[svn:parrot-pdd] r18010 - trunk/docs/pdds
Author: kjs Date: Fri Apr 6 09:44:16 2007 New Revision: 18010 Modified: trunk/docs/pdds/pdd15_objects.pod Log: pdd15: * fix typo ('languaes' => 'languages') Modified: trunk/docs/pdds/pdd15_objects.pod == --- trunk/docs/pdds/pdd15_objects.pod (original) +++ trunk/docs/pdds/pdd15_objects.pod Fri Apr 6 09:44:16 2007 @@ -261,7 +261,7 @@ class object that replaces the old class object in the Namespace. However, the old class object must be kept, as the old objects still point to it and do their method resolution and attribute lookup through -that class object. +that class object. If a class hasn't been instantiated, adding a method or attribute only modifies the existing class object instead of creating a new class @@ -444,7 +444,7 @@ It also takes slurpy named parameters to flag whether the method is a vtable method, and whether its anonymous (no named entry as a method, -only as a vtable). +only as a vtable). =item methods @@ -561,7 +561,7 @@ B isa A A o1 = new B(); B o2 = new B(); - + o1.x; # retrieves A's attribute o2.x; # retrieves B's attribute @@ -782,7 +782,7 @@ It also takes slurpy named parameters to flag whether the method is a vtable method, and whether its anonymous (no named entry as a method, -only as a vtable). +only as a vtable). =item methods @@ -800,7 +800,7 @@ When a role is added to a class, we try to compose it right away, and throw an exception on any conflicts that are detected. A conflict occurs if two roles try to supply a method of the same name (but see the note -on multi-methods below). High level languaes will provide varying +on multi-methods below). High level languages will provide varying facilities to deal with this, and Parrot provides the primitives to implement them. @@ -1086,7 +1086,7 @@ =head2 PMCS -Ruby: Just like Smalltalk, everything is an object. I'm hoping to be able to +Ruby: Just like Smalltalk, everything is an object. I'm hoping to be able to implement core Ruby classes (String, Array, Hash, Module, etc) something like this. ParrotClass @@ -1216,7 +1216,7 @@ delegation. Perl 6: Delegation support is highly flexible, even allowing a regex to match -method names that should be delegated to a particular object. +method names that should be delegated to a particular object. =head2 Prototype-based OO
[svn:parrot-pdd] r18011 - trunk/docs/pdds
Author: kjs Date: Fri Apr 6 10:09:26 2007 New Revision: 18011 Modified: trunk/docs/pdds/pdd15_objects.pod Log: pdd15: * fix minor typo (PMCS -> PMCs) * add space to fix inheritance tree of RubyString example. Modified: trunk/docs/pdds/pdd15_objects.pod == --- trunk/docs/pdds/pdd15_objects.pod (original) +++ trunk/docs/pdds/pdd15_objects.pod Fri Apr 6 10:09:26 2007 @@ -1084,12 +1084,12 @@ Notes on some of the OO-related needs of various languages. -=head2 PMCS +=head2 PMCs Ruby: Just like Smalltalk, everything is an object. I'm hoping to be able to implement core Ruby classes (String, Array, Hash, Module, etc) something like this. -ParrotClass + ParrotClass | RubyClass String | |
[svn:parrot-pdd] r18013 - trunk/docs/pdds
Author: kjs Date: Fri Apr 6 10:18:06 2007 New Revision: 18013 Modified: trunk/docs/pdds/pdd15_objects.pod Log: pdd15: * yet another minor typo: 'instantiatated -> instantiated' Modified: trunk/docs/pdds/pdd15_objects.pod == --- trunk/docs/pdds/pdd15_objects.pod (original) +++ trunk/docs/pdds/pdd15_objects.pod Fri Apr 6 10:18:06 2007 @@ -286,7 +286,7 @@ We may eventually be able to eliminate the registry of class IDs altogether. -A class can be garbage collected when it has no instantiatated objects +A class can be garbage collected when it has no instantiated objects and no Namespace object referencing it (to mark it as live). When a class is garbage collected, it should remove itself from the registry.
[svn:parrot-pdd] r21733 - trunk/docs/pdds/draft
Author: kjs Date: Mon Oct 1 21:05:37 2007 New Revision: 21733 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: docs/pdd19_pir.pod: * add note about multiple heredocs per statement * add .pcc_* directives (explicit listing instead of "*") Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Mon Oct 1 21:05:37 2007 @@ -135,6 +135,17 @@ Only one heredoc can be active per statement line. +{{ REVIEW: it would be useful to have multiple heredocs per statement, + which allows for writing: + + function(<<'INPUT', <<'OUTPUT', 'some test') + ... + INPUT + ... + OUTPUT + +}} + =item charset:"string constant" Like above with a chracter set attached to the string. Valid character @@ -326,7 +337,19 @@ =item .pcc_* -Directives used for Parrot Calling Conventions. +Directives used for Parrot Calling Conventions. These are: + +=over 4 + +=item .pcc_begin and .pcc_end + +=item .pcc_begin_return and .pcc_end_return + +=item .pcc_begin_yield and .pcc_end_yield + +=item .pcc_call + +=back =back
[svn:parrot-pdd] r21734 - trunk/docs/pdds/draft
Author: kjs Date: Mon Oct 1 21:23:47 2007 New Revision: 21734 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: pdd19_pir.pod: * add comment with respect to "pcc_" prefix on calling directives. Refers to (newly opened) ticket #45925. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Mon Oct 1 21:23:47 2007 @@ -351,6 +351,8 @@ =back +{{ REVIEW: Do we still want/need the "pcc_" prefix? See #45925. }} + =back =head2 Directives for subroutine parameters and return
[svn:parrot-pdd] r21732 - trunk/docs/pdds/draft
Author: kjs Date: Mon Oct 1 20:17:53 2007 New Revision: 21732 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: docs/pdd19 * add note about method name spec. (bare/quote/register). Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Mon Oct 1 20:17:53 2007 @@ -401,6 +401,10 @@ PCC function call with B<.pcc_*> directives. I can denote a global subroutine, a local B or a B. +{{We should review the (currently inconsistent) specification of the +method name. Currently it can be a bare word, a quoted string or a +string register. See #45859.}} + =item .return ([ [: ...], ...]) Return from the current compilation unit with zero or more values.
[svn:parrot-pdd] r21823 - trunk/docs/pdds/draft
Author: kjs Date: Thu Oct 4 05:27:44 2007 New Revision: 21823 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: pdd19_pir.pod: * add note about issue of op-names as identifiers. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Thu Oct 4 05:27:44 2007 @@ -66,6 +66,8 @@ {{ REVIEW: identifier length limit }} +{{ REVIEW: can op-names be used as identifiers? See #24251. }} + Example: a
[svn:parrot-pdd] r22124 - trunk/docs/pdds/draft
Author: kjs Date: Tue Oct 16 02:33:38 2007 New Revision: 22124 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: docs/draft/pdd19_pir.pod: * remove incorrect reference to ticket about ".globalconst", which is not to be removed; the ticket refers to ".global" only. * add note to ".param " syntax, which is not working. A reference to a ticket is added. * add ".param" "string" => as a supported variant to docs. * remove whitespace. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Tue Oct 16 02:33:38 2007 @@ -6,7 +6,7 @@ =head1 ABSTRACT -This document describes PIR, a stable, middle-level language for both +This document describes PIR, a stable, middle-level language for both compiler and human to target on. =head1 VERSION @@ -25,7 +25,7 @@ =head1 Statements A valid PIR program consists of a sequence of I. A -I is terminated by a newline (). So, each statement has to be +I is terminated by a newline (). So, each statement has to be on its own line. =head2 General statement format @@ -38,13 +38,13 @@ =head2 Labels PIR code has both local and global labels. Global labels start with an -underscore, local labels shouldn't. Optional label for the given -instruction, can stand on its own line. A label must conform to the syntax +underscore, local labels shouldn't. Optional label for the given +instruction, can stand on its own line. A label must conform to the syntax of B described below. -The name of a global label has to be unique, since it can be called at any -point in the program. A local label is accessible only in the compilation -unit where it's defined. A local label name must be unique within a +The name of a global label has to be unique, since it can be called at any +point in the program. A local label is accessible only in the compilation +unit where it's defined. A local label name must be unique within a compilation unit, but it can be reused in other compilation units. Examples: @@ -83,7 +83,7 @@ =item -A PASM register In, Sn, Nn, Pn, or a PIR temporary register $In, $Sn, $Nn, +A PASM register In, Sn, Nn, Pn, or a PIR temporary register $In, $Sn, $Nn, $Pn, where B consists of digit(s) only. B must be between 1 and 99. {{ REVIEW: n limit }} @@ -116,7 +116,7 @@ Heredocs work like single or double quoted strings. All lines up to the terminating delimiter is slurped into the string. The delimiter -has to be on its own line, at the begging of the line and with no trailing +has to be on its own line, at the begging of the line and with no trailing whitespace. Assignment of a heredoc: @@ -137,15 +137,15 @@ Only one heredoc can be active per statement line. -{{ REVIEW: it would be useful to have multiple heredocs per statement, +{{ REVIEW: it would be useful to have multiple heredocs per statement, which allows for writing: - + function(<<'INPUT', <<'OUTPUT', 'some test') ... INPUT ... OUTPUT - + }} =item charset:"string constant" @@ -217,9 +217,9 @@ =item .HLL_map 'CoreType', 'UserType' -Whenever Parrot has to create PMCs inside C code on behalf of the running -user program it consults the current type mapping for the executing HLL -and creates a PMC of type I<'UserType'> instead of I<'CoreType'>, if such +Whenever Parrot has to create PMCs inside C code on behalf of the running +user program it consults the current type mapping for the executing HLL +and creates a PMC of type I<'UserType'> instead of I<'CoreType'>, if such a mapping is defined. E.g. with this code snippet ... @@ -254,12 +254,12 @@ =item .emit -Define a I containing PASM code. Always paired with +Define a I containing PASM code. Always paired with C<.eom>. =item .eom -End a I containing PASM code. Always paired with +End a I containing PASM code. Always paired with C<.emit>. =item .local [:unique_reg] @@ -306,7 +306,8 @@ =item .globalconst = -{{ PROPOSAL: to be removed, see RT#45407 }} +As C<.const> above, but the defined constant is globally accessible. + =item .namespace @@ -361,14 +362,22 @@ =over 4 -=item .param [: ...] +=item .param [:]* At the top of a subroutine, declare a local variable, in the mannter of B<.local>, into which parameter(s) of the current subroutine should be stored. Available flags: C<:slurpy>, C<:optional>, C<:opt_flag> and C<:unique_reg>. -=item .param [: ...] +=item .param "" => [:]* + +Define a named parameter. This is syntactic sugar for: + + .param :named("") + +=item .param [:]* + +{{ Specifying a r
[svn:parrot-pdd] r22164 - trunk/docs/pdds/draft
Author: kjs Date: Wed Oct 17 02:41:08 2007 New Revision: 22164 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: pdd19_pir.pod: * fix typo * remove .param " syntax description; is not implemented anyway. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Oct 17 02:41:08 2007 @@ -364,7 +364,7 @@ =item .param [:]* -At the top of a subroutine, declare a local variable, in the mannter +At the top of a subroutine, declare a local variable, in the manner of B<.local>, into which parameter(s) of the current subroutine should be stored. Available flags: C<:slurpy>, C<:optional>, C<:opt_flag> and C<:unique_reg>. @@ -375,14 +375,6 @@ .param :named("") -=item .param [:]* - -{{ Specifying a register for a parameter does not work. See. RT#46455. }} - -At the top of a subroutine, specify where parameter(s) of the current -subroutine should be stored. Available flags: -C<:slurpy>, C<:optional>, C<:opt_flag> and C<:unique_reg>. - =item .return [: ...] Between B<.pcc_begin_return> and B<.pcc_end_return>, specify one or
[svn:parrot-pdd] r22276 - trunk/docs/pdds/draft
Author: kjs Date: Fri Oct 19 12:40:49 2007 New Revision: 22276 Modified: trunk/docs/pdds/draft/pdd06_pasm.pod Log: and yet another line too long in pdd06_pasm.pod Modified: trunk/docs/pdds/draft/pdd06_pasm.pod == --- trunk/docs/pdds/draft/pdd06_pasm.pod(original) +++ trunk/docs/pdds/draft/pdd06_pasm.podFri Oct 19 12:40:49 2007 @@ -49,7 +49,8 @@ allison: which is what we want, anyway, right? particle: yup yes - good, looks like we're in agreement and headed in the proper direction on that topic. + good, looks like we're in agreement and headed in the proper direction on +that topic. =back
[svn:parrot-pdd] r22275 - trunk/docs/pdds/draft
Author: kjs Date: Fri Oct 19 12:39:10 2007 New Revision: 22275 Modified: trunk/docs/pdds/draft/pdd06_pasm.pod Log: make line length test pass for pdd06_pasm.pod Modified: trunk/docs/pdds/draft/pdd06_pasm.pod == --- trunk/docs/pdds/draft/pdd06_pasm.pod(original) +++ trunk/docs/pdds/draft/pdd06_pasm.podFri Oct 19 12:39:10 2007 @@ -25,29 +25,31 @@ =over 4 =item * - Can we get rid of PASM ? - conversely, does PASM need to be kept up to date? - PASM is just a text form of PBC, so it should be kept - are there specific PBC features that can't currently be represented in PASM? - besides hll and :outer? -:init -lexicals? -:vtable -I'm a bit rusty, but anything that starts with a '.' or ':' is suspect - things that start with '.' are just directives to IMCC, equally applicable to PASM and PIR -isn't PASM separate from IMCC? - mdiep: it used to be separate -so to say that PASM can have directives is a major architectural change - perhaps the biggest thing we need is a definition of what PASM actually is - the line has grown quite fuzzy over the years - PASM could be defined as stringified PBC - compilable stringified pbc -it should be defined that way if we're going to call it assembly. - barney: that's the most likely direction, and if so, it has some implications for how PASM behaves - allison: which is what we want, anyway, right? - particle: yup - yes - good, looks like we're in agreement and headed in the proper direction on that topic. +Can we get rid of PASM ? + conversely, does PASM need to be kept up to date? + PASM is just a text form of PBC, so it should be kept + are there specific PBC features that can't currently be represented in PASM? + besides hll and :outer? + :init + lexicals? + :vtable + I'm a bit rusty, but anything that starts with a '.' or ':' is suspect + things that start with '.' are just directives to IMCC, +equally applicable to PASM and PIR + isn't PASM separate from IMCC? + mdiep: it used to be separate + so to say that PASM can have directives is a major architectural change + perhaps the biggest thing we need is a definition of what PASM actually is + the line has grown quite fuzzy over the years +PASM could be defined as stringified PBC + compilable stringified pbc + it should be defined that way if we're going to call it assembly. + barney: that's the most likely direction, and if so, it has some implications +for how PASM behaves + allison: which is what we want, anyway, right? + particle: yup +yes + good, looks like we're in agreement and headed in the proper direction on that topic. =back
[svn:parrot-pdd] r22279 - trunk/docs/pdds/draft
Author: kjs Date: Fri Oct 19 13:06:18 2007 New Revision: 22279 Modified: trunk/docs/pdds/draft/pdd06_pasm.pod Log: and yet another line too long in pdd06; fixing. Modified: trunk/docs/pdds/draft/pdd06_pasm.pod == --- trunk/docs/pdds/draft/pdd06_pasm.pod(original) +++ trunk/docs/pdds/draft/pdd06_pasm.podFri Oct 19 13:06:18 2007 @@ -1252,7 +1252,8 @@ =over 4 -=item * Fixed stack ops; push, pop, and clear properly documented according to the engine's behaviour now. +=item * Fixed stack ops; push, pop, and clear properly documented according to the +engine's behaviour now. =back
[svn:parrot-pdd] r22404 - trunk/docs/pdds/draft
Author: kjs Date: Mon Oct 22 13:43:08 2007 New Revision: 22404 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: pdd19_pir.pod: o add macro stuff I sent to list earlier, as requested by Allison. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Mon Oct 22 13:43:08 2007 @@ -15,6 +15,9 @@ =head1 DESCRIPTION +This document is the Parrot Design Document for the Parrot Intermediate +Representation (PIR). + =head1 Comments and empty lines Comments start with B<#> and last until the following newline. These @@ -110,13 +113,13 @@ Are delimited by B<">. A B<"> inside a string must be escaped by B<\>. Only 7-bit ASCII is accepted in string constants; to use -characters outside thar range, specify an encoding in the way below. +characters outside that range, specify an encoding in the way below. =item <<"heredoc", <<'heredoc' Heredocs work like single or double quoted strings. All lines up to the terminating delimiter are slurped into the string. The delimiter -has to be on its own line, at the beginning of the line and with no +has to be on its own line, at the beginning of the line and with no trailing whitespace. Assignment of a heredoc: @@ -488,7 +491,7 @@ =item unless goto -Unless B evaluates as true, jump to the named B. Translate +Unless B evaluates as true, jump to the named B. Translate to B. =item if null goto @@ -503,13 +506,13 @@ =item ifgoto -The B can be: B, E=, ==, != E= E> which translate -to the PASM opcodes B, B, B, B, B or B. If B +The B can be: B, E=, ==, != E= E> which translate +to the PASM opcodes B, B, B, B, B or B. If B B B evaluates as true, jump to the named B. =item unlessgoto -The B can be: B, E=, ==, != E= E> which translate +The B can be: B, E=, ==, != E= E> which translate to the PASM opcodes B, B, B, B, B or B. Unless B B B evaluates as true, jump to the named B. @@ -539,10 +542,10 @@ =item = -This is equivalent to +This is equivalent to Bvar1E = Evar1E EopE Evar2E>. Where B is called an assignment operator and can be any of the following -binary operators described earlier: B<+>, B<->, B<*>, B, B<%>, B<.>, +binary operators described earlier: B<+>, B<->, B<*>, B, B<%>, B<.>, B<&>, B<|>, B<~>, BE>, BE> or BEE>. =item = [ ] @@ -620,6 +623,205 @@ =back + + +=head1 MACRO LAYER + +This section describes the macro layer of the PIR language. + +=head3 Current Situation + +The macro layer of the PIR compiler handles the following directives: + +=over 4 + +=item * C<.include> + +The C<.include> directive takes a string argument that contains the +name of the PIR file that is included. + +=item * C<.macro> + +The C<.macro> directive starts the definition of a macro. + +=item * C<.constant> + +The C<.constant> directive is a special type of macro; it allows the +user to use a symbolic name for a constant value or a register. + +=back + + +=head3 Proposed Situation + +The current macro layer has a few limitations. These are listed below. + +=over 4 + +=item * Macro parameter list + +If a macro defines no parameter list (not even the parentheses), then +the macro expansion should not specify any parenthesis. This means that +a macro defined as: + + .macro foo + ... + .endm + +can only be expanded by writing C<.foo>. Writing C<.foo()> is an error. +If, however, the macro definition is written as: + + .macro foo() + ... + .endm + +then writing C<.foo> is an error, and instead the user should write this +as C<.foo()>. On the one hand this behavior is consistent, but on the other +hand the error message is somewhat dubious; if the user writes C<.foo> when +the macro was defined as above (C), then the error message indicates +that the macro needs 1 argument. + +Some rationalization would be desirable. + +=item * Heredoc arguments + +Heredoc arguments are not allowed when expanding a macro. This means that +the following is not allowed: + + .macro foo(bar) + ... + .endm + + .foo(<<'EOS') + This is a heredoc +string. + + EOS + +=item * Unique local variables + +Within the macro body, the user can declare a unique label identifier using +the value of a macro parameter, like so: + + .macro foo(a) + ... + .label $a: + ... + .endm + +Currently, IMCC still allows for writing C<.local> to declare a local label, +but that is deprecated. Use C<.label> instead. + +However, it would be helpful if it were possible to declare unique local variables +as well. The syntax for this could be as follows: + + .macro foo(b) + ... + .local int $b + ... + .$b = 42 + print .$b #
[svn:parrot-pdd] r22547 - trunk/docs/pdds/draft
Author: kjs Date: Sun Oct 28 06:24:43 2007 New Revision: 22547 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: pdd19; remove word to fix grammar thing. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Sun Oct 28 06:24:43 2007 @@ -6,7 +6,7 @@ =head1 ABSTRACT -This document is outlines the architecture and core syntax of the Parrot +This document outlines the architecture and core syntax of the Parrot Intermediate Representation (PIR). This document describes PIR, a stable, middle-level language for both @@ -54,7 +54,7 @@ letters, digits, and underscores. Identifiers don't have any limit on length at the moment, but some sane-but-generous length limit may be imposed in the future (256 chars, 1024 chars?). The following examples are all valid -identifiers. +identifiers. a _a @@ -197,7 +197,7 @@ =back -=head2 Directives +=head2 Directives =over 4 @@ -473,13 +473,13 @@ =item ifgoto The I can be: C, E=, ==, != E= E> which translate -to the PASM opcodes C, C, C, C, C or C. If +to the PASM opcodes C, C, C, C, C or C. If I evaluates as true, jump to the named I. =item unlessgoto The I can be: C, E=, ==, != E= E> which translate -to the PASM opcodes C, C, C, C, C or C. Unless +to the PASM opcodes C, C, C, C, C or C. Unless I evaluates as true, jump to the named I. =item = @@ -895,9 +895,9 @@ {{ NOTE: response to the question: - I don't think that 'morph' as a method call is a good idea - we need something that says "assign to value" versus "assign to container" - we can't eliminate the existing 'morph' opcode until we have a replacement + I don't think that 'morph' as a method call is a good idea + we need something that says "assign to value" versus "assign to container" + we can't eliminate the existing 'morph' opcode until we have a replacement }}
[svn:parrot-pdd] r22709 - trunk/docs/pdds/draft
Author: kjs Date: Sun Nov 4 11:54:16 2007 New Revision: 22709 Modified: trunk/docs/pdds/draft/pdd06_pasm.pod Log: [pdd06] add ":anon" flag to pasm grammar (this is allowed in pasm too). Modified: trunk/docs/pdds/draft/pdd06_pasm.pod == --- trunk/docs/pdds/draft/pdd06_pasm.pod(original) +++ trunk/docs/pdds/draft/pdd06_pasm.podSun Nov 4 11:54:16 2007 @@ -130,7 +130,7 @@ ".pcc_sub" [ sub_flag ]? sub_flag: - ":init" | ":main" | ":load" | ":postcomp" | ":immediate" + ":init" | ":main" | ":load" | ":postcomp" | ":immediate" | ":anon" label: identifier ":" @@ -1252,7 +1252,7 @@ =over 4 -=item * Fixed stack ops; push, pop, and clear properly documented according to the +=item * Fixed stack ops; push, pop, and clear properly documented according to the engine's behaviour now. =back
[svn:parrot-pdd] r23020 - trunk/docs/pdds/draft
Author: kjs Date: Sat Nov 24 11:11:16 2007 New Revision: 23020 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] clarify text for single quoted strings. Replace "char string" with "single quoted string", as suggested by pmichaud++ and masak++. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Sat Nov 24 11:11:16 2007 @@ -115,12 +115,12 @@ =over 4 -=item 'char constant' +=item 'single-quoted string constant' Are delimited by single-quotes (C<'>). They are taken to be ASCII encoded. No escape sequences are processed. -=item "string constants" +=item "double-quoted string constants" Are delimited by double-quotes (C<">). A C<"> inside a string must be escaped by C<\>. Only 7-bit ASCII is accepted in string constants; to use characters
[svn:parrot-pdd] r23177 - trunk/docs/pdds/draft
Author: kjs Date: Wed Nov 28 03:16:34 2007 New Revision: 23177 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] remove .sym from pdd19 - pir. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Nov 28 03:16:34 2007 @@ -214,12 +214,6 @@ associate the identifier with a unique register for the duration of the compilation unit. -=item .sym [deprecated, see RT#45405] - - .sym [:unique_reg] - -Same as C<.local>. - =item .lex , Declare a lexical variable that is an alias for a PMC register. For example, @@ -897,7 +891,7 @@ .arg x .arg y .arg z - .pcc_call $P0, $P1 # r = _sub_label(x, y, z) + .pcc_call $P0, $P1# r = _sub_label(x, y, z) ret_addr: .local int r # optional - new result var .result r
[svn:parrot-pdd] r23196 - trunk/docs/pdds/draft
Author: kjs Date: Wed Nov 28 08:04:01 2007 New Revision: 23196 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] remove .pcc_ prefix. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Nov 28 08:04:01 2007 @@ -872,9 +872,9 @@ .param int b # I6 .param int c # I7 ... - .pcc_begin_return + .begin_return .return xy # e.g. I5 - .pcc_end_return + .end_return ... .end @@ -887,15 +887,15 @@ .local int x .local num y .local str z - .pcc_begin + .begin_call .arg x .arg y .arg z - .pcc_call $P0, $P1# r = _sub_label(x, y, z) + .call $P0, $P1# r = _sub_label(x, y, z) ret_addr: .local int r # optional - new result var .result r - .pcc_end + .end_call =head2 Subroutine Call Syntactic Sugar
[svn:parrot-pdd] r23504 - trunk/docs/pdds/draft
Author: kjs Date: Wed Dec 5 09:08:50 2007 New Revision: 23504 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] * remove some notes about deprecated things that are removed by now. * add .get_results directive. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Dec 5 09:08:50 2007 @@ -338,8 +338,6 @@ above), but string sub names can contain any characters, including characters from different character sets (see L above). -{{ NOTE: the optional comma in the flag list is deprecated RT#45697 }} - Always paired with C<.end>. =item .end @@ -360,8 +358,6 @@ =head3 Directives used for Parrot calling conventions. -{{ DEPRECATED: the "pcc_" prefix. See #45925. }} - =over 4 =item .begin_call and .end_call @@ -420,6 +416,24 @@ {{ TODO: once these flag bits are solidified by long-term use, then we may choose to copy appropriate bits of the documentation to here. }} + +=head3 Catching Exceptions + +Using the C op you can install an exception handler. If an exception +is thrown, Parrot will execute the installed exception handler. In order to +retrieve the thrown exception, use the C<.get_results> directive. + + push_eh handler + ... + handler: + .local pmc exception + .local string message + .get_results (exception, message) + ... + +This is syntactic sugar for the C op, but any flags set on the +targets will be handled automatically by the PIR compiler. + =head2 Syntactic Sugar Any PASM opcode is a valid PIR instruction. In addition, PIR defines some
[svn:parrot-pdd] r23799 - trunk/docs/pdds/draft
Author: kjs Date: Wed Dec 12 10:24:43 2007 New Revision: 23799 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] Add section about sub flags into PDD 19. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Dec 12 10:24:43 2007 @@ -329,9 +329,9 @@ .sub [: ...] Define a compilation unit. All code in a PIR source file must be defined in a -compilation unit. See L for +compilation unit. See the section C for available flags. Optional flags are a list of I, separated by empty -spaces, and empty spaces only. +spaces. The name of the sub may be either a bare identifier or a quoted string constant. Bare identifiers must be valid PIR identifiers (see L @@ -356,6 +356,90 @@ =back +=head3 Subroutine flags + +This is a list of zero or more items with the following meanings: + +=over 4 + +=item :main + +Define "main" entry point to start execution. If multiple subroutines +are marked as B<:main>, the B marked subroutine is entered. + +=item :load + +Run this subroutine during the B opcode. +If multiple subs have the B<:load> pragma, the subs are +run in source code order. + +=item :init + +Run the subroutine when the program is run directly (that is, not loaded as a +module). This is different from B<:load>, which runs a subroutine when a +library is being loaded. To get both behaviours, use B<:init :load>. + +=item :anon + +Do not install this subroutine in the namespace. Allows the subroutine +name to be reused. + +=item :multi(Type1, Type2...) + +Engage in multiple dispatch with the listed types. + +=item :immediate + +This subroutine is executed immediately after being compiled. (Analagous to +C in perl5.) + +=item :postcomp + +Same as C<:immediate>, except that the subroutine is B executed when +the compilation of the file that contains the subroutine is triggered by +a C instruction in another file. + +An example. File C contains: + + .sub main + load_bytecode "foo.pir" + .end + +The file C contains: + + .sub foo :immediate + print "42" + .end + + .sub bar :postcomp + print "43" + .end + +When executing file C, it will execute both C and C. +However, when executing the file C, only C will be executed. + +=item :method + +The marked C<.sub> is a method. In the method body, the object PMC +can be referred to with C. + +=item :vtable + +The marked C<.sub> overrides a v-table method. By default, a sub with the same +name as a v-table method does not override the v-table method. To specify that +there should be no namespace entry (that is, it just overrides the v-table +method but is callable as a normal method), use B<:vtable :anon>. To give the +v-table method a different name, use B<:vtable("...")>. For example, to have +the method B also be the v-table method B), use +B<:vtable("get_string")>. + +=item :outer(subname) + +The marked C<.sub> is lexically nested within the sub known by B. + +=back + + =head3 Directives used for Parrot calling conventions. =over 4
[svn:parrot-pdd] r23800 - trunk/docs/pdds/draft
Author: kjs Date: Wed Dec 12 10:51:05 2007 New Revision: 23800 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] remove some old stuff, add some stuff from docs/imcc/calling_conventions.pod. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Dec 12 10:51:05 2007 @@ -1,4 +1,5 @@ # Copyright (C) 2007, The Perl Foundation. +# $Id$ =head1 NAME @@ -358,8 +359,6 @@ =head3 Subroutine flags -This is a list of zero or more items with the following meanings: - =over 4 =item :main @@ -446,24 +445,52 @@ =item .begin_call and .end_call +Directives to start and end a subroutine invocation, respectively. + =item .begin_return and .end_return +Directives to start and end a statement to return values. + =item .begin_yield and .end_yield +Directives to start and end a statement to yield values. + =item .call -=item .return [: ...] +Takes either 2 arguments: the sub and the return continuation, or the +sub only. For the latter case an B gets emitted. Providing +an explicit return continuation is more efficient, if its created +outside of a loop and the call is done inside a loop. + +=item .invocant + +Directive to specify the object for a method call. Use it in combination +with C<.meth_call>. + +=item .meth_call + +Directive to do a method call. It calls the specified method on the object +that was specified with the C<.invocant> directive. + +=item .nci_call + +Directive to make a call through the Native Calling Interface (NCI). +The specified subroutine must be loaded using the op that takes +the library, function name and function signature as arguments. +See L for details. + +=item .return [:]* Between C<.begin_return> and C<.end_return>, specify one or more of the return value(s) of the current subroutine. Available flags: C<:flat>, C<:named>. -=item .arg [: ...] +=item .arg [:]* Between C<.begin_call> and C<.call>, specify an argument to be passed. Available flags: C<:flat>, C<:named>. -=item .result [: ...] +=item .result [:]* Between C<.call> and C<.end_call>, specify where one or more return value(s) should be stored. Available flags: @@ -497,15 +524,16 @@ and C, which correspond to the calling convention flags C<:slurpy>, C<:optional>, C<:opt_flag>, and C<:flat>. -{{ TODO: once these flag bits are solidified by long-term use, then we -may choose to copy appropriate bits of the documentation to here. }} - =head3 Catching Exceptions Using the C op you can install an exception handler. If an exception is thrown, Parrot will execute the installed exception handler. In order to -retrieve the thrown exception, use the C<.get_results> directive. +retrieve the thrown exception, use the C<.get_results> directive. This directive +always takes 2 arguments: an exception object and a message string. + +{{ Wouldn't it be more useful to make this flexible, or at least only the + exception object? The message can be retrieved from the exception object. }} push_eh handler ... @@ -966,12 +994,12 @@ =head2 Subroutine Definition .sub _sub_label [Subpragma, ...] - .param int a # I5 - .param int b # I6 - .param int c # I7 + .param int a + .param int b + .param int c ... .begin_return - .return xy # e.g. I5 + .return xy .end_return ... .end
[svn:parrot-pdd] r23801 - trunk/docs/pdds/draft
Author: kjs Date: Wed Dec 12 11:00:49 2007 New Revision: 23801 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] move all useful stuff from docs/imcc/calling_conventions into pdd19. Lots of the latter file is outdated, this file will be removed shortly. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Dec 12 11:00:49 2007 @@ -850,8 +850,6 @@ ... .endm -{{ NOTE: Currently, IMCC still allows for writing C<.local> to declare a local -label, but that is deprecated. Use C<.label> instead. }} =head3 Unique local variables @@ -993,7 +991,7 @@ =head2 Subroutine Definition - .sub _sub_label [Subpragma, ...] + .sub _sub_label []* .param int a .param int b .param int c @@ -1023,6 +1021,20 @@ .result r .end_call +=head2 NCI Call + + load_lib $P0, "libname" + dlfunc $P1, $P0, "funcname", "signature" + ... + .begin_call + .arg x + .arg y + .arg z + .nci_call $P1 # r = funcname(x, y, z) + .local int r # optional - new result var + .result r + .end_call + =head2 Subroutine Call Syntactic Sugar ... # variable decls @@ -1036,6 +1048,100 @@ $P0(args) +=head2 Methods + + .namespace [ "Foo" ] + + .sub _sub_label :method [,Subpragma, ...] + .param int a + .param int b + .param int c + ... + self."_other_meth"() + ... + .begin_return + .return xy + .end_return + ... + .end + +The variable "self" automatically refers to the invocating object, if the +subroutine declaration contains "method". + +=head2 Calling Methods + +The syntax is very similar to subroutine calls. The call is done with +C which must immediately be preceded by the C<.invocant>: + + .local pmc class + .local pmc obj + newclass class, "Foo" + new obj, class + .begin_call + .arg x + .arg y + .arg z + .invocant obj + .meth_call "_method" [, $P1 ] # r = obj."_method"(x, y, z) + .local int r # optional - new result var + .result r + .end_call + +The return continuation is optional. The method can be a string +constant or a string variable. + +=head2 Returning and Yielding + + .return ( a, b ) # return the values of a and b + + .return ()# return no value + + .return func_call() # tail call function + + .return o."meth"()# tail method call + +Similarly, one can yield using the .yield directive + + .yield ( a, b ) # yield with the values of a and b + + .yield ()# yield with no value + + +=head2 Stack calling conventions + +Arguments are Bd in reverse order onto the user stack: + + .arg y # save args in reversed order + .arg x + call _foo#(r, s) = _foo(x,y) + .local int r + .local int s + .result r# restore results in order + .result s# + +and return values are Bd in argument order from there. + + + + .sub _foo # sub foo(int a, int b) + saveall + .param int a # receive arguments from left to right + .param int b + ... + + .return mi # return (pl, mi), push results + .return pl # in reverse order + restoreall + ret + .end + +Pushing arguments in reversed order on the user stack makes the left +most argument the top of stack entry. This allows for a variable +number of function arguments (and return values), where the left most +argument before a variable number of following arguments is the +argument count. + + =head1 ATTACHMENTS N/A
[svn:parrot-pdd] r23841 - trunk/docs/pdds/draft
Author: kjs Date: Thu Dec 13 04:22:18 2007 New Revision: 23841 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] add #line directive. Also add a proposal to change this into .line. (ticket ref. included). Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Thu Dec 13 04:22:18 2007 @@ -355,6 +355,21 @@ End a compilation unit containing PASM code. Always paired with C<.emit>. + +=item #line + +Set the line number and filename to the value specified. This is useful in +case the PIR code is generated from some source file, and any error messages +should print the source file's location, not the line number and filename of +the generated file. + +{{ PROPOSAL: Change this to: + + .line ',' + +which is more consistent, and not as confusing as #line, which looks as a comment. +Also, the #line directive must be at the beginning of the line. See [RT#45857]. }} + =back =head3 Subroutine flags
[svn:parrot-pdd] r23876 - trunk/docs/pdds/draft
Author: kjs Date: Fri Dec 14 01:59:47 2007 New Revision: 23876 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] fix docs for .macro_const and some other clarif. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Fri Dec 14 01:59:47 2007 @@ -755,20 +755,30 @@ =over 4 -=item * C<.include> +=item * C<.include> "" The C<.include> directive takes a string argument that contains the name of the PIR file that is included. -=item * C<.macro> +=item * C<.macro> [] -The C<.macro> directive starts the definition of a macro. +The C<.macro> directive starts the definition of a macro named by the specified +identifier. The optional parameter list is a comma-separated list of identifiers, +enclosed in parentheses. +See C<.endm> for ending the macro definition. -=item * C<.macro_const> (Not Implemented: See RT #48563) +=item * <.endm> + +Closes a macro definition. + +=item * C<.macro_const> (|) + + .macro_const PI 3.14 The C<.macro_const> directive is a special type of macro; it allows the user to use a symbolic name for a constant value. Like C<.macro>, the substitution -occurs at compile time. +occurs at compile time. It takes two arguments (not comma separated), the first +is an identifier, the second a constant value or a register. {{ NOTE: C<.constant> is deprecated, replaced by C<.macro_const>. See RT #48561 }}
[svn:parrot-pdd] r23923 - trunk/docs/pdds/draft
Author: kjs Date: Sat Dec 15 03:09:12 2007 New Revision: 23923 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] add deprecation note at .emit/.eom dir'ves Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Sat Dec 15 03:09:12 2007 @@ -350,11 +350,14 @@ Define a compilation unit containing PASM code (only opcodes and a limited subset of directives). Always paired with C<.eom>. +{{ DEPRECATED. See RT#47846 }} + =item .eom End a compilation unit containing PASM code. Always paired with C<.emit>. +{{ DEPRECATED. See RT#47846 }} =item #line
[svn:parrot-pdd] r23918 - trunk/docs/pdds/draft
Author: kjs Date: Sat Dec 15 02:11:50 2007 New Revision: 23918 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] add something about unique ids for macro exapnsions for unique labels.locals. removed the comment suggesting this. imcc currently supports the labels; locals will be done later (compilers/pirc/[new/macro] supports this, but is not yet complete) Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Sat Dec 15 02:11:50 2007 @@ -896,10 +896,10 @@ to the parser will read as follows: .sub main -.local int local__foo__b +.local int local__foo__b__2 ... -local__foo__b = 42 -print local__foo__b +local__foo__b__2 = 42 +print local__foo__b__2 .end @@ -940,16 +940,14 @@ This will result in code for the parser as follows: .sub main -.local int local__foo__x -.local int local__bar__x +.local int local__foo__x__2 +.local int local__bar__x__4 .end - -{{ PROPOSAL: should C<.macro_local> also add a random value to the munged name, -to allow multiple calls to the same macro from within the same compilation -unit? May not be used often enough to be worth adding it. The same effect can -be achieved by using a symbolic parameter name for the macro local, it's just -slightly less convenient. }} +Each expansion is associated with a unique number; for labels declared with +C<.macro_label> and locals declared with C<.macro_local> expansions, this +means that multiple expansions of a macro will not result in conflicting +label or local names. =head3 Ordinary local variables
[svn:parrot-pdd] r24075 - trunk/docs/pdds/draft
Author: kjs Date: Wed Dec 19 09:40:15 2007 New Revision: 24075 Modified: trunk/docs/pdds/draft/pdd06_pasm.pod Log: [pdd06] change .constant into .macro_const Modified: trunk/docs/pdds/draft/pdd06_pasm.pod == --- trunk/docs/pdds/draft/pdd06_pasm.pod(original) +++ trunk/docs/pdds/draft/pdd06_pasm.podWed Dec 19 09:40:15 2007 @@ -94,7 +94,7 @@ single parameter, the name of the namespace, in the form of a multi-dimensional key. -Constants can be declared with the C<.constant> directive. It takes two +Constants can be declared with the C<.macro_const> directive. It takes two parameters: the name of the constant and the value. Subroutine names are noted with the C<.pcc_sub> directive. It takes a @@ -136,7 +136,7 @@ identifier ":" constant_directive: - ".constant" identifier literal + ".macro_const" identifier literal namespace_directive: ".namespace" "[" multi_dimensional_key "]"
[svn:parrot-pdd] r24226 - trunk/docs/pdds/draft
Author: kjs Date: Thu Dec 27 02:00:14 2007 New Revision: 24226 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] remove depr. that are gone now. Some other minor layout. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Thu Dec 27 02:00:14 2007 @@ -65,7 +65,7 @@ Opcode names are not reserved words in PIR, and may be used as variable names. For example, you can define a local variable named C. [See RT #24251] -NOTE: The use of C<::> in identifiers is deprecated. [See RT #48735] +{{ NOTE: The use of C<::> in identifiers is deprecated. [See RT #48735] }} =head3 Labels @@ -761,12 +761,14 @@ =item * C<.include> "" The C<.include> directive takes a string argument that contains the -name of the PIR file that is included. +name of the PIR file that is included. The contents of the included +file are inserted as if they were written at the point where the +C<.include> directive occurs. =item * C<.macro> [] The C<.macro> directive starts the definition of a macro named by the specified -identifier. The optional parameter list is a comma-separated list of identifiers, +identifier. The optional parameter list is a comma-separated list of identifiers, enclosed in parentheses. See C<.endm> for ending the macro definition. @@ -776,16 +778,13 @@ =item * C<.macro_const> (|) - .macro_const PI 3.14 + .macro_const PI 3.14 The C<.macro_const> directive is a special type of macro; it allows the user to use a symbolic name for a constant value. Like C<.macro>, the substitution -occurs at compile time. It takes two arguments (not comma separated), the first +occurs at compile time. It takes two arguments (not comma separated), the first is an identifier, the second a constant value or a register. -{{ NOTE: C<.constant> is deprecated, replaced by C<.macro_const>. -See RT #48561 }} - =back The macro layer is completely implemented in the lexical analysis phase. @@ -948,7 +947,7 @@ .end Each expansion is associated with a unique number; for labels declared with -C<.macro_label> and locals declared with C<.macro_local> expansions, this +C<.macro_label> and locals declared with C<.macro_local> expansions, this means that multiple expansions of a macro will not result in conflicting label or local names.
[svn:parrot-pdd] r30041 - trunk/docs/pdds
Author: kjs Date: Tue Aug 5 11:16:36 2008 New Revision: 30041 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] add an RT ticket referring to deprecated old-style pasm registers deprecation decision. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Tue Aug 5 11:16:36 2008 @@ -103,7 +103,7 @@ register, if it is the only register in the subroutine. {{DEPRECATION NOTE: PIR will no longer support the old PASM-style syntax -for registers without dollar signs: C, C, C, C.}} +for registers without dollar signs: C, C, C, C. RT#57638}} =head2 Constants
[svn:parrot-pdd] r30083 - trunk/docs/pdds
Author: kjs Date: Thu Aug 7 03:35:11 2008 New Revision: 30083 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] add description for binary relational operators in = section. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Thu Aug 7 03:35:11 2008 @@ -683,8 +683,7 @@ Binary bitwise operations C<&> (bitwise AND), C<|> (bitwise OR) and C<~> (bitwise XOR). -{{PROPOSAL: Change description to support logic operators (comparisons) as -implemented (and working) in imcc.y. ANR: proposal not clear.}} +Binary relational operations C, E=, ==, != E= E>. =item =
[svn:parrot-pdd] r30378 - trunk/docs/pdds
Author: kjs Date: Wed Aug 20 07:13:25 2008 New Revision: 30378 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] document :instanceof pragma. pmichaud++ for writing it Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Wed Aug 20 07:13:25 2008 @@ -510,6 +510,13 @@ subroutines in the file may have the same name (because they are multi, or in different namespaces). +=item :instanceof( ) + +The C<:instanceof> pragma is an experimental pragma that creates a sub as a +PMC type other than 'Sub'. However, as currently implemented it doesn't +work well with C<:outer> or existing PMC types such as C, +C, etc. + =back
[svn:parrot-pdd] r30384 - trunk/docs/pdds
Author: kjs Date: Wed Aug 20 09:51:31 2008 New Revision: 30384 Modified: trunk/docs/pdds/pdd26_ast.pod Log: [pdd26] add description for "register" scope + add missing ')' + mention :vtable subs have 'self' too (in attribute scope description). Modified: trunk/docs/pdds/pdd26_ast.pod == --- trunk/docs/pdds/pdd26_ast.pod (original) +++ trunk/docs/pdds/pdd26_ast.pod Wed Aug 20 09:51:31 2008 @@ -203,7 +203,21 @@ the attribute belongs. If this child is not present, the attribute is assumed to belong to the current invocant, indicated by the special variable C (which is implicitly passed to all subs -that are flagged as a C<:method>. +that are flagged as a C<:method> or C<:vtable>). + +=item "register" + +Register variables are limited in scope to the C node +in which they are declared. This is different from the C +scope, which I any nested C nodes. If the +node's C attribute is true, then this node defines a new +register variable within the current block. Register variables +are mapped to Parrot registers, and are useful for handling the +PIR pseudo-variable C and storing intermediate results. +Names given to the C attribute must conform to rules for +PIR identifiers. If no C atribute is set, Parrot registers +are used. In this case, setting the C does not have any +effect. =back
[svn:parrot-pdd] r30437 - trunk/docs/pdds
Author: kjs Date: Fri Aug 22 03:59:58 2008 New Revision: 30437 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] add a note about not-allowing space around the method-call dot. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Fri Aug 22 03:59:58 2008 @@ -805,6 +805,9 @@ Internally, the call stack doesn't increase because of a tail call, so you can write recursive functions and not have stack overflows. +Whitespace surrounding the dot ('.') that separates the object from the +method is not allowed. + =back =head2 Assignment and Morphing
[svn:parrot-pdd] r30568 - trunk/docs/pdds
Author: kjs Date: Tue Aug 26 04:24:18 2008 New Revision: 30568 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] add a comment that PIR keywords cannot be used as PIR identifiers (as opposed to opcode names, which are allowed). Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Tue Aug 26 04:24:18 2008 @@ -63,6 +63,10 @@ Opcode names are not reserved words in PIR, and may be used as variable names. For example, you can define a local variable named C. [See RT #24251] +PIR keywords, on the other hand, I reserved, and cannot be used as +identifiers. Some opcode names (C, C) are, in fact, PIR keywords, +which therefore cannot be used as identifiers. + {{ NOTE: The use of C<::> in identifiers is deprecated. [See RT #48735] }} =head3 Labels
[svn:parrot-pdd] r30569 - trunk/docs/pdds
Author: kjs Date: Tue Aug 26 04:27:55 2008 New Revision: 30569 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] be a bit more precise in opcode names vs local var names vs sub names. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Tue Aug 26 04:27:55 2008 @@ -62,8 +62,11 @@ Opcode names are not reserved words in PIR, and may be used as variable names. For example, you can define a local variable named C. [See RT #24251] +Note that by using an opcode name as a local variable name, the variable will +I the opcode name, effectively making the opcode unusable. Opcode names +used as subroutine identifiers, on the other hand, will I that opcode. -PIR keywords, on the other hand, I reserved, and cannot be used as +In contrast to opcode names, PIR keywords I reserved, and cannot be used as identifiers. Some opcode names (C, C) are, in fact, PIR keywords, which therefore cannot be used as identifiers.
[svn:parrot-pdd] r30632 - trunk/docs/pdds
Author: kjs Date: Fri Aug 29 02:22:05 2008 New Revision: 30632 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] list all PIR reserved words. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Fri Aug 29 02:22:05 2008 @@ -67,8 +67,14 @@ used as subroutine identifiers, on the other hand, will I that opcode. In contrast to opcode names, PIR keywords I reserved, and cannot be used as -identifiers. Some opcode names (C, C) are, in fact, PIR keywords, -which therefore cannot be used as identifiers. +identifiers. Some opcode names are, in fact, PIR keywords, which therefore +cannot be used as identifiers. + +The following are PIR keywords, and cannot be used as identifiers: + + goto if int null + num pmc string unless + {{ NOTE: The use of C<::> in identifiers is deprecated. [See RT #48735] }}
[svn:parrot-pdd] r30633 - trunk/docs/pdds
Author: kjs Date: Fri Aug 29 03:13:05 2008 New Revision: 30633 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] remove a previously added line of mine which I no longer understand myself. Something about subroutine identifiers and hiding opnames. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Fri Aug 29 03:13:05 2008 @@ -63,8 +63,7 @@ Opcode names are not reserved words in PIR, and may be used as variable names. For example, you can define a local variable named C. [See RT #24251] Note that by using an opcode name as a local variable name, the variable will -I the opcode name, effectively making the opcode unusable. Opcode names -used as subroutine identifiers, on the other hand, will I that opcode. +I the opcode name, effectively making the opcode unusable. In contrast to opcode names, PIR keywords I reserved, and cannot be used as identifiers. Some opcode names are, in fact, PIR keywords, which therefore
[svn:parrot-pdd] r32055 - trunk/docs/pdds
Author: kjs Date: Mon Oct 20 13:53:10 2008 New Revision: 32055 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [docs] update pdd19 w.r.t. RT#58236 (.arg->.set_arg, etc.) + update examples Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Mon Oct 20 13:53:10 2008 @@ -75,6 +75,10 @@ num pmc string unless +{{ NOTE: compilers/pirc does not have any reserved words; all keywords and ops + can be used as identifiers. +}} + {{ NOTE: The use of C<::> in identifiers is deprecated. [See RT #48735] }} =head3 Labels @@ -589,17 +593,39 @@ =item .return [:]* +{{ Deprecated; use .set_return instead. See RT#58236. }} + +=item .set_return [:]* + Between C<.begin_return> and C<.end_return>, specify one or more of the return value(s) of the current subroutine. Available flags: C<:flat>, C<:named>. +=item .yield [:]* + +{{ Deprecated; use .set_yield instead. See RT#58236. }} + +=item .set_yield [:]* + +Between C<.begin_yield> and C<.end_yield>, specify one or +more of the yield value(s) of the current subroutine. Available +flags: C<:flat>, C<:named>. + =item .arg [:]* +{{ Deprecated. Use .set_arg instead. See RT#58236. }} + +=item .set_arg [:]* + Between C<.begin_call> and C<.call>, specify an argument to be passed. Available flags: C<:flat>, C<:named>. =item .result [:]* +{{ Deprecated. Use .get_result instead. See RT#58236. }} + +=item .get_result [:]* + Between C<.call> and C<.end_call>, specify where one or more return value(s) should be stored. Available flags: C<:slurpy>, C<:named>, C<:optional>, and C<:opt_flag>. @@ -825,12 +851,29 @@ syntax from other uses of the C<.return> directive that will be probably deprecated. +{{ Since .return is deprecated in .begin_/end_return, do we still need and/or + want the parentheses? +}} + =item .return (args) +{{ Deprecated. Use .tailcall instead. See RT#58236. }} + =item .return .'somemethod'(args) +{{ Deprecated. Use .tailcall instead. See RT#58236. }} + =item .return .(args) +{{ Deprecated. Use .tailcall instead. See RT#58236. }} + +=item .tailcall (args) + +=item .tailcall .'somemethod'(args) + +=item .tailcall .(args) + + Tail call: call a function or method and return from the sub with the function or method call return values. @@ -881,7 +924,7 @@ runtime/parrot/include, in that order. The first file of that name to be found is included. -{{ NOTE: the C directive's search order is subject to change. }} +{{ NOTE: the C<.include> directive's search order is subject to change. }} =item * C<.macro> [] @@ -1143,7 +1186,7 @@ .param int c ... .begin_return - .return xy + .set_return xy .end_return ... .end @@ -1158,13 +1201,13 @@ .local num y .local str z .begin_call - .arg x - .arg y - .arg z + .set_arg x + .set_arg y + .set_arg z .call $P0, $P1# r = _sub_label(x, y, z) ret_addr: .local int r # optional - new result var - .result r + .get_result r .end_call =head2 NCI Call @@ -1173,12 +1216,12 @@ dlfunc $P1, $P0, "funcname", "signature" ... .begin_call - .arg x - .arg y - .arg z + .set_arg x + .set_arg y + .set_arg z .nci_call $P1 # r = funcname(x, y, z) .local int r # optional - new result var - .result r + .get_result r .end_call =head2 Subroutine Call Syntactic Sugar @@ -1208,7 +1251,7 @@ self."_other_meth"() ... .begin_return - .return xy + .set_return xy .end_return ... .end @@ -1226,13 +1269,13 @@ newclass class, "Foo" new obj, class .begin_call - .arg x - .arg y - .arg z + .set_arg x + .set_arg y + .set_arg z .invocant obj .meth_call "_method" [, $P1 ] # r = obj."_method"(x, y, z) .local int r # optional - new result var - .result r + .get_result r .end_call The return continuation is optional. The method can be a string @@ -1244,9 +1287,9 @@ .return ()# return no value - .return func_call() # tail call function + .tailcall func_call() # tail call function - .return o."meth"()# tail method call + .tailcall o."meth"()# tail method call Similarly, one can yield using the .yield directive @@ -1259,13 +1302,13 @@ Arguments are Bd in reverse order onto the user stack: - .arg y # save args in reversed order - .arg x + .set_arg y # save args in reversed order + .set_arg x call _foo#(r, s) = _foo(x,y) .local int r .local int s - .result r# restore results in order - .result s# + .get_result r# restore results in order + .get_result s# and return values are Bd in argument order from there.
[svn:parrot-pdd] r32677 - trunk/docs/pdds
Author: kjs Date: Sat Nov 15 14:51:49 2008 New Revision: 32677 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] fix a pod error. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Sat Nov 15 14:51:49 2008 @@ -239,12 +239,12 @@ =over 4 -=item* When a subroutine has a small fixed number of registers +=item * When a subroutine has a small fixed number of registers -=item* When a named variable or named register is used throughout the entire +=item * When a named variable or named register is used throughout the entire subroutine -=item* When a reference needs to be made to a register +=item * When a reference needs to be made to a register =back
[svn:parrot-pdd] r32679 - trunk/docs/pdds
Author: kjs Date: Sat Nov 15 15:17:37 2008 New Revision: 32679 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] update .arg and .result into new forms (.set_arg, etc.) Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Sat Nov 15 15:17:37 2008 @@ -799,10 +799,10 @@ This is short for: .begin_call - .arg + .set_arg ... .call - .result + .get_result ... .end_call
[svn:parrot-pdd] r32719 - trunk/docs/pdds
Author: kjs Date: Sun Nov 16 10:04:44 2008 New Revision: 32719 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] add description of the new :nsentry subroutine flag. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Sun Nov 16 10:04:44 2008 @@ -528,6 +528,13 @@ work well with C<:outer> or existing PMC types such as C, C, etc. +=item :nsentry( ) + +Specify the name by which the subroutine is stored in the namespace. The default +name by which a subroutine is stored in the namespace (if this flag is missing), +is the subroutine's name as given after the C<.sub> directive. This flag allows +to override this. + =back
[svn:parrot-pdd] r32726 - trunk/docs/pdds
Author: kjs Date: Sun Nov 16 11:05:31 2008 New Revision: 32726 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] :lexid will be changed into :subid. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Sun Nov 16 11:05:31 2008 @@ -516,6 +516,10 @@ =item :lexid( ) +Deprecated; see RT#60592. C<:lexid> will be renamed to C<:subid>. + +=item :subid( ) + Specifies a unique string identifier for the subroutine. This is useful for referring to a particular subroutine with C<:outer>, even though several subroutines in the file may have the same name (because they are multi, or in
[svn:parrot-pdd] r33348 - trunk/docs/pdds
Author: kjs Date: Sat Nov 29 10:21:48 2008 New Revision: 33348 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] clean up deprecations. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Sat Nov 29 10:21:48 2008 @@ -105,8 +105,7 @@ .local pmc foo The type of a named variable can be C, C, C or C, -corresponding to the types of registers. No other types are used. [See -RT#42769] +corresponding to the types of registers. No other types are used. The second way of referencing a register is through a register variable C<$In>, C<$Sn>, C<$Nn>, or C<$Pn>. The capital letter indicates the type @@ -116,9 +115,6 @@ register in the register set, C<$P42> may be stored in the zeroth PMC register, if it is the only register in the subroutine. -{{DEPRECATION NOTE: PIR will no longer support the old PASM-style syntax -for registers without dollar signs: C, C, C, C. RT#57638}} - =head2 Constants Constants may be used in place of registers or variables. A constant is not @@ -597,7 +593,7 @@ Directive to specify the object for a method call. Use it in combination with C<.meth_call>. -=item .meth_call +=item .meth_call Directive to do a method call. It calls the specified method on the object that was specified with the C<.invocant> directive. @@ -609,39 +605,23 @@ the library, function name and function signature as arguments. See L for details. -=item .return [:]* - -{{ Deprecated; use .set_return instead. See RT#58236. }} - =item .set_return [:]* Between C<.begin_return> and C<.end_return>, specify one or more of the return value(s) of the current subroutine. Available flags: C<:flat>, C<:named>. -=item .yield [:]* - -{{ Deprecated; use .set_yield instead. See RT#58236. }} - =item .set_yield [:]* Between C<.begin_yield> and C<.end_yield>, specify one or more of the yield value(s) of the current subroutine. Available flags: C<:flat>, C<:named>. -=item .arg [:]* - -{{ Deprecated. Use .set_arg instead. See RT#58236. }} - =item .set_arg [:]* Between C<.begin_call> and C<.call>, specify an argument to be passed. Available flags: C<:flat>, C<:named>. -=item .result [:]* - -{{ Deprecated. Use .get_result instead. See RT#58236. }} - =item .get_result [:]* Between C<.call> and C<.end_call>, specify where one or more return @@ -860,15 +840,6 @@ Return from the current subroutine with zero or more values. -The parentheses surrounding the arguments are mandatory. Besides making -sequence break more conspicuous, this is necessary to distinguish this -syntax from other uses of the C<.return> directive that will be probably -deprecated. - -{{ Since .return is deprecated in .begin_/end_return, do we still need and/or - want the parentheses? -}} - =item .tailcall (args) =item .tailcall .'somemethod'(args)
[svn:parrot-pdd] r33362 - trunk/docs/pdds
Author: kjs Date: Sun Nov 30 06:18:44 2008 New Revision: 33362 Modified: trunk/docs/pdds/pdd19_pir.pod trunk/docs/pdds/pdd23_exceptions.pod Log: [pdd] remove the part about resuming an exception from pdd19: it's not a part of the PIR language. Also, it was also written in better detail in pdd23. Add a section 'Exception Object Interface' to pdd23, of which resuming is one subsection. Retrieving the message is another section. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Sun Nov 30 06:18:44 2008 @@ -680,6 +680,9 @@ continuation() ... +See L for accessing the various attributes +of the exception object. + =head2 Syntactic Sugar Any PASM opcode is a valid PIR instruction. In addition, PIR defines some Modified: trunk/docs/pdds/pdd23_exceptions.pod == --- trunk/docs/pdds/pdd23_exceptions.pod(original) +++ trunk/docs/pdds/pdd23_exceptions.podSun Nov 30 06:18:44 2008 @@ -226,11 +226,21 @@ Base class of all standard exceptions. Provides no special functionality. Exists for the purpose of C testing. +=item B + +Exception type that is thrown by the C opcode. See the description of +the C opcode in this document. + =item B A system error as reported in the C variable C. Payload is an integer. Message is the return value of the standard C function C. +=item B + +Exception type that is thrown by the C opcode. See the description of +the C opcode in this document. + =item B Generic base class for math errors. @@ -356,7 +366,22 @@ it still keeps the error information out-of-band, instead of mixing the error in with normal return values. }} -=head2 Resuming after Exceptions +=head2 Exception Object Interface + +=head2 Retrieving the Exception Message + +The exception message is stored in the 'message' attribute: + + ... + handler: + .local pmc exception + .local string message + .get_results (exception) + message = exception['message'] + say message + + +=head3 Resuming after Exceptions Exceptions thrown by standard Parrot opcodes (like the one thrown by C above or by the C opcode) are always resumable,
[svn:parrot-pdd] r33363 - trunk/docs/pdds
Author: kjs Date: Sun Nov 30 06:20:05 2008 New Revision: 33363 Modified: trunk/docs/pdds/pdd23_exceptions.pod Log: [pdd23] woops. A head2 should have been a head3. Modified: trunk/docs/pdds/pdd23_exceptions.pod == --- trunk/docs/pdds/pdd23_exceptions.pod(original) +++ trunk/docs/pdds/pdd23_exceptions.podSun Nov 30 06:20:05 2008 @@ -368,7 +368,7 @@ =head2 Exception Object Interface -=head2 Retrieving the Exception Message +=head3 Retrieving the Exception Message The exception message is stored in the 'message' attribute:
[Parrot] New comment on Memory Management in PIRC.
kjs has left a new comment on your post "Memory Management in PIRC": Justin, thanks for sharing your thoughts. I'm not sure what "APR" way of things is.. Creating memory pools and reclaiming the pool after each step: all allocated memory is needed till the end of the compilation, so there's no different phases or stages regarding memory requirements. Otherwise, yes, that'd be a nice approach. Your second option, allocating a sizeof (void*) in each allocation to build a single linked list: if I understand correctly, that does mean there's a node for each allocation, which is sizeof (void *) + sizeof (pointer to node), which means there's a 100% overhead on the "next" pointers. In the implemented solution, there's only one "next" pointer needed for each 512 allocations (and that number could be changed). Posted by kjs to Parrot at November 30, 2008 5:31 AM
[svn:parrot-pdd] r33372 - trunk/docs/pdds
Author: kjs Date: Sun Nov 30 08:08:13 2008 New Revision: 33372 Modified: trunk/docs/pdds/pdd26_ast.pod Log: [pdd26] add pasttype descriptions for 'chain' and 'return'. resolving RT#48705. Modified: trunk/docs/pdds/pdd26_ast.pod == --- trunk/docs/pdds/pdd26_ast.pod (original) +++ trunk/docs/pdds/pdd26_ast.pod Sun Nov 30 08:08:13 2008 @@ -287,6 +287,15 @@ =over 4 +=item chain + +A short-circuiting chain of operations. In a sequence of nodes +with pasttype 'chain', the right operand of a node serves as +the left operand of its parent. Each node is evaluated only +once, and the first false result short-circuits the chain. +In other words, C<< $x < $y < $z >> is true only if +$x < $y and $y < $z, but $y only gets evaluated once. + =item copy Copy the value of the node's second child into the variable @@ -390,6 +399,11 @@ node's C attribute (a string). See the C method below for details. +=item return + +Generate a return exception, using the first child (if any) as +a return value. + =item try Evaluates the first child, if any exceptions occur then they
[Parrot] New comment on Episode 3: Squaak Details and First Steps.
kjs has left a new comment on your post "Episode 3: Squaak Details and First Steps": refers to the rule (or token) expression. If you declare a rule "foo", and you want to use it, you need to put the pointy brackets around it, like . Posted by kjs to Parrot at December 6, 2008 7:14 AM
[Parrot] New comment on Episode 3: Squaak Details and First Steps.
kjs has left a new comment on your post "Episode 3: Squaak Details and First Steps": srottak: You should check the action method definitions in the action.pm file. Please note that each {*} indicates an invocation to an action method that has the same name as the rule in which the {*} occurs. Please check the parameter lists of these methods; apparently, there's a parameter/argument mismatch. Posted by kjs to Parrot at December 8, 2008 2:42 AM
[svn:parrot-pdd] r33726 - trunk/docs/pdds
Author: kjs Date: Tue Dec 9 13:18:23 2008 New Revision: 33726 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] some updates and clarifying texts. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Tue Dec 9 13:18:23 2008 @@ -62,23 +62,21 @@ Opcode names are not reserved words in PIR, and may be used as variable names. For example, you can define a local variable named C. [See RT #24251] -Note that by using an opcode name as a local variable name, the variable will -I the opcode name, effectively making the opcode unusable. - -In contrast to opcode names, PIR keywords I reserved, and cannot be used -as identifiers. Some opcode names are, in fact, PIR keywords, which therefore -cannot be used as identifiers. +Note that currently, by using an opcode name as a local variable name, the +variable will I the opcode name, effectively making the opcode unusable. +In the future this will be resolved. + +The PIR language is designed to have as few reserved keywords as possible. +Currently, in contrast to opcode names, PIR keywords I reserved, and cannot +be used as identifiers. Some opcode names are, in fact, PIR keywords, which +therefore cannot be used as identifiers. This, too, will be resolved in a +future re-implementation of the PIR compiler. The following are PIR keywords, and cannot be used as identifiers: goto if int null num pmc string unless - -{{ NOTE: compilers/pirc does not have any reserved words; all keywords and ops - can be used as identifiers. -}} - =head3 Labels A label declaration consists of a label name followed by a colon. A label name @@ -162,7 +160,9 @@ ... EOS -You may have multiple heredocs within a single statement or directive: +Although currently not possible, a future implementation of the PIR +language will allow you to use multiple heredocs within a single +statement or directive: function(<<'INPUT', <<'OUTPUT', 'some test') ... @@ -265,9 +265,10 @@ =item .const = Define a constant named I of type I and assign value -I to it. The I may be either an integer value or a string -constant. The constant is stored in the constant table of the current -bytecode file. +I to it. The I must be C, C, C or a string +constant indicating the PMC type. This allows you to create PMC constants +representing Subroutines. +The constant is stored in the constant table of the current bytecode file. =item .globalconst = @@ -323,7 +324,7 @@ Define the HLL for the current file. Takes one string constant, the name of the HLL. -=item .HLL_map = [unimplemented: RT #57430] +=item .HLL_map = Whenever Parrot has to create PMCs inside C code on behalf of the running user program, it consults the current type mapping for the executing HLL
[svn:parrot-pdd] r33798 - trunk/docs/pdds
Author: kjs Date: Thu Dec 11 05:39:13 2008 New Revision: 33798 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] removed deprecated and removed stuff. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Thu Dec 11 05:39:13 2008 @@ -359,9 +359,6 @@ the PIR code is generated from some source PIR files, and error messages should print the source file's name, not the name of the generated file. -{{ DEPRECATION NOTE: was C<<#line >>. See [RT#45857], -[RT#43269], and [RT#47141]. }} - =item .annotate Makes an entry in the bytecode annotations table. This is used to store high @@ -390,33 +387,6 @@ Then you're asking for a bigger bytecode file as a result. -=item .namespace [deprecated: See RT #48737] - -{{ DEPRECATION NOTE: this variation of C<.namespace> and -C<.endnamespace> are deprecated. They were a hackish attempt at -implementing scopes in Parrot, but didn't actually turn out to be -useful.}} - -Open a new scope block. This "namespace" is not the same as the -.namespace [ ] syntax, which is used for storing subroutines -in a particular namespace in the global symbol table. -This directive is useful in cases such as (pseudocode): - - local x = 1; - print(x); # prints 1 - do # open a new namespace/scope block -local x = 2; # this x hides the previous x -print(x); # prints 2 - end # close the current namespace - print(x); # prints 1 again - -All types of common language constructs such as if, for, while, repeat and -such that have nested scopes, can use this directive. - -=item .endnamespace [deprecated: RT #48737] - -Closes the scope block that was opened with .namespace . - =back =head3 Subroutine flags @@ -480,7 +450,7 @@ This code is run at compile time, and the returned C is stored in the bytecode file in place of the sub. Other subs may then do: -.const .Sub tr_00 = 'tr_00_init' +.const 'Sub' tr_00 = 'tr_00_init' in order to fetch the constant. @@ -812,10 +782,6 @@ Note that this only works for opcodes that have have a leading C parameter. [this restriction unimplemented: RT #36283] -=item global "string" = [deprecated: RT #48016] - -=item = global "string" [deprecated: RT #48018] - =item ([ [: ...], ...]) = ([ [: ...], ...]) This is short for:
[svn:parrot-pdd] r33799 - trunk/docs/pdds
Author: kjs Date: Thu Dec 11 05:43:56 2008 New Revision: 33799 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] add bits on implementation Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Thu Dec 11 05:43:56 2008 @@ -965,7 +965,7 @@ EOS -{{ NOTE: This is likely because the parsing of heredocs happens later than the +{{ NOTE: This is because the parsing of heredocs happens later than the preprocessing of macros. Might be nice if we could parse heredocs at the macro level, but not a high priority. compilers/pirc/new can do this. }} @@ -1136,7 +1136,7 @@ =head2 Subroutine Call - .const .Sub $P0 = "_sub_label" + .const "Sub" $P0 = "_sub_label" $P1 = new 'Continuation' set_addr $P1, ret_addr ... @@ -1178,7 +1178,7 @@ a NCI sub, and on invocation will do the Right Thing. Instead of the label a subroutine object can be used too: - find_global $P0, "_sub_label" + get_global $P0, "_sub_label" $P0(args) @@ -1278,7 +1278,28 @@ =head1 IMPLEMENTATION There are multiple implementations of PIR, each of which will meet this -specification for the syntax. +specification for the syntax. Currently there are the following +implementations: + +=over 4 + +=item * compilers/imcc + +This is the current implementation being used in Parrot. + +=item * compilers/pirc + +This is a new implementation which will fix several of +IMCC's shortcomings. It will replace IMCC in the not too +distant future. + +=item * languages/PIR + +This is a PGE-based implementation, but needs to be updated +and completed. + +=back + =head1 ATTACHMENTS
[svn:parrot-pdd] r33979 - trunk/docs/pdds
Author: kjs Date: Tue Dec 16 12:09:02 2008 New Revision: 33979 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] change some {{ }} notes in more formal notes, indicating the current behaviour, and what it will be like. More cleanups of pdd19 will come after more deprecated stuff is removed from the implementation (IMCC). + remove example with stack calling conventions. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Tue Dec 16 12:09:02 2008 @@ -434,7 +434,9 @@ constants at compile time, provided that (a) the generated constant can be computed at compile time (i.e. doesn't depend on the runtime environment), and (b) the constant value is of a PMC class that supports saving in a bytecode -file [need a freeze/thaw reference]. +file. + +{{ TODO: need a freeze/thaw reference }}. For example, C contains the following (slightly abbreviated) definition: @@ -735,13 +737,15 @@ A keyed C operation for PMCs or a substring operation for string arguments and an integer key. -{{ DEPRECATION NOTE: Possibly deprecate the substring variant. }} +{{ DEPRECATION NOTE: The substring operation for string arguments is + deprecated, and will be removed after the 0.8.2 release. }} =item = [ ] {{ NOTE: keyed assignment is still valid in PIR, but the C<..> notation in keys is deprecated [See RT #48561], so this syntactic sugar for slices is also -deprecated. See the (currently experimental) C opcode instead. }} +deprecated. See the (currently experimental) C opcode instead, but +this, too, is deprecated. }} where C is: @@ -944,16 +948,17 @@ can also be expanded by writing either C<.foo> or C<.foo()>. -{{ NOTE: this is a change from the current implementation, which requires the -definition and call of a zero-parameter macro to match in the use of -parentheses. }} +B =over =item * Heredoc arguments -Heredoc arguments are not allowed when expanding a macro. This means that -the following is not allowed: +Heredoc arguments are not allowed when expanding a macro. The next +implementation of PIR ("PIRC") will be able to handle this correctly. +This means that, currently, when using IMCC, the following is not allowed: .macro foo(bar) ... @@ -965,9 +970,6 @@ EOS -{{ NOTE: This is because the parsing of heredocs happens later than the -preprocessing of macros. Might be nice if we could parse heredocs at the macro -level, but not a high priority. compilers/pirc/new can do this. }} Using braces, { }, allows you to span multiple lines for an argument. See runtime/parrot/include/hllmacros.pir for examples and possible usage. @@ -1016,6 +1018,8 @@ =head3 Unique local variables +B. + Within the macro body, the user can declare a local variable with a unique name. @@ -1123,62 +1127,73 @@ =head2 Subroutine Definition - .sub _sub_label []* - .param int a - .param int b - .param int c - ... - .begin_return - .set_return xy - .end_return - ... - .end +A simple subroutine, marked with C<:main>, indicating it's the entry point +in the file. Other sub flags include C<:load>, C<:init>, etc. + +.sub sub_label :main + .param int a + .param int b + .param int c + + .begin_return +.set_return xy + .end_return + +.end =head2 Subroutine Call - .const "Sub" $P0 = "_sub_label" - $P1 = new 'Continuation' - set_addr $P1, ret_addr - ... - .local int x - .local num y - .local str z - .begin_call - .set_arg x - .set_arg y - .set_arg z - .call $P0, $P1# r = _sub_label(x, y, z) +Invocation of a subroutine. In this case a continuation subroutine is +created. + +.const "Sub" $P0 = "sub_label" +$P1 = new 'Continuation' +set_addr $P1, ret_addr +# ... +.local int x +.local num y +.local string z +.begin_call + .set_arg x + .set_arg y + .set_arg z + .call $P0, $P1# r = _sub_label(x, y, z) ret_addr: - .local int r # optional - new result var - .get_result r - .end_call + .local int r # optional - new result var + .get_result r +.end_call =head2 NCI Call - load_lib $P0, "libname" - dlfunc $P1, $P0, "funcname", "signature" - ... - .begin_call - .set_arg x - .set_arg y - .set_arg z - .nci_call $P1 # r = funcname(x, y, z) - .local int r # optional - new result var - .get_result r - .end_call +load_lib $P0, "libname" +dlfunc $P1, $P0, "funcname", "signature" +# ... +.begin_call + .set_arg x + .set_arg y + .set_arg z + .nci_call $P1 # r = funcname(x, y, z) + .local int r # optional - new result var + .get_result r +.end_call =head2 Subro
[svn:parrot-pdd] r34044 - in trunk: . compilers/imcc docs/pdds
Author: kjs Date: Wed Dec 17 12:54:21 2008 New Revision: 34044 Modified: trunk/docs/pdds/pdd19_pir.pod Changes in other areas also in this revision: Modified: trunk/DEPRECATED.pod trunk/compilers/imcc/imcc.y trunk/compilers/imcc/imcparser.c Log: [imcc] remove commented-out code for string indexing. + update DEPRECATED with recently removed stuff. + update pdd19 with recently removed stuff. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Wed Dec 17 12:54:21 2008 @@ -734,42 +734,16 @@ =item = [ ] -A keyed C operation for PMCs or a substring operation for string -arguments and an integer key. +A keyed C operation for PMCs to retrieve a value from an aggregate. +This maps to: -{{ DEPRECATION NOTE: The substring operation for string arguments is - deprecated, and will be removed after the 0.8.2 release. }} - -=item = [ ] - -{{ NOTE: keyed assignment is still valid in PIR, but the C<..> notation in -keys is deprecated [See RT #48561], so this syntactic sugar for slices is also -deprecated. See the (currently experimental) C opcode instead, but -this, too, is deprecated. }} - -where C is: - - .. - -returns a slice defined starting at C and ending at C. - - .. - -returns a slice starting at the first element, and ending at C. - - .. - -returns a slice starting at C to the end of the array. - -see src/pmc/slice.pmc -and t/pmc/slice.t. + set , [ ] =item [ ] = -A keyed C operation. +A keyed C operation to set a value in an aggregate. This maps to: -{{ DEPRECATION NOTE: this syntactic sugar will no longer be used for the -assign C op with a length of 1. }} + set [ ], =item =
[svn:parrot-pdd] r35488 - trunk/docs/pdds
Author: kjs Date: Tue Jan 13 06:52:29 2009 New Revision: 35488 Modified: trunk/docs/pdds/pdd19_pir.pod Log: [pdd19] Be more explicit; if you don't specify a :main flag, execution starts at the top. Modified: trunk/docs/pdds/pdd19_pir.pod == --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Tue Jan 13 06:52:29 2009 @@ -398,7 +398,8 @@ Define "main" entry point to start execution. If multiple subroutines are marked as B<:main>, the B marked subroutine is used. Only the first file loaded or compiled counts; subs marked as B<:main> are ignored by the -B op. +B op. If no B<:main> flag is specified at all, execution +starts at the first subroutine in the file. =item :load
[svn:parrot-pdd] r24299 - trunk/docs/pdds
Author: kjs Date: Sun Dec 30 05:35:58 2007 New Revision: 24299 Modified: trunk/docs/pdds/pdd27_multiple_dispatch.pod Log: [pdd27] add note about :invocant parameters must be contiguous. No explanation yet. Modified: trunk/docs/pdds/pdd27_multiple_dispatch.pod == --- trunk/docs/pdds/pdd27_multiple_dispatch.pod (original) +++ trunk/docs/pdds/pdd27_multiple_dispatch.pod Sun Dec 30 05:35:58 2007 @@ -20,7 +20,7 @@ particular call at runtime, based on the types of the arguments passed into the call. The selection process compares the arguments of the call and the types declared in the signatures of the alternates, as well as their inherited -or composed parents, to find the best match. +or composed parents, to find the best match. A similar selection of alternates based on types at compile time is generally called overloading. @@ -122,8 +122,9 @@ Not all elements of a multi-sub's signature are relevant for the purposes of multiple dispatch. The subroutine parameters that participate in dispatch are -marked with the attribute C<:invocant>. Subs that are not marked with -C<:multi> may not mark parameters with C<:invocant>. +marked with the attribute C<:invocant>, and must be contiguous. +Subs that are not marked with C<:multi> may not mark parameters with +C<:invocant>. {{NOTE: I'm open to other names for the attribute. An English form of the Latin I, "to call upon", is pretty appropriate to the act of using
[svn:parrot-pdd] r24301 - trunk/docs/pdds/draft
Author: kjs Date: Sun Dec 30 05:44:09 2007 New Revision: 24301 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] add reference to pdd27 for the :multi flag. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Sun Dec 30 05:44:09 2007 @@ -390,6 +390,8 @@ =item :multi(Type1, Type2...) Engage in multiple dispatch with the listed types. +See L for more information on the +multiple dispatch system. =item :immediate
[svn:parrot-pdd] r24300 - trunk/docs/pdds/draft
Author: kjs Date: Sun Dec 30 05:41:24 2007 New Revision: 24300 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] remove .emit and .eom from pdd19; the tokens are no longer allowed by imcc. the parser-generated symbol EMIT is still there, as it is used to force the parser in PASM mode (for .pasm files). Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Sun Dec 30 05:41:24 2007 @@ -345,20 +345,6 @@ End a compilation unit. Always paired with C<.sub>. -=item .emit - -Define a compilation unit containing PASM code (only opcodes and a limited -subset of directives). Always paired with C<.eom>. - -{{ DEPRECATED. See RT#47846 }} - -=item .eom - -End a compilation unit containing PASM code. Always paired with -C<.emit>. - -{{ DEPRECATED. See RT#47846 }} - =item #line Set the line number and filename to the value specified. This is useful in
[svn:parrot-pdd] r25478 - trunk/docs/pdds
Author: kjs Date: Sun Feb 3 10:49:02 2008 New Revision: 25478 Modified: trunk/docs/pdds/pdd26_ast.pod Log: [pdd26] add description of :scope('attribute') Modified: trunk/docs/pdds/pdd26_ast.pod == --- trunk/docs/pdds/pdd26_ast.pod (original) +++ trunk/docs/pdds/pdd26_ast.pod Sun Feb 3 10:49:02 2008 @@ -194,6 +194,18 @@ to specify how to generate the aggregate if it doesn't already exist. +=item "attribute" + +Attribute variables represent object attributes (in some languages +they're called "member variables"). The attribute's name is given +by the node's C attribute. Nodes representing attribute +variables have an optional child, representing the object to which +the attribute belongs. If this child is not present, the attribute +is assumed to belong to the current invocant, indicated by the +special variable C (which is implicitly passed to all subs +that are flagged as a C<:method>. + + =back If C is not explicitly provided in the node, then PAST will @@ -309,7 +321,7 @@ semantics; simply set the first child to the left operand and the second child to the right operand, leaving the third child empty or uninitialized. If the first child evaluates to -true it is returned as the result of the operation, otherwise the +true it is returned as the result of the operation, otherwise the second child is evaluated and returned as the result. =item while
[svn:parrot-pdd] r25755 - trunk/docs/pdds/draft
Author: kjs Date: Sat Feb 16 03:03:19 2008 New Revision: 25755 Modified: trunk/docs/pdds/draft/pdd06_pasm.pod Log: [pdd06] add note about a pasm grammar in bison. This might be handy when this pdd is being reviewed and updated. Modified: trunk/docs/pdds/draft/pdd06_pasm.pod == --- trunk/docs/pdds/draft/pdd06_pasm.pod(original) +++ trunk/docs/pdds/draft/pdd06_pasm.podSat Feb 16 03:03:19 2008 @@ -115,6 +115,8 @@ Below is an overview of the grammar of a PASM file. +{{ See compilers/pirc/new for a bison-basd implementation of PASM }} + pasm_file: [ pasm_line '\n' ]*
[svn:parrot-pdd] r25898 - trunk/docs/pdds/draft
Author: kjs Date: Wed Feb 20 02:54:41 2008 New Revision: 25898 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] o move the part about = and morphing, so it's before the macro section. o fix a few pod issues (no errors, but forgotten markup) o add a note about NCI and short-invocation syntax o add a note about braced arguments; taken from docs/imcc/macros.pir o add a note about compilers/pirc/new being able to handle heredoc arguments in macro expansions. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Feb 20 02:54:41 2008 @@ -734,6 +734,35 @@ =back +=head2 Assignment and Morphing + +The C<=> syntactic sugar in PIR, when used in the simple case of: + + = + +directly corresponds to the C opcode. So, two low-level arguments (int, +num, or string registers, variables, or constants) are a direct C assignment, +or a C-level conversion (int cast, float cast, a string copy, or a call to one +of the conversion functions like C). + +A PMC source with a low-level destination, calls the C, +C, or C vtable function on the PMC. A low-level source +with a PMC destination calls the C, C, +or C vtable function on the PMC (assign to value semantics). +Two PMC arguments are a direct C assignment (assign to container semantics). + +For assign to value semantics for two PMC arguments use C, which calls +the C vtable function. + + +{{ NOTE: response to the question: + + I don't think that 'morph' as a method call is a good idea + we need something that says "assign to value" versus "assign to container" + we can't eliminate the existing 'morph' opcode until we have a replacement + +}} + =head2 Macros @@ -756,7 +785,7 @@ enclosed in parentheses. See C<.endm> for ending the macro definition. -=item * <.endm> +=item * C<.endm> Closes a macro definition. @@ -847,7 +876,41 @@ {{ NOTE: This is likely because the parsing of heredocs happens later than the preprocessing of macros. Might be nice if we could parse heredocs at the macro -level, but not a high priority. }} +level, but not a high priority. compilers/pirc/new can do this, but there's a +bug in the heredoc handling on Win32 XP using MSVS. }} + +Using braces, { }, allows you to span multiple lines for an argument. +See runtime/parrot/include/hllmacros.pir for examples and possible usage. +A simple example is this: + + .macro foo(a,b) + .a + .b + .endm + + .sub main + .foo({ print "1" + print "2" +}, { + print "3" + print "4" +}) + .end + +This will expand the macro C, after which the input to the PIR parser is: + + .sub main + print "1" + print "2" + print "3" + print "4" + .end + +which will result in the output: + + 1234 + +{{ NOTE: braced arguments does not work correctly yet in compilers/pirc/new }} =back @@ -968,35 +1031,6 @@ If you intend the macro to create unique variables names, use C<.macro_local> instead of C<.local> to take advantage of the name munging. -=head2 Assignment and Morphing - -The C<=> syntactic sugar in PIR, when used in the simple case of: - - = - -directly corresponds to the C opcode. So, two low-level arguments (int, -num, or string registers, variables, or constants) are a direct C assignment, -or a C-level conversion (int cast, float cast, a string copy, or a call to one -of the conversion functions like C). - -A PMC source with a low-level destination, calls the C, -C, or C vtable function on the PMC. A low-level source -with a PMC destination calls the C, C, -or C vtable function on the PMC (assign to value semantics). -Two PMC arguments are a direct C assignment (assign to container semantics). - -For assign to value semantics for two PMC arguments use C, which calls -the C vtable function. - - -{{ NOTE: response to the question: - - I don't think that 'morph' as a method call is a good idea - we need something that says "assign to value" versus "assign to container" - we can't eliminate the existing 'morph' opcode until we have a replacement - -}} - =head1 EXAMPLES =head2 Subroutine Definition @@ -1052,6 +1086,8 @@ (r1[, r2 ...]) = _sub_label(x, y, z) _sub_label(x, y, z) +This also works for NCI calls, as the subroutine PMC will be +a NCI sub, and on invocation will do the Right Thing. Instead of the label a subroutine object can be used too: find_global $P0, "_sub_label"
[svn:parrot-pdd] r25899 - trunk/docs/pdds/draft
Author: kjs Date: Wed Feb 20 03:10:40 2008 New Revision: 25899 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] add a note about search order of the include directive. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Feb 20 03:10:40 2008 @@ -778,6 +778,12 @@ file are inserted as if they were written at the point where the C<.include> directive occurs. +The include file is searched for in the current directory and in +runtime/parrot/include, in that order. The first file of that name to +be found is included. + +{{ Check the search order of the include directive and whether it's complete }} + =item * C<.macro> [] The C<.macro> directive starts the definition of a macro named by the specified
[svn:parrot-pdd] r26696 - trunk/docs/pdds/draft
Author: kjs Date: Tue Apr 1 13:27:08 2008 New Revision: 26696 Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod Log: [pdd29] fix copyright year; add a reference and add an abstract line. Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod == --- trunk/docs/pdds/draft/pdd29_compiler_tools.pod (original) +++ trunk/docs/pdds/draft/pdd29_compiler_tools.pod Tue Apr 1 13:27:08 2008 @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2008, The Perl Foundation. +# Copyright (C) 2008, The Perl Foundation. # $Id$ =head1 NAME @@ -16,6 +16,7 @@ =head1 ABSTRACT +This PDD specifies the Parrot Compiler Tools (PCT). =head1 SYNOPSIS @@ -31,6 +32,9 @@ =head1 REFERENCES +docs/pdd26_ast.pod + + =cut __END__
[svn:parrot-pdd] r26695 - in trunk: . docs/pdds/draft
Author: kjs Date: Tue Apr 1 13:12:40 2008 New Revision: 26695 Added: trunk/docs/pdds/draft/pdd29_compiler_tools.pod (contents, props changed) Changes in other areas also in this revision: Modified: trunk/MANIFEST Log: [pdd29] check in initial pdd stub for compiler tools. update manifest. keywords are set. Added: trunk/docs/pdds/draft/pdd29_compiler_tools.pod == --- (empty file) +++ trunk/docs/pdds/draft/pdd29_compiler_tools.pod Tue Apr 1 13:12:40 2008 @@ -0,0 +1,39 @@ +# Copyright (C) 2001-2008, The Perl Foundation. +# $Id$ + +=head1 NAME + +docs/pdds/draft/pdd29_compiler_tools.pod - Parrot Compiler Tools + +=head1 VERSION + +$Revision$ + +=head1 MAINTAINER + +Will "Coke" Coleda +Klaas-Jan Stol + +=head1 ABSTRACT + + +=head1 SYNOPSIS + + +=head1 DESCRIPTION + + +=head1 IMPLEMENTATION + + +=head1 ATTACHMENTS + + +=head1 REFERENCES + +=cut + +__END__ +Local Variables: + fill-column:78 +End:
[svn:parrot-pdd] r26703 - trunk/docs/pdds/draft
Author: kjs Date: Wed Apr 2 05:40:30 2008 New Revision: 26703 Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod Log: [pdd29] give pdd29 a first swing Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod == --- trunk/docs/pdds/draft/pdd29_compiler_tools.pod (original) +++ trunk/docs/pdds/draft/pdd29_compiler_tools.pod Wed Apr 2 05:40:30 2008 @@ -20,20 +20,190 @@ =head1 SYNOPSIS +Creating a PCT-based compiler can be done as follows: + + .sub 'onload' :anon :load :init + load_bytecode 'PCT.pbc' + $P0 = get_hll_global ['PCT'], 'HLLCompiler' + $P1 = $P0.'new'() + $P1.'language'('Foo') + $P1.'parsegrammar'('Foo::Grammar') + $P1.'parseactions'('Foo::Grammar::Actions') + .end + + .sub 'main' :main + .param pmc args + $P0 = compreg 'Foo' + $P1 = $P0.'command_line'(args) + .end + +{{ this is the most important part; is this enough? }} + +The Parrot distribution contains a Perl script to generate a compiler +stub, containing all necessary files. This generated compiler will +compile out of the box. It is highly suggested to use this script to +get started with the PCT. +The script is located in C. + +{{ Not sure whether the mk_language_shell.pl script should be mentioned long term }} + + +Running the compiler is then done as follows: + + $ parrot foo.pbc [--target=[parse|past|post|pir]] + +{{ other options? }} =head1 DESCRIPTION +The Parrot Compiler Tools are specially designed to easily create a +compiler targeting the Parrot Virtual Machine. The tools themselves +run on Parrot, which implies that no other external programs are +needed. + +The PCT is a set of libraries and programs, to: + +=over 4 + +=item * create a parser + +=item * create an intermediate data structure (Abstract Syntax Tree) + +=item * generate executable code (Parrot Intermediate Representation) + +=back + + =head1 IMPLEMENTATION +The PCT is made up of the following libraries and programs: + +=over 4 + +=item * Parrot Grammar Engine (PGE) + +=item * Parrot Abstract Syntax Tree (PAST) classes + +=item * Parrot Opcode Syntax Tree (POST) classes + +=item * PCT::HLLCompiler class + +=item * PCT::Grammar class + +=back + +Although strictly speaking it is not part of the PCT, the +Not Quite Perl (6) (NQP) language is typically used in all PCT-based +compilers. NQP is a subset of the Perl 6 language, and is a +high-level language as an alternative for PIR. + +=head2 Compilation phases + +A PCT-based compiler has by default four compilation phases, or +I. Phases can be removed and added through the API of +the C class. These are: + +=over 4 + +=item * source to parse tree + +The source is read, parsed and stored in a parse tree. + +=item * parse tree to PAST + +The parse tree is converted into a Parrot Abstract Syntax Tree. + +=item * PAST to POST + +The PAST is converted into a Parrot Opcode Syntax Tree. + +=item * POST to PIR + +The POST is converted into executable Parrot Intermediate Representation. + +=back + +=head3 Source to Parse Tree + +{{ XXX }} + +=head3 Parse tree to PAST + +{{ XXX }} + +=head3 PAST to POST + +{{ XXX }} + +=head3 POST to PIR + +{{ XXX }} + +=head2 Parrot Grammar Engine + +The Parrot Grammar Engine (PGE) is a component that I regular +expressions. Besides I regular expressions, it also understands +Perl 6 Rules. Such rules are special regular expressions to define a grammar. + +=head2 PCT::Grammar + +The class C is a built-in grammar class that can be used as +a parent class for a custom grammar. This class defines a number of rules and +tokens that are inherited by child classes. Note that the concept of C +and C are equivalent. + +The following rules are predefined: + +{{ is this necessary, or just a reference to the file? }} + +=over 4 + +=item ident + +=item ws + +=back + +=head2 PCT::HLLCompiler + +All PCT-based compilers use a HLLCompiler object as a compiler driver. +This object invokes the different compiler phases. + +=head3 HLLCompiler API Methods + +{{ TODO: complete this }} + +=over 4 + +=item commandline_prompt + +$P0.'commandline_prompt'($S0) + +sets the string in C<$S0> as a commandline prompt on the compiler in C<$P0>. +The prompt is the text that is shown on the commandline before a command is +entered when the compiler is started in interactive mode. + +=item commandline_banner + +$P0.'commandline_banner'($S0) + +sets the string in C<$S0> as a commandline banner on the compiler in C<$P0>. +The banner is the first text that is shown when the compiler is started in +interactive mode. This can be used for a copyright notice or other information. + +=back + =head1 ATTACHMENTS +None. =head1 REFERENCES docs/pdd26_ast.pod +http://dev.perl.org/perl6/doc/design/syn/S05.html =cut
[svn:parrot-pdd] r26707 - trunk/docs/pdds/draft
Author: kjs Date: Wed Apr 2 14:16:53 2008 New Revision: 26707 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] add some more proposals to pdd19; it will be reviewed shortly (I heard), so this is the chance to put in ideas. Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Wed Apr 2 14:16:53 2008 @@ -215,7 +215,7 @@ associate the identifier with a unique register for the duration of the compilation unit. -=item .lex , +=item .lex , Declare a lexical variable that is an alias for a PMC register. For example, given this preamble: @@ -235,6 +235,11 @@ =item .const = +{{ PROPOSAL: add + .const = + as an alternative to allow ".const 'Sub' ... " +}} + Define a constant named I of type I and assign value I to it. The constant is stored in the constant table of the current bytecode file. @@ -276,6 +281,16 @@ creates nested namespaces, by storing the inner namespace object in the outer namespace's global pad. +{{ PROPOSAL: make the brackets non-optional for specifying the "root" namespace, + so the key becomes optional. + + .namespace [ ? ] + + key: [';' ]* + + Also, the "identifier" should be a quoted string? +}} + =item .pragma n_operators Convert arithmethic infix operators to n_infix operations. The unary opcodes @@ -302,8 +317,17 @@ I isn't empty this compile time pragma also loads the shared lib for the HLL, so that integer type constants are working for creating new PMCs. +{{ PROPOSAL: make the "," part optional, so you don't have to + specify an empty string for the library. + (Alternatively, make this two different directives: .HLL_name, .HLL_lib) +}} + =item .HLL_map , +{{ PROPOSAL: make the ',' an "->", "=>", "=", for instance, so it's easier + to remember what argument comes first, the core type or the user type. +}} + Whenever Parrot has to create PMCs inside C code on behalf of the running user program it consults the current type mapping for the executing HLL and creates a PMC of type I instead of I, if such @@ -443,6 +467,14 @@ =head3 Directives used for Parrot calling conventions. +{{ A bit of a radical idea, but now would be the time to decide on this: + Remove the whole "long-style" invocation syntax altogether. + Only allow the short version. + As PIR is typically being generated, and hopefully by PCT-based + compilers, there seems to be no real use for too much syntactic + sugar. Just a thought. +}} + =over 4 =item .begin_call and .end_call @@ -547,6 +579,8 @@ This is syntactic sugar for the C op, but any flags set on the targets will be handled automatically by the PIR compiler. +The C<.get_results> directive must be the first instruction of the exception +handler; only declarations (.lex, .local) may come first. =head2 Syntactic Sugar
[svn:parrot-pdd] r26739 - trunk/docs/pdds/draft
Author: kjs Date: Fri Apr 4 02:16:08 2008 New Revision: 26739 Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod Log: [pdd29] fix a small layout thing; add a bit to synopsis for actions; add some HLLCompiler API methods. Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod == --- trunk/docs/pdds/draft/pdd29_compiler_tools.pod (original) +++ trunk/docs/pdds/draft/pdd29_compiler_tools.pod Fri Apr 4 02:16:08 2008 @@ -90,10 +90,10 @@ {{ Is this a good idea? }} -class Foo::Grammar::Actions; + class Foo::Grammar::Actions; method TOP($/) { - my $past := PAST::Block.new( :blocktype('declaration') ); + my $past := PAST::Block.new( :blocktype('declaration'), :node($/) ); for $ { $past.push( $( $_ ) ); } @@ -101,7 +101,10 @@ } method statement($/) { - ... + make PAST::Op.new( $( $ ), +$( $ ), +:pasttype('bind'), +:node($/) ); } method expression($/, $key) { @@ -292,6 +295,18 @@ =over 4 +=item language + +$P0.'language'('Foo') + +=item parsegrammar + +$P0.'parsegrammar'('Foo::Grammar') + +=item parseactions + +$P0.'parseactions('Foo::Grammar::Actions') + =item commandline_prompt $P0.'commandline_prompt'($S0)
[svn:parrot-pdd] r26738 - trunk/docs/pdds/draft
Author: kjs Date: Fri Apr 4 01:50:45 2008 New Revision: 26738 Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod Log: [pdd29] add more stuff to pdd29 Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod == --- trunk/docs/pdds/draft/pdd29_compiler_tools.pod (original) +++ trunk/docs/pdds/draft/pdd29_compiler_tools.pod Fri Apr 4 01:50:45 2008 @@ -14,6 +14,17 @@ Will "Coke" Coleda Klaas-Jan Stol +=head1 DEFINITIONS + +=head2 Compiler + +In this document, when we speak of a I, we mean +PCT-based compilers. + +=head2 HLL + +A High-Level Language. Examples are: Perl, Ruby, Python, Lua, Tcl, etc. + =head1 ABSTRACT This PDD specifies the Parrot Compiler Tools (PCT). @@ -45,15 +56,70 @@ get started with the PCT. The script is located in C. -{{ Not sure whether the mk_language_shell.pl script should be mentioned long -term }} +{{ Not sure whether the mk_language_shell.pl script should be mentioned long term + In a sense, this script can also be considered part of the parrot compiler "tools", + as it is used to create a compiler. +}} + +=head2 Parser Synopsis + + grammar Foo is PCT::Grammar; + + rule TOP { + * + {*} + } + + rule statement { + '=' + {*} + } + + rule expression is optable { ... } + + proto infix:<+> is precedence('1') is pirop('n_add') { ... } + + rule 'term:' is tighter(infix:<+>) is parsed(&term) { ... } + + rule term { + | {*} #= ident + | {*} #= number + } + +=head2 Actions Synopsis + +{{ Is this a good idea? }} + +class Foo::Grammar::Actions; + + method TOP($/) { + my $past := PAST::Block.new( :blocktype('declaration') ); + for $ { + $past.push( $( $_ ) ); + } + make $past; + } + method statement($/) { + ... + } + + method expression($/, $key) { + ... + } + + method term($/, $key) { + make $( $/{$key} ); + } + +=head2 Running the compiler Running the compiler is then done as follows: $ parrot foo.pbc [--target=[parse|past|post|pir]] -{{ other options? }} +{{ other options? Maybe --target=pbc in the future, once PBC can be + generated? }} =head1 DESCRIPTION @@ -70,7 +136,7 @@ =item * create an intermediate data structure (Abstract Syntax Tree) -=item * generate executable code (Parrot Intermediate Representation) +=item * generate executable Parrot code =back @@ -127,19 +193,45 @@ =head3 Source to Parse Tree -{{ XXX }} +The first stage of a PCT-based compiler is done by the C. The +parser is defined as a set of Perl 6 Rules, which is processed by the +Perl 6 Rules compiler. This results in a generated PIR file that +implements the parser. + +{{ Doesn't this make the Perl 6 rules compiler part of the PCT? }} + +During the first stage, the source (input string) is parsed, resulting +in a C. =head3 Parse tree to PAST -{{ XXX }} +The second stage converts the parse tree into a Parrot Abstract Syntax Tree +(PAST). PAST is a data structure consisting of PAST nodes, each of which +represents a common HLL construct. While all languages differ in syntax, +many constructs in different HLLs map to the same semantics. This second +transformation is executed during the parse stage. The transformations +of the parse tree nodes into PAST nodes is done by so-called parse actions, +which are methods of a class that is specified through the C +attribute of the HLLCompiler. Such classes are implemented in NQP. + +{{ How do we say that this is not obligatory; you could also use PIR, + and in the future maybe other languages. +}} =head3 PAST to POST -{{ XXX }} +The third transformation converts the PAST into a Parrot Opcode Syntax Tree +(POST). PAST nodes represent HLL constructs, which are transformed into a +set of low-level POST nodes. A POST node is a low-level node, representing +a single instruction, label, or a subroutine. While a PAST is very close to +a HLL program, a POST is much closer to PIR code. =head3 POST to PIR -{{ XXX }} +The last transformation generates PIR code from the POST. + +The generated PIR is then fed into the Parrot executable, and processed +into Parrot Byte Code (PBC) by the PIR compiler. =head2 Parrot Grammar Engine @@ -147,6 +239,28 @@ expressions. Besides I regular expressions, it also understands Perl 6 Rules. Such rules are special regular expressions to define a grammar. +=head2 Parrot Abstract Syntax Tree + +The PCT includes a set of PAST classes. PAST classes represent common language +constructs, such as a C. +These are described extensively in L. + +=head2 Parrot Opcode Syntax Tree + +=head3 POST::Node + +POST::Node is the base class for all other POST classes. + +=head3 POST::Op + +=head3 POST::Ops + +=head3 POST::Label + +=head3 POST::Sub + + + =head2 PCT::Grammar The class C is a built-in grammar class that can be used as @@ -1
[svn:parrot-pdd] r26955 - trunk/docs/pdds/draft
Author: kjs Date: Sun Apr 13 05:08:55 2008 New Revision: 26955 Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod Log: [pdd29] add a few more things so i won't forget. Modified: trunk/docs/pdds/draft/pdd29_compiler_tools.pod == --- trunk/docs/pdds/draft/pdd29_compiler_tools.pod (original) +++ trunk/docs/pdds/draft/pdd29_compiler_tools.pod Sun Apr 13 05:08:55 2008 @@ -143,6 +143,8 @@ =back +{{ Maybe just say it's used to create parrot-targeting compilers, not + list these as =items }} =head1 IMPLEMENTATION @@ -242,6 +244,13 @@ expressions. Besides I regular expressions, it also understands Perl 6 Rules. Such rules are special regular expressions to define a grammar. +The I symbol in a grammar is named C; this is the top-level +rule that is executed when the parser is invoked. + +=head3 Operator precedence parsing + +{{ insert stuff about using an operator prec. table here }} + =head2 Parrot Abstract Syntax Tree The PCT includes a set of PAST classes. PAST classes represent common language
[svn:parrot-pdd] r29292 - trunk/docs/pdds/draft
Author: kjs Date: Fri Jul 11 06:24:05 2008 New Revision: 29292 Modified: trunk/docs/pdds/draft/pdd19_pir.pod Log: [pdd19] add :lexid, but description not complete yet (not sure about details). Modified: trunk/docs/pdds/draft/pdd19_pir.pod == --- trunk/docs/pdds/draft/pdd19_pir.pod (original) +++ trunk/docs/pdds/draft/pdd19_pir.pod Fri Jul 11 06:24:05 2008 @@ -294,6 +294,9 @@ The brackets are not optional, although the string inside them is. +{{ NOTE: currently the brackets *are* optional. TODO: make decision whether + we want the brackets optional. }} + =item .pragma n_operators @@ -436,17 +439,17 @@ abbreviated) definition: .sub tr_00_init :immediate - .local pmc tr_array - tr_array = new 'FixedIntegerArray' - tr_array = 256 - ## [code to initialize tr_array omitted.] - .return (tr_array) +.local pmc tr_array +tr_array = new 'FixedIntegerArray' +tr_array = 256 +## [code to initialize tr_array omitted.] +.return (tr_array) .end -This code is run at compile time, and the returned C is stored +This code is run at compile time, and the returned C is stored in the bytecode file in place of the sub. Other subs may then do: - .const .Sub tr_00 = 'tr_00_init' +.const .Sub tr_00 = 'tr_00_init' in order to fetch the constant. @@ -492,10 +495,20 @@ the method B also be the v-table method B), use B<:vtable("get_string")>. +When the B<:vtable> flag is set, the object PMC cn be referred to with C, +as with the B<:method> flag. + + =item :outer(subname) The marked C<.sub> is lexically nested within the sub known by B. +=item :lexid( ) + +Identifies the subroutine by the specified string. + +{{ TODO: explain purpose and details of this flag. }} + =back @@ -953,8 +966,7 @@ {{ NOTE: This is likely because the parsing of heredocs happens later than the preprocessing of macros. Might be nice if we could parse heredocs at the macro -level, but not a high priority. compilers/pirc/new can do this, but there's a -bug in the heredoc handling on Win32 XP using MSVS. }} +level, but not a high priority. compilers/pirc/new can do this. }} Using braces, { }, allows you to span multiple lines for an argument. See runtime/parrot/include/hllmacros.pir for examples and possible usage. @@ -987,8 +999,6 @@ 1234 -{{ NOTE: braced arguments does not work correctly yet in compilers/pirc/new }} - =back =head3 Unique local labels