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 existance of the method for this class.

PMC *Parrot_single_subclass(Parrot_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(Parrot_Interp interpreter, PMC *class, STRING *class_name)

Creates a new class, named class_name.

PMC *Parrot_class_lookup(Parrot_Interp interpreter, STRING *class_name)

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

INTVAL Parrot_class_register(Parrot_Interp interpreter, STRING *class_name, PMC *new_class)

This is the way to register a new Parrot class as an instantiatable 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(Parrot_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(Parrot_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(Parrot_Interp interpreter, PMC *removed_class, PMC *existing_class)

This currently does nothing but return NULL.

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

This currently does nothing but return NULL.

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

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

PMC *Parrot_new_method_cache(Parrot_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(Parrot_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_note_method_offset(Parrot_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(Parrot_Interp interpreter, UINTVAL offset, PMC *method) { interpreter->ctx.current_class_offset = offset; }

/*

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

Adds the attribute attr to the class.

PMC *Parrot_get_attrib_by_num(Parrot_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(Parrot_Interp interpreter, PMC *object, STRING *attr)

Returns attribute with full qualified name attr from object.

PMC *Parrot_set_attrib_by_num(Parrot_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(Parrot_Interp interpreter, PMC *object, STRING *attr, PMC *value)

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

PMC *Parrot_find_class_constructor(Parrot_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