Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add handling of blocktype declaration, and add a basic test for it.
  • Loading branch information
jnthn committed May 12, 2012
1 parent 5d24bc1 commit 2cd5cd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/QAST/Compiler.nqp
Expand Up @@ -252,7 +252,11 @@ class QAST::Compiler is HLL::Compiler {
$ops.result($rreg);
}
else {

# Get the block and newclosure it.
my $breg := $*REGALLOC.fresh_p();
$ops.push_pirop(".const 'Sub' $breg = '" ~ $node.cuid() ~ "'");
$ops.push_pirop("newclosure", $breg, $breg, :result($breg));
$ops.result($breg);
}
$ops
}
Expand Down
15 changes: 14 additions & 1 deletion t/qast/qast.t
@@ -1,6 +1,6 @@
use QRegex;

plan(29);
plan(30);

# Following a test infrastructure.
sub compile_qast($qast) {
Expand Down Expand Up @@ -340,3 +340,16 @@ is_qast_args(
[nqp::hash('coconuts', 42)],
42,
'atkey operation');

is_qast(
QAST::Block.new(
QAST::Op.new(
:op('call'),
QAST::Block.new(
:blocktype('declaration'),
QAST::IVal.new( :value(2012) )
)
)
),
2012,
'declaration blocktype directly inside a call op');

0 comments on commit 2cd5cd6

Please sign in to comment.