Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
halfway commit, does not work
Still seems to be largly an attempt in the right direction, though.
  • Loading branch information
Carl Masak committed Aug 30, 2012
1 parent 7d10d1a commit 1ac5431
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -1078,8 +1078,19 @@ class Perl6::Actions is HLL::Actions {
method term:sym<lambda>($/) { make block_closure($<pblock>.ast); }
method term:sym<sigterm>($/) { make $<sigterm>.ast; }
method term:sym<unquote>($/) {
my $ast_class := $*W.find_symbol(['AST']);
my $unquote_ast := $ast_class.new();
my $past := $<statementlist>.ast;
nqp::bindattr($unquote_ast, $ast_class, '$!past', $past);
$*W.add_object($unquote_ast);
my $throwaway_block := QAST::Block.new();
my $unquote_context := block_closure(
reference_to_code_object(
$*W.create_simple_code_object($throwaway_block, 'Block'),
$throwaway_block
));
make QAST::Unquote.new(:position(+@*UNQUOTE_ASTS));
@*UNQUOTE_ASTS.push($<statementlist>.ast);
@*UNQUOTE_ASTS.push($unquote_ast);
}

method name($/) { }
Expand Down
12 changes: 11 additions & 1 deletion src/core/AST.pm
Expand Up @@ -17,14 +17,24 @@ my class AST {

method evaluate_unquotes(@unquote_asts) {
my $pasts := nqp::list();
say "The list has {+@unquote_asts} elements";
for @unquote_asts {
# TODO: find and report macro name
X::TypeCheck::Splice.new(
got => $_,
expected => AST,
action => 'unquote evaluation',
).throw unless $_ ~~ AST;
nqp::push($pasts, nqp::getattr(nqp::p6decont($_), AST, '$!past'))
my $past := QAST::Block.new(
:blocktype<raw>,
nqp::getattr(nqp::p6decont($_), AST, '$!past'),
);
$*W.add_quasi_fixups($_, $past);
$past := QAST::Stmts.new(
$past,
QAST::Op.new( :op('call'), QAST::BVal.new( :value($past) ) )
);
nqp::push($pasts, $past);
}
$!past.evaluate_unquotes($pasts);
}
Expand Down

0 comments on commit 1ac5431

Please sign in to comment.