Permalink
Browse files

Implement the pop and shift VTABLEs in sixmodelobject.pmc.

  • Loading branch information...
arnsholt committed Mar 14, 2013
1 parent 91b03ba commit fb2a2fdb025f2c4383c1130280db5817c286e09c
Showing with 52 additions and 0 deletions.
  1. +52 −0 src/pmc/sixmodelobject.pmc
View
@@ -668,6 +668,32 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
OBJECT_BODY(decont), value);
}
+ VTABLE PMC *shift_pmc() {
+ PMC *decont = decontainerize(interp, SELF);
+ PMC **vt = STABLE(decont)->parrot_vtable_mapping;
+ PMC *meth;
+ AttributeIdentifier *vth = STABLE(decont)->parrot_vtable_handler_mapping;
+ if (vt && !PMC_IS_NULL(meth = vt[PARROT_VTABLE_SLOT_SHIFT_PMC])) {
+ 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, decont);
+ 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_SHIFT_PMC].class_handle) {
+ PMC *val = get_attr(interp, decont,
+ vth[PARROT_VTABLE_SLOT_SHIFT_PMC].class_handle,
+ vth[PARROT_VTABLE_SLOT_SHIFT_PMC].attr_name,
+ vth[PARROT_VTABLE_SLOT_SHIFT_PMC].hint);
+ return VTABLE_shift_pmc(interp, val);
+ }
+ else
+ return REPR(decont)->pos_funcs->shift_boxed(interp, STABLE(decont),
+ OBJECT_BODY(decont));
+ }
+
VTABLE void push_pmc(PMC *value) {
PMC *decont = decontainerize(interp, SELF);
PMC **vt = STABLE(decont)->parrot_vtable_mapping;
@@ -694,6 +720,32 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
OBJECT_BODY(decont), value);
}
+ VTABLE PMC *pop_pmc() {
+ PMC *decont = decontainerize(interp, SELF);
+ PMC **vt = STABLE(decont)->parrot_vtable_mapping;
+ PMC *meth;
+ AttributeIdentifier *vth = STABLE(decont)->parrot_vtable_handler_mapping;
+ if (vt && !PMC_IS_NULL(meth = vt[PARROT_VTABLE_SLOT_POP_PMC])) {
+ 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, decont);
+ 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_POP_PMC].class_handle) {
+ PMC *val = get_attr(interp, decont,
+ vth[PARROT_VTABLE_SLOT_POP_PMC].class_handle,
+ vth[PARROT_VTABLE_SLOT_POP_PMC].attr_name,
+ vth[PARROT_VTABLE_SLOT_POP_PMC].hint);
+ return VTABLE_pop_pmc(interp, val);
+ }
+ else
+ return REPR(decont)->pos_funcs->pop_boxed(interp, STABLE(decont),
+ OBJECT_BODY(decont));
+ }
+
VTABLE opcode_t *invoke(void *next) {
PMC *decont = decontainerize(interp, SELF);

0 comments on commit fb2a2fd

Please sign in to comment.