Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (44 sloc) 1.86 kb
/* This extends the Parrot Sub PMC to add various pieces needed for
* multiple dispatch. */
#include "pmc_sub.h"
pmclass DispatcherSub extends Sub auto_attrs dynpmc group nqp {
ATTR PMC *dispatchees; /* Used if this code object is a dispatcher. */
ATTR PMC *dispatch_cache; /* Holds a (multi-)dispatch cache if needed. */
VTABLE void init() {
SET_ATTR_dispatchees(interp, SELF, PMCNULL);
SET_ATTR_dispatch_cache(interp, SELF, PMCNULL);
VTABLE void mark() {
PMC *dispatchees, *dispatch_cache;
GET_ATTR_dispatchees(interp, SELF, dispatchees);
Parrot_gc_mark_PMC_alive(INTERP, dispatchees);
GET_ATTR_dispatch_cache(interp, SELF, dispatch_cache);
Parrot_gc_mark_PMC_alive(INTERP, dispatch_cache);
VTABLE PMC * clone() {
PMC *dispatchees, *dispatch_cache;
PMC *cloned = SUPER();
GET_ATTR_dispatchees(interp, SELF, dispatchees);
SET_ATTR_dispatchees(interp, cloned, dispatchees);
return cloned;
VTABLE void assign_pmc(PMC *other) {
/* It's OK to assign another DispatcherSub or alternatively to
* assign a Parrot Sub (our immediate parent). */
if (other->vtable->base_type == SELF->vtable->base_type ||
other->vtable->base_type == enum_class_Sub) {
Parrot_Sub_attributes *my_sub;
Parrot_Sub_attributes *other_sub;
PMC_get_sub(INTERP, SELF, my_sub);
PMC_get_sub(INTERP, other, other_sub);
/* copy the sub struct */
memmove(my_sub, other_sub, sizeof (Parrot_Sub_attributes));
Parrot_ex_throw_from_c_args(INTERP, NULL,
"Can't assign a non-Sub type to a Sub");
Jump to Line
Something went wrong with that request. Please try again.