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

[svn:parrot] r34236 - in branches/pctloop: compilers/pct/src/PAST languages/perl6/src/builtins

From:
tene
Date:
December 21, 2008 22:29
Subject:
[svn:parrot] r34236 - in branches/pctloop: compilers/pct/src/PAST languages/perl6/src/builtins
Message ID:
20081222062930.44AB3CBA12@x12.develooper.com
Author: tene
Date: Sun Dec 21 22:29:29 2008
New Revision: 34236

Modified:
   branches/pctloop/compilers/pct/src/PAST/Compiler.pir
   branches/pctloop/languages/perl6/src/builtins/control.pir

Log:
[pct]: Support 'redo' in loop_helper
[rakudo]: Add 'redo' and 'last' subs

Modified: branches/pctloop/compilers/pct/src/PAST/Compiler.pir
==============================================================================
--- branches/pctloop/compilers/pct/src/PAST/Compiler.pir	(original)
+++ branches/pctloop/compilers/pct/src/PAST/Compiler.pir	Sun Dec 21 22:29:29 2008
@@ -1535,25 +1535,33 @@
     .local pmc ops
     ops = post_ops.'new'()
 
-    .local pmc looplabel, startlabel, nextlabel, lastlabel, endlabel
+    .local pmc looplabel, startlabel, nextlabel, redolabel, lastlabel, endlabel
     $S0 = self.'unique'('loop_')
     looplabel = post_label.'new'('result'=>$S0)
     $S1 = concat $S0, '_start'
     startlabel = post_label.'new'('result'=>$S1)
     $S1 = concat $S0, '_next'
     nextlabel = post_label.'new'('result'=>$S1)
+    $S1 = concat $S0, '_redo'
+    redolabel = post_label.'new'('result'=>$S1)
     $S1 = concat $S0, '_last'
     lastlabel = post_label.'new'('result'=>$S1)
     $S1 = concat $S0, '_end'
     endlabel = post_label.'new'('result'=>$S1)
 
-    .local string next_handler, last_handler
+    .local string next_handler, redo_handler, last_handler
     next_handler = self.'uniquereg'('P')
     ops.'push_pirop'('new', next_handler, "'ExceptionHandler'")
     ops.'push_pirop'('set_addr', next_handler, nextlabel)
     ops.'push_pirop'('callmethod', '"handle_types"', next_handler, .CONTROL_LOOP_NEXT)
     ops.'push_pirop'('push_eh', next_handler)
 
+    redo_handler = self.'uniquereg'('P')
+    ops.'push_pirop'('new', redo_handler, "'ExceptionHandler'")
+    ops.'push_pirop'('set_addr', redo_handler, redolabel)
+    ops.'push_pirop'('callmethod', '"handle_types"', redo_handler, .CONTROL_LOOP_REDO)
+    ops.'push_pirop'('push_eh', redo_handler)
+
     last_handler = self.'uniquereg'('P')
     ops.'push_pirop'('new', last_handler, "'ExceptionHandler'")
     ops.'push_pirop'('set_addr', last_handler, lastlabel)
@@ -1569,6 +1577,10 @@
     ops.'push'(body)
     self.'push_throw_typed'(ops, .CONTROL_LOOP_NEXT)
 
+    ops.'push'(redolabel)
+    ops.'push_pirop'('.local pmc exception')
+    ops.'push_pirop'('.get_results (exception)')
+    ops.'push_pirop'('goto', startlabel)
     ops.'push'(nextlabel)
     ops.'push_pirop'('.local pmc exception')
     ops.'push_pirop'('.get_results (exception)')

Modified: branches/pctloop/languages/perl6/src/builtins/control.pir
==============================================================================
--- branches/pctloop/languages/perl6/src/builtins/control.pir	(original)
+++ branches/pctloop/languages/perl6/src/builtins/control.pir	Sun Dec 21 22:29:29 2008
@@ -126,6 +126,30 @@
     throw e
 .end
 
+=item redo
+
+=cut
+
+.sub 'redo'
+    .local pmc e
+    e = new 'Exception'
+    e['severity'] = .EXCEPT_NORMAL
+    e['type'] = .CONTROL_LOOP_REDO
+    throw e
+.end
+
+=item last
+
+=cut
+
+.sub 'last'
+    .local pmc e
+    e = new 'Exception'
+    e['severity'] = .EXCEPT_NORMAL
+    e['type'] = .CONTROL_LOOP_LAST
+    throw e
+.end
+
 .sub 'continue'
     .local pmc e
     e = new 'Exception'



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