Skip to content

Commit 39a8dad

Browse files
author
Carl Masak
committed
[QAST::Operations] implement :flat :named
Parrot makes this work even without the :named, but it's nice to have it there, I guess.
1 parent b66b2e1 commit 39a8dad

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/QAST/Operations.nqp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ sub handle_arg($arg, $qastcomp, $ops, @arg_results) {
353353
my $result := $arg_post.result;
354354
if $arg.flat {
355355
$result := "$result :flat";
356+
if $arg.named {
357+
$result := "$result :named";
358+
}
356359
}
357360
elsif $arg.named -> $name {
358361
$result := "$result :named(" ~ $qastcomp.escape($name) ~ ")";

t/qast/qast.t

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,3 +841,44 @@ is_qast(
841841
42,
842842
'call with flattened argument works');
843843
}
844+
845+
{
846+
my $greeter := QAST::Block.new(
847+
QAST::Var.new( :name('greeting'), :named('greeting'), :scope('local'), :decl('param') ),
848+
QAST::Var.new( :name('name'), :named('name'), :scope('local'), :decl('param') ),
849+
QAST::Op.new(
850+
:op('concat'),
851+
QAST::Op.new(
852+
:op('callmethod'), :name('m'),
853+
QAST::Var.new( :name('greeting'), :scope('local') ),
854+
:returns(str)
855+
),
856+
QAST::Op.new(
857+
:op('callmethod'), :name('m'),
858+
QAST::Var.new( :name('name'), :scope('local') ),
859+
:returns(str)
860+
)
861+
),
862+
);
863+
864+
is_qast(
865+
QAST::Block.new(
866+
$greeter,
867+
QAST::Op.new(
868+
:op('call'),
869+
QAST::BVal.new( :value($greeter) ),
870+
QAST::Op.new(
871+
:op('hash'),
872+
QAST::SVal.new( :value('name') ),
873+
QAST::WVal.new( :value(A) ),
874+
QAST::SVal.new( :value('greeting') ),
875+
QAST::WVal.new( :value(B) ),
876+
:flat,
877+
:named,
878+
)
879+
)
880+
),
881+
'ba',
882+
'call with named flattened argument works');
883+
}
884+

0 commit comments

Comments
 (0)