Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[QAST::Operations] implement :flat :named
Parrot makes this work even without the :named, but it's
nice to have it there, I guess.
  • Loading branch information
Carl Masak committed May 26, 2012
1 parent b66b2e1 commit 39a8dad
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/QAST/Operations.nqp
Expand Up @@ -353,6 +353,9 @@ sub handle_arg($arg, $qastcomp, $ops, @arg_results) {
my $result := $arg_post.result;
if $arg.flat {
$result := "$result :flat";
if $arg.named {
$result := "$result :named";
}
}
elsif $arg.named -> $name {
$result := "$result :named(" ~ $qastcomp.escape($name) ~ ")";
Expand Down
41 changes: 41 additions & 0 deletions t/qast/qast.t
Expand Up @@ -841,3 +841,44 @@ is_qast(
42,
'call with flattened argument works');
}

{
my $greeter := QAST::Block.new(
QAST::Var.new( :name('greeting'), :named('greeting'), :scope('local'), :decl('param') ),
QAST::Var.new( :name('name'), :named('name'), :scope('local'), :decl('param') ),
QAST::Op.new(
:op('concat'),
QAST::Op.new(
:op('callmethod'), :name('m'),
QAST::Var.new( :name('greeting'), :scope('local') ),
:returns(str)
),
QAST::Op.new(
:op('callmethod'), :name('m'),
QAST::Var.new( :name('name'), :scope('local') ),
:returns(str)
)
),
);

is_qast(
QAST::Block.new(
$greeter,
QAST::Op.new(
:op('call'),
QAST::BVal.new( :value($greeter) ),
QAST::Op.new(
:op('hash'),
QAST::SVal.new( :value('name') ),
QAST::WVal.new( :value(A) ),
QAST::SVal.new( :value('greeting') ),
QAST::WVal.new( :value(B) ),
:flat,
:named,
)
)
),
'ba',
'call with named flattened argument works');
}

0 comments on commit 39a8dad

Please sign in to comment.