Permalink
Browse files

Make say ($_*$_ for 0..9) DTRT (only for for now)

  • Loading branch information...
1 parent faba63b commit b4b916ab696845c3563f30a254f30a42acc11109 @sorear committed Mar 29, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 src/NieczaActions.pm6
  2. +14 −0 src/Op.pm6
@@ -3284,7 +3284,7 @@ method statementlist($/) {
[ map *.statement_level($/), map *.ast, @( $<statement> ) ]);
}
-method semilist($/) { make [ map *.ast, @( $<statement> ) ] }
+method semilist($/) { make [ map *.ast.semilist_level($/), @( $<statement> ) ] }
method module_name:normal ($/) {
# name-extension stuff is just ignored on module names for now
View
@@ -47,6 +47,7 @@ method cgop_labelled($body, $label) {
method code_labelled($body, $label) { self.code($body) } #OK not used
method statement_level($/) { self }
+method semilist_level($/) { self }
method onlystub() { False }
method const_value($) { }
@@ -517,6 +518,19 @@ class ImmedForLoop is Op {
method zyg() { $.source, $.sink }
method ctxzyg($) { $.source, 1, $.sink, 0 }
+ # used only with 'foo ($_ for 1,2,3)'
+ # var will be a single gensym
+ method semilist_level($/) {
+ my $pname = $!var.[0];
+ my $aname = $Actions.gensym;
+ my $sub = $Actions.thunk_sub($OpLet.new(var => $pname,
+ to => $OpLexical.new(name => $aname), in => $!sink),
+ params => [ $aname ]);
+ my $sname = $Actions.block_expr($/, $sub).name;
+
+ $OpForLoop.new(sink => $sname, source => $!source);
+ }
+
method code($body) { self.code_labelled($body, '') }
method code_labelled($body, $l) {
my $id = $Actions.genid;

0 comments on commit b4b916a

Please sign in to comment.