Skip to content

Commit

Permalink
Make get_iter overridable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed May 25, 2011
1 parent 2ca4db0 commit 05bf809
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/pmc/sixmodelobject.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,26 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
else
return SUPER(next);
}

VTABLE PMC * get_iter() {
PMC **vt = STABLE(SELF)->parrot_vtable_mapping;
ParrotVtableHandlerSlot *vth = STABLE(SELF)->parrot_vtable_handler_mapping;
PMC *meth;
if (vt && !PMC_IS_NULL(meth = vt[PARROT_VTABLE_SLOT_GET_ITER])) {
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, SELF);
Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
cappy = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
return VTABLE_get_pmc_keyed_int(interp, cappy, 0);
}
else if (vth && vth[PARROT_VTABLE_SLOT_GET_ITER].class_handle) {
PMC *val = VTABLE_get_attr_keyed(interp, SELF, vth[PARROT_VTABLE_SLOT_GET_ITER].class_handle,
vth[PARROT_VTABLE_SLOT_GET_ITER].att_name);
return VTABLE_get_iter(interp, val);
}
else
return SUPER();
}
}

2 comments on commit 05bf809

@leto
Copy link
Contributor

@leto leto commented on 05bf809 May 26, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you trying to save memory by storing various different kinds of PMC's in "cappy". What is a "cappy" ?

@jnthn
Copy link
Contributor Author

@jnthn jnthn commented on 05bf809 May 26, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly just a cute name for "capture", but it's also going to hold the return value... All that chunk of the code is doing is building a capture to pass, and that it will then obtain the return value from. Avoids using stuff like Parrot_ext_call, which gives a speed win (though the fact that 6model locates a v-table override way faster than Parrot's own object implementation does is probably even more of a speed win).

Please sign in to comment.