Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a way to grab a code ref from an SC; will be needed for the new f…
…ixup handling code.
  • Loading branch information
jnthn committed Feb 13, 2012
1 parent bf0a0d8 commit 6291382
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/HLL/World.pm
Expand Up @@ -102,6 +102,11 @@ class HLL::World {
$past
}

# Gets a code ref from the SC.
method get_slot_past_for_code_ref_at($idx) {
PAST::Op.new( :pirop('nqp_get_sc_code_ref Psi'), $!handle, $idx );
}

# Utility sub to wrap PAST with slot setting.
method set_slot_past($slot, $past_to_set) {
return PAST::Op.new( :pirop('nqp_set_sc_object vsiP'),
Expand Down Expand Up @@ -147,9 +152,11 @@ class HLL::World {

# Adds a code reference to the root set of code refs.
method add_root_code_ref($code_ref, $past_block) {
pir::nqp_add_code_ref_to_sc__vPiP($!sc, $!num_code_refs, $code_ref);
my $code_ref_idx := $!num_code_refs;
$!num_code_refs := $!num_code_refs + 1;
$!code_ref_blocks.push($past_block);
pir::nqp_add_code_ref_to_sc__vPiP($!sc, $!num_code_refs, $code_ref);
$code_ref_idx
}

# Checks if we are in pre-compilation mode.
Expand Down
21 changes: 21 additions & 0 deletions src/ops/nqp.ops
Expand Up @@ -1447,6 +1447,27 @@ inline op nqp_get_sc_object(out PMC, in STR, in INT) :base_core {
$2);
}


/*

=item nqp_get_sc_code_ref()

Fetches the code ref from the serialization context keyed by handle and index.

=cut

*/
inline op nqp_get_sc_code_ref(out PMC, in STR, in INT) :base_core {
PMC *sc = SC_get_sc(interp, $2);
if (!PMC_IS_NULL(sc))
$1 = SC_get_code(interp, sc, $3);
else
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Cannot fetch code ref from non-existent serialization context %Ss",
$2);
}


/*

=item nqp_get_sc()
Expand Down

0 comments on commit 6291382

Please sign in to comment.