Author: pmichaud
Date: Tue Aug 19 07:32:13 2008
New Revision: 30341

Modified:
   trunk/compilers/pct/src/PAST/Compiler.pir
   trunk/languages/abc/src/   (props changed)
   trunk/languages/perl6/src/parser/actions.pm

Log:
merge rakpbc branch into trunk


Modified: trunk/compilers/pct/src/PAST/Compiler.pir
==============================================================================
--- trunk/compilers/pct/src/PAST/Compiler.pir   (original)
+++ trunk/compilers/pct/src/PAST/Compiler.pir   Tue Aug 19 07:32:13 2008
@@ -518,21 +518,27 @@
     blockpast = get_global '@?BLOCK'
     unshift blockpast, node
 
-    .local string name
+    .local string name, pirflags, blocktype
+    .local pmc ns
     name = node.'name'()
+    pirflags = node.'pirflags'()
+    blocktype = node.'blocktype'()
+    ns = node.'namespace'()
+
+    ##  handle anonymous blocks
     if name goto have_name
     name = self.'unique'('_block')
+    if ns goto have_name
+    pirflags = concat pirflags, ' :anon'
   have_name:
 
     ##  create a POST::Sub node for this block
-    .local string blocktype
-    blocktype = node.'blocktype'()
-    .local pmc ns, pirflags
-    ns = node.'namespace'()
-    pirflags = node.'pirflags'()
     .local pmc bpost
     $P0 = get_hll_global ['POST'], 'Sub'
-    bpost = $P0.'new'('node'=>node, 'name'=>name, 'blocktype'=>blocktype, 
'namespace'=>ns, 'pirflags'=>pirflags)
+    bpost = $P0.'new'('node'=>node, 'name'=>name, 'blocktype'=>blocktype, 
'namespace'=>ns)
+    unless pirflags goto pirflags_done
+    bpost.'pirflags'(pirflags)
+  pirflags_done:
 
     ##  determine the outer POST::Sub for the new one
     .local pmc outerpost
@@ -672,7 +678,10 @@
     $P0 = get_hll_global ['POST'], 'Ops'
     bpost = $P0.'new'(bpost, 'node'=>node, 'result'=>result)
     if ns goto block_decl_ns
-    bpost.'push_pirop'('get_global', result, name)
+    concat $S0, '.const .Sub ', result
+    concat $S0, ' = '
+    concat $S0, name
+    bpost.'push_pirop'($S0)
     goto block_done
   block_decl_ns:
     bpost.'push_pirop'('get_hll_global', result, ns, name)

Modified: trunk/languages/perl6/src/parser/actions.pm
==============================================================================
--- trunk/languages/perl6/src/parser/actions.pm (original)
+++ trunk/languages/perl6/src/parser/actions.pm Tue Aug 19 07:32:13 2008
@@ -29,6 +29,23 @@
     # Make sure we have the interpinfo constants.
     $past.unshift( PAST::Op.new( :inline('.include "interpinfo.pasm"') ) );
 
+    #  convert the last operation of the block into a .return op
+    #  so that :load block below isn't used as return value
+    $past.push( PAST::Op.new( $past.pop(), :pirop('return') ) );
+    #  automatically invoke mainline on :load (but not :init)
+    $past.push(
+        PAST::Block.new(
+            PAST::Op.new(
+                :inline(
+                    '$P0 = interpinfo .INTERPINFO_CURRENT_SUB',
+                    '$P0 = $P0."get_outer"()',
+                    '$P0()'
+                )
+            ),
+            :pirflags(':load')
+        )
+    );
+
     make $past;
 }
 

Reply via email to