Created
August 2, 2015 05:18
-
-
Save cognominal/efa78cd052e6b9ef7268 to your computer and use it in GitHub Desktop.
tentative example of ParamTypeCheck use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use QAST:from<NQP>; | |
use nqp; | |
my $ast := QAST::Block.new( | |
QAST::Op.new(:op<call>, | |
QAST::Block.new( | |
QAST::Var.new(:name<$a>, :scope<param>, :decl<var>, | |
QAST::ParamTypeCheck.new( | |
QAST::Op.new(:op<istrue>, QAST::Var.new(:name<$a>, :scope<param>)))), | |
QAST::Op.new(:op<say>, | |
QAST::Op.new(:op<callmethod>, :name<Str>,QAST::Var.new(:name<$a>, :scope<param>)) | |
) | |
), | |
QAST::Ival(:value(42)) | |
) | |
); | |
say($ast.dump()); | |
say(exec_qast($ast)); | |
sub exec_qast($qast) { | |
my $*QAST_BLOCK_NO_CLOSE := 1; | |
my $code := nqp::getcomp('nqp').compile($qast, :from('ast')); | |
$code(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment