develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34061 - branches/main/languages/perl6/src/parser

From:
pmichaud
Date:
December 17, 2008 22:29
Subject:
[svn:parrot] r34061 - branches/main/languages/perl6/src/parser
Message ID:
20081218062904.BE87CCBA12@x12.develooper.com
Author: pmichaud
Date: Wed Dec 17 22:29:04 2008
New Revision: 34061

Modified:
   branches/main/languages/perl6/src/parser/actions.pm

Log:
[rakudo]:  Convert some $?INIT to .loadinit on blocks.


Modified: branches/main/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/main/languages/perl6/src/parser/actions.pm	(original)
+++ branches/main/languages/perl6/src/parser/actions.pm	Wed Dec 17 22:29:04 2008
@@ -11,13 +11,6 @@
     # Attach any initialization code.
     our $?INIT;
     if defined( $?INIT ) {
-        $?INIT.unshift(
-            PAST::Var.new(
-                :name('$def'),
-                :scope('lexical'),
-                :isdecl(1)
-            )
-        );
         $?INIT.blocktype('declaration');
         $?INIT.pirflags(':init :load');
         $past.unshift( $?INIT );
@@ -978,14 +971,10 @@
 
         # Assemble all that we build into a statement list and then place it
         # into the init code.
-        our $?INIT;
-        unless defined( $?INIT ) {
-            $?INIT := PAST::Block.new();
-        }
-        $?INIT.push(PAST::Stmts.new(
-            $role_past,
-            $class_past
-        ));
+        our $?BLOCK;
+        my $loadinit := $?BLOCK.loadinit();
+        $loadinit.push($role_past);
+        $loadinit.push($class_past);
 
         # Finally, since it's a decl, we don't have anything to emit at this
         # point; just hand back empty statements block.
@@ -1871,7 +1860,6 @@
     our $?MODULE;
     our $?NS;
     our $?PACKAGE;
-    our $?INIT;
     my $name := $<name>;
 
     if $key eq 'open' {
@@ -2018,10 +2006,8 @@
             );
 
             # Attatch grammar declaration to the init code.
-            unless defined( $?INIT ) {
-                $?INIT := PAST::Block.new();
-            }
-            $?INIT.push( $?GRAMMAR );
+            our $?BLOCK;
+            $?BLOCK.loadinit().push( $?GRAMMAR );
 
             # Clear namespace.
             $?NS := '';
@@ -2077,15 +2063,13 @@
             # we want to put under this block so they get the correct
             # namespace. If it's an anonymous class, everything goes into
             # this block.
-            unless defined( $?INIT ) {
-                $?INIT := PAST::Block.new();
-            }
             for @( $?CLASS ) {
                 if $_.isa(PAST::Block) || !$name {
                     $past[0].push( $_ );
                 }
                 else {
-                    $?INIT.push( $_ );
+                    our $?BLOCK;
+                    $?BLOCK.loadinit().push( $_ );
                 }
             }
         }
@@ -2098,7 +2082,6 @@
 method role_def($/, $key) {
     our $?ROLE;
     our $?NS;
-    our $?INIT;
     my $name := ~$<name>;
 
     if $key eq 'open' {
@@ -2135,15 +2118,13 @@
 
         # Attatch role declaration to the init code, skipping blocks since
         # those are accessors.
-        unless defined( $?INIT ) {
-            $?INIT := PAST::Block.new();
-        }
         for @( $?ROLE ) {
             if $_.isa(PAST::Block) {
                 $past.push( $_ );
             }
             else {
-                $?INIT.push( $_ );
+                our $?BLOCK;
+                $?BLOCK.loadinit().push( $_ );
             }
         }
 
@@ -3261,13 +3242,11 @@
         )
     );
 
-    # Put this code in $?INIT, so the type is created early enough, then this
-    # node results in an empty statement node.
-    our $?INIT;
-    unless defined($?INIT) {
-        $?INIT := PAST::Block.new();
-    }
-    $?INIT.push($past);
+    # Put this code in loadinit, so the type is created early enough, 
+    # then this node results in an empty statement node.
+    our $?BLOCK;
+    $?BLOCK.loadinit().push($past);
+
     make PAST::Stmts.new();
 }
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About