-
-
Save MasterDuke17/a19a5cfadd0e450d1dd74d2f048db905 to your computer and use it in GitHub Desktop.
AST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- QAST::Stmts | |
- QAST::WVal(Array) | |
- QAST::Stmt | |
- QAST::Op(while) | |
- QAST::Op(p6definite) | |
- QAST::Op(bind) | |
- QAST::Var(lexical $_) | |
- QAST::Op(call &get) | |
- QAST::Block(:blocktype(immediate)) | |
- QAST::Op(call) | |
- QAST::Op(p6capturelex) | |
- QAST::Stmts <sunk> .say | |
- QAST::Stmt <sunk final> .say | |
- QAST::Want <sunk> | |
- QAST::Op(callmethod sink) <sunk> | |
- QAST::Op(hllize) <sunk> :statement_id<?> | |
- QAST::Op(callmethod say) say | |
- QAST::Var(lexical $_) <wanted> | |
- v | |
- QAST::Op(p6sink) | |
- QAST::Op(hllize) <sunk> :statement_id<?> | |
- QAST::Op(callmethod say) say | |
- QAST::Var(lexical $_) <wanted> | |
- QAST::WVal(Nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp | |
index 0ea6797..7e05dd1 100644 | |
--- a/src/Perl6/Actions.nqp | |
+++ b/src/Perl6/Actions.nqp | |
@@ -710,21 +710,25 @@ class Perl6::Actions is HLL::Actions does STDActions { | |
make $name; | |
} | |
- # Turn $code into "for lines() { $code }" | |
+ # Turn $code into "while ($_ := get()).DEFINITE { $code }" | |
sub wrap_option_n_code($/, $code) { | |
- $code := make_topic_block_ref($/, $code, copy => 1); | |
- my $past := QAST::Op.new(:op<callmethod>, :name<map>, | |
- QAST::Op.new(:op<call>, :name<&lines>), | |
- QAST::Op.new(:op<p6capturelex>, $code) | |
+ #$code := make_topic_block_ref($/, $code, copy => 1); | |
+ my $bind_get := QAST::Op.new(:op<bind>, | |
+ QAST::Var.new(:name<$_>, :scope<lexical>), | |
+ QAST::Op.new(:op<call>, :name<&get>) | |
); | |
- $past := QAST::Want.new( | |
- QAST::Op.new( :op<callmethod>, :name<sink>, $past ), | |
- 'v', QAST::Op.new( :op<callmethod>, :name<sink>, $past ) | |
- ); | |
- } | |
- | |
- # Turn $code into "for lines() { $code; say $_ }" | |
- # &wrap_option_n_code already does the C<for> loop, so we just add the | |
+ my $cond := QAST::Op.new(:op<p6definite>, $bind_get); | |
+ my $body := QAST::Block.new(:blocktype<immediate>, QAST::Op.new(:op<call>, QAST::Op.new(:op<p6capturelex>, $code))); | |
+ my $past := QAST::Op.new(:op<while>, $cond, $body); | |
+ #tweak_loop($past); | |
+ #$past := QAST::Want.new( | |
+ # $past, | |
+ # 'v', $past | |
+ #); | |
+ } | |
+ | |
+ # Turn $code into "while ($_ := get()).DEFINITE { $code; say $_ }" | |
+ # &wrap_option_n_code already does the C<while> loop, so we just add the | |
# C<say> call here | |
sub wrap_option_p_code($/, $code) { | |
wrap_option_n_code($/, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[dan@alexandria rakudo]$ ./perl6-m -ne '.say' perl6-valgrind-m | |
#!/bin/sh | |
Cannot find method 'Nil' on object of type List | |
in block <unit> at -e line 1 | |
[dan@alexandria rakudo]$ ./perl6-m -ne 'say "hi"' perl6-valgrind-m | |
hi | |
No such method 'CALL-ME' for invocant of type 'Bool' | |
in block <unit> at -e line 1 | |
[dan@alexandria rakudo]$ ./perl6-m -ne 'sub { say "hi" }' perl6-valgrind-m | |
hi | |
hi | |
hi | |
hi | |
hi | |
hi | |
hi | |
hi | |
hi | |
hi | |
hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment