NAME ^

objects.c - Class and object

DESCRIPTION ^

Handles class and object manipulation.

Functions ^

static void create_deleg_pmc_vtable(Interp *, PMC *class, STRING *name)

Create a vtable that dispatches either to the contained PMC in the first attribute (deleg_pmc) or to an overridden method (delegate), depending on the existence of the method for this class.

const char *Parrot_MMD_method_name(Interp*, INTVAL)

Return the method name for the given MMD enum.

INTVAL Parrot_MMD_method_idx(Interp*, STRING *)

Return the MMD function number for method name or -1 on failure.

TODO allow dynamic expansion at runtime.

PMC *Parrot_single_subclass(Interp *ointerpreter, PMC *base_class, STRING *child_class_name)

Subclass a class. Single parent class, nice and straightforward. If child_class is NULL, this is an anonymous subclass we're creating, which happens commonly enough to warrant an actual single-subclass function.

void Parrot_new_class(Interp *interpreter, PMC *class, STRING *class_name)

Creates a new class, named class_name.

PMC *Parrot_class_lookup(Interp *interpreter, STRING *class_name)

Looks for the class named class_name and returns it if it exists. Otherwise it returns PMCNULL.

static void parrot_class_register(Interp *interpreter, STRING *class_name, PMC *new_class, PMC *mro)

This is the way to register a new Parrot class as an instantiable type. Doing this involves putting it in the class hash, setting its vtable so that the init method initializes objects of the class rather than the class itself, and adding it to the interpreter's base type table so you can create a new foo in PASM like this: new Px, foo.

void Parrot_instantiate_object(Interp *interpreter, PMC *object, PMC *init)

Creates a Parrot object. Takes a passed-in class PMC that has sufficient information to describe the layout of the object and, well, makes the darned object.

PMC *Parrot_add_parent(Interp *interpreter, PMC *new_base_class, PMC *existing_class)

Add the parent class to the current class' parent list. This also involved adding all the parent's parents, as well as all attributes of the parent classes that we're adding in.

PMC *Parrot_remove_parent(Interp *interpreter, PMC *removed_class, PMC *existing_class)

This currently does nothing but return NULL.

PMC *Parrot_multi_subclass(Interp *interpreter, PMC *base_class_array, STRING *child_class_name)

This currently does nothing but return NULL.

INTVAL Parrot_object_isa(Interp *interpreter, PMC *pmc, PMC *cl)

Return whether the object pmc is an instance of class cl.

PMC *Parrot_new_method_cache(Interp *interpreter)

This should create and return a new method cache PMC.

Currently it does nothing but return NULL.

PMC *Parrot_find_method_with_cache(Interp *interpreter, PMC *class, STRING *method_name)

Find a method PMC for a named method, given the class PMC, current interpreter, and name of the method.

This routine should use the current scope's method cache, if there is one. If not, it creates a new method cache. Or, rather, it will when we've got that bit working. For now it unconditionally goes and looks up the name in the global stash.

void Parrot_invalidate_method_cache(Interp *, STRING *class)

Clear method cache for the given class. If class is NULL caches for all classes are invalidated.

void Parrot_note_method_offset(Interp *interpreter, UINTVAL offset, PMC *method)

Notes where in the hierarchy we just found a method. Used so that we can do a next and continue the search through the hierarchy for the next instance of this method.

*/ void Parrot_note_method_offset(Interp* interpreter, UINTVAL offset, PMC *method) { interpreter->ctx.current_class_offset = offset; }

/*

INTVAL Parrot_add_attribute(Interp *interpreter, PMC *class, STRING *attr)

Adds the attribute attr to the class.

PMC *Parrot_get_attrib_by_num(Interp *interpreter, PMC *object, INTVAL attrib)

Returns attribute number attrib from object. Presumably the code is asking for the correct attribute number.

PMC *Parrot_get_attrib_by_str(Interp *interpreter, PMC *object, STRING *attr)

Returns attribute with full qualified name attr from object.

PMC *Parrot_set_attrib_by_num(Interp *interpreter, PMC *object, INTVAL attrib, PMC *value)

Set attribute number attrib from object to value. Presumably the code is asking for the correct attribute number.

PMC *Parrot_set_attrib_by_str(Interp *interpreter, PMC *object, STRING *attr, PMC *value)

Sets attribute with full qualified name attr from object to value.

PMC *Parrot_find_class_constructor(Interp *interpreter, STRING *class, INTVAL classtoken)

Find and return the constructor method PMC for the named sub. The classtoken is an identifier for the class used for fast lookup, or 0 if you don't have an identifier token. Which, as they're currently undefined, is pretty likely

SEE ALSO ^

include/parrot/objects.h, docs/pdds/pdd15_objects.pod.


parrot