Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Have deserialization handle republication of Parrot v-table handlers,…
… so we catch mixin cases also. With this, CORE.setting now seems to load...but then nothing happens afterwards. :/
  • Loading branch information
jnthn committed Feb 28, 2012
1 parent 06304cb commit 1a15a9a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
23 changes: 23 additions & 0 deletions src/6model/serialization.c
Expand Up @@ -1597,6 +1597,19 @@ void repossess(PARROT_INTERP, SerializationReader *reader, INTVAL i) {
}
}

/* Handles doing Parrot v-table publication (we don't serialize that data). */
static void do_parrot_vtable_fixup_if_needed(PARROT_INTERP, PMC *obj, STRING *meth_name) {
PMC *meth = VTABLE_find_method(interp, STABLE(obj)->HOW, meth_name);
if (!PMC_IS_NULL(meth)) {
PMC *old_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC *cappy = Parrot_pmc_new(interp, enum_class_CallContext);
VTABLE_push_pmc(interp, cappy, STABLE(obj)->HOW);
VTABLE_push_pmc(interp, cappy, obj);
Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
}
}

/* Takes serialized data, an empty SerializationContext to deserialize it into,
* a strings heap and the set of static code refs for the compilation unit.
* Deserializes the data into the required objects and STables. */
Expand Down Expand Up @@ -1689,6 +1702,16 @@ void Serialization_deserialize(PARROT_INTERP, PMC *sc, PMC *string_heap, PMC *st
deserialize_object(interp, reader, i,
VTABLE_get_pmc_keyed_int(interp, objects, i));

/* Do any Parrot v-table publication. */
for (i = 0; i < reader->root.num_objects; i++) {
PMC *obj = VTABLE_get_pmc_keyed_int(interp, objects, i);
if (!IS_CONCRETE(obj)) {
do_parrot_vtable_fixup_if_needed(interp, obj, Parrot_str_new_constant(interp, "publish_parrot_vtable_mapping"));
do_parrot_vtable_fixup_if_needed(interp, obj, Parrot_str_new_constant(interp, "publish_parrot_vtablee_handler_mapping"));
do_parrot_vtable_fixup_if_needed(interp, obj, Parrot_str_new_constant(interp, "publish_parrot_vtable_handler_mapping"));
}
}

/* Re-enable GC. */
Parrot_unblock_GC_mark(interp);

Expand Down
22 changes: 1 addition & 21 deletions src/NQP/World.pm
Expand Up @@ -418,29 +418,9 @@ class NQP::World is HLL::World {
$obj.HOW.add_parrot_vtable_handler_mapping($obj, $name, $att_name);
}

# Composes the package, and stores an event for this action.
# Composes the package.
method pkg_compose($obj) {
# Compose.
$obj.HOW.compose($obj);

if self.is_precompilation_mode() {
# Make sure we fix up Parrot-specific vtable handling;
# we don't serialize this.
if pir::can__IPs($obj.HOW, 'publish_parrot_vtable_mapping') {
my $slot_past := self.get_slot_past_for_object($obj);
self.add_fixup_task(:deserialize_past(PAST::Stmts.new(
PAST::Op.new(
:pasttype('callmethod'), :name('publish_parrot_vtable_mapping'),
PAST::Op.new( :pirop('get_how PP'), $slot_past ),
$slot_past
),
PAST::Op.new(
:pasttype('callmethod'), :name('publish_parrot_vtablee_handler_mapping'),
PAST::Op.new( :pirop('get_how PP'), $slot_past ),
$slot_past
))));
}
}
}

# Runs a block at BEGIN time.
Expand Down

0 comments on commit 1a15a9a

Please sign in to comment.