Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Perl6::Actions] refactor
De-duplicated some code. This will help us during
the next commit, because we'll be adding more
code in that path.
  • Loading branch information
Carl Masak committed Nov 2, 2012
1 parent c45b029 commit e7ab9ac
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Perl6/Actions.pm
Expand Up @@ -3484,18 +3484,20 @@ class Perl6::Actions is HLL::Actions does STDActions {
}
}

sub add_macro_arguments($expr, $ast_class, @argument_quasi_asts) {
sub add_macro_arguments($expr, $ast_class, @argument_asts) {
sub wrap_and_add_expr($expr) {
my $quasi_ast := $ast_class.new();
nqp::bindattr($quasi_ast, $ast_class, '$!past', $expr);
@argument_asts.push($quasi_ast);
}

if nqp::istype($expr, QAST::Op) && $expr.name eq '&infix:<,>' {
for $expr.list {
my $quasi_ast := $ast_class.new();
nqp::bindattr($quasi_ast, $ast_class, '$!past', $_);
@argument_quasi_asts.push($quasi_ast);
wrap_and_add_expr($_);
}
}
else {
my $quasi_ast := $ast_class.new();
nqp::bindattr($quasi_ast, $ast_class, '$!past', $expr);
@argument_quasi_asts.push($quasi_ast);
wrap_and_add_expr($expr);
}
}

Expand Down

0 comments on commit e7ab9ac

Please sign in to comment.