Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
nqp::defined(...) and test.
  • Loading branch information
jnthn committed Jan 12, 2013
1 parent c819b74 commit 3fee403
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -1126,6 +1126,9 @@ QAST::OperationsJAST.map_classlib_core_op('box_n', $TYPE_OPS, 'box_n', [$RT_NUM,
QAST::OperationsJAST.map_classlib_core_op('box_s', $TYPE_OPS, 'box_s', [$RT_STR, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('setboolspec', $TYPE_OPS, 'setboolspec', [$RT_OBJ, $RT_INT, $RT_OBJ], $RT_OBJ, :tc);

# defined - overridden by HLL, but by default same as .DEFINITE.
QAST::OperationsJAST.map_classlib_core_op('defined', $TYPE_OPS, 'isconcrete', [$RT_OBJ], $RT_INT, :tc);

# code object related opcodes
QAST::OperationsJAST.map_classlib_core_op('takeclosure', $TYPE_OPS, 'takeclosure', [$RT_OBJ], $RT_OBJ, :tc);

Expand Down
31 changes: 30 additions & 1 deletion t/qast_6model.t
@@ -1,6 +1,6 @@
use helper;

plan(14);
plan(15);

qast_test(
-> {
Expand Down Expand Up @@ -908,3 +908,32 @@ qast_test(
},
"0\n0\n1\n1\n1\n0\n",
"Boolification");

qast_test(
-> {
my $block := QAST::Block.new(
QAST::Stmts.new(
QAST::Op.new(
:op('say'),
QAST::Op.new(
:op('defined'),
QAST::Op.new( :op('knowhow') )
)),
QAST::Op.new(
:op('say'),
QAST::Op.new(
:op('defined'),
QAST::Op.new(
:op('create'),
QAST::Op.new( :op('knowhow') )
)))
));
QAST::CompUnit.new(
$block,
:main(QAST::Op.new(
:op('call'),
QAST::BVal.new( :value($block) )
)))
},
"0\n1\n",
"defined works, just like isconcrete by default");

0 comments on commit 3fee403

Please sign in to comment.