Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add abstractions for getting the current lexpad and code.
  • Loading branch information
jnthn committed Jul 9, 2012
1 parent 171f251 commit 68c25c3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/QAST/Operations.nqp
Expand Up @@ -590,6 +590,24 @@ QAST::Operations.add_core_op('lexotic', -> $qastcomp, $op {
$ops
});

# Context introspection
QAST::Operations.add_core_op('curlexpad', -> $qastcomp, $op {
my $reg := $*REGALLOC.fresh_p();
my $ops := $qastcomp.post_new('Ops');
$ops.push_pirop('getinterp', $reg);
$ops.push_pirop('set', $reg, $reg ~ "['lexpad']");
$ops.result($reg);
$ops
});
QAST::Operations.add_core_op('curcode', -> $qastcomp, $op {
my $reg := $*REGALLOC.fresh_p();
my $ops := $qastcomp.post_new('Ops');
$ops.push_pirop('getinterp', $reg);
$ops.push_pirop('set', $reg, $reg ~ "['sub']");
$ops.result($reg);
$ops
});

# I/O opcodes
QAST::Operations.add_core_pirop_mapping('print', 'print', '0s');
QAST::Operations.add_core_pirop_mapping('say', 'say', '0s');
Expand Down

0 comments on commit 68c25c3

Please sign in to comment.