NAME ^

src/pmc/parrotclass.pmc - Parrot Class

DESCRIPTION ^

The structure of a parrot class is reasonably straightforward. The PMC's cached integer value is the number of attribute slots that an object of this type requires. The data pointer holds a pointer to an array of PMCs. That array has:

PCD_PARENTS

An array of immediate parents.

PCD_CLASS_NAME

The class name PMC.

PCD_ATTRIBUTES

A hash, the keys are the classname/attrib name pair (separated by a NULL), while the value is the offset to the attribute.

PCD_CLASS_ATTRIBUTES

Array of attribute of this class.

PCD_OBJECT_VTABLE

Vtable PMC that holds the vtable for objects of this class.

Methods ^

void init()

Initializes the class flags.

void init_pmc(PMC *init)

The actual class creation code, called from newclass opcode. The init argument is not a PMC *but the classname STRING.

void destroy()

Free the class's attribute array, if any. Also used by ParrotObjects.

PMC *instantiate(PMC *init)

Creates a new PMC object of the type of the class and calls init().

INTVAL isa(STRING *classname)

Returns whether the class is or inherits from *classname.

PMC *get_class()

Return SELF.

STRING *name()

Return the classname.

void visit(visit_info *info)

This is used by freeze/thaw to visit the contents of the class.

*info is the visit info, (see include/parrot/pmc_freeze.h).

void freeze(visit_info *info)

Used to archive the class.

void thaw(visit_info *info)

Used to unarchive the class.

void thawfinish(visit_info *info)

Create the class from the thawed parents and attributes array.

METHOD PMC *get_parents()

Returns the array of parents for this class.


parrot