Created
December 20, 2012 20:34
-
-
Save anonymous/4348324 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
sub try_nqp_transform($code, $transform) { | |
pir::load_language__0s('NQP'); | |
my $nqp := pir::compreg__Ps('nqp'); | |
my $p6 := pir::compreg__Ps('perl6'); | |
my $qast := $p6.compile($code, :target('past')); | |
my $comp := $nqp.compile($transform); | |
my $res := nqp::atpos($comp, 1)($qast); | |
my $pbc := $p6.evalpmc($p6.pir($p6.post($res))); | |
$pbc(); | |
} | |
try_nqp_transform(q:to/P6CODE/, q:to/NQPCODE/); | |
say 42; | |
P6CODE | |
sub transform($qast) { | |
say("in transformer"); | |
# Do stuff... | |
$qast | |
} | |
NQPCODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment