NAME ^

objects.c - Class and object

DESCRIPTION ^

Handles class and object manipulation.

Functions ^

INTVAL Parrot_get_vtable_index

Return index if name is a valid vtable slot name.

static PMC *find_vtable_meth_ns

Return Sub PMC if a method with the vtable name exists in ns

PMC *Parrot_find_vtable_meth

Given pmc, run through its mro looking for the meth vtable method. Return the vtable method PMC if found.

STRING *readable_name

Given a String or Key PMC return the STRING* representation

RT#45967 this function, key_set_to_string, and the key PMC get_repr should be consolidated

static void fail_if_exist

Throws an exception if a PMC or class with the same name already exists.

RT#45969 uses global class registry

static void rebuild_attrib_stuff

Take the class and completely rebuild the attribute stuff for it. Horribly destructive, and definitely not a good thing to do if there are instantiated objects for the class

static void create_deleg_pmc_vtable

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

Return the method name for the given MMD enum.

INTVAL Parrot_MMD_method_idx

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

RT#45973 allow dynamic expansion at runtime.

PMC *Parrot_single_subclass

Subclass a class. Single parent class, nice and straightforward. If child_class is NULL, this is an anonymous subclass we're creating, function.

void Parrot_new_class

Creates a new class, named class_name.

PMC *Parrot_class_lookup

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

PMC *Parrot_class_lookup_p

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

static INTVAL register_type

RT#48260: Not yet documented!!!

static void parrot_class_register

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.

static PMC *get_init_meth

RT#48260: Not yet documented!!!

static void do_initcall

RT#48260: Not yet documented!!!

void Parrot_instantiate_object_init

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

void Parrot_instantiate_object

RT#48260: Not yet documented!!!

static void instantiate_object

RT#48260: Not yet documented!!!

static PMC *not_empty

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.

The MRO (method resolution order) is the C3 algorithm used by Perl6 and Python (>= 2.3). See also: http://pugs.blogs.com/pugs/2005/07/day_165_r5671_j.html

static PMC *class_mro_merge

merge the list if lists

static PMC *create_class_mro

create C3 MRO

PMC *Parrot_remove_parent

This currently does nothing but return PMCNULL.

PMC *Parrot_multi_subclass

This currently does nothing but return PMCNULL.

INTVAL Parrot_object_isa

Returns whether the object pmc is an instance of class _class.

PMC *Parrot_new_method_cache

This should create and return a new method cache PMC.

Currently it does nothing but return PMCNULL.

void mark_object_cache

RT#48260: Not yet documented!!!

void init_object_cache

RT#48260: Not yet documented!!!

void destroy_object_cache

RT#48260: Not yet documented!!!

static void invalidate_type_caches

RT#48260: Not yet documented!!!

static void invalidate_all_caches

RT#48260: Not yet documented!!!

void Parrot_invalidate_method_cache

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

PMC *Parrot_find_method_direct

Find a method PMC for a named method, given the class PMC, current interpreter, and name of the method. Don't use a possible method cache.

PMC *Parrot_find_method_with_cache

Find a method PMC for a named method, given the class PMC, current interp, 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.

static void debug_trace_find_meth

RT#48260: Not yet documented!!!

static PMC *find_method_direct_1

RT#48260: Not yet documented!!!

void Parrot_note_method_offset

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.

INTVAL Parrot_add_attribute

Adds the attribute attr to the class.

   Life is ever so much easier if a class keeps its attributes at the
   end of the attribute array, since we don't have to insert and
   reorder attributes. Inserting's no big deal, especially since we're
   going to break horribly if you insert into a class that's been
   subclassed, but it'll do for now.
PMC *Parrot_get_attrib_by_num

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

static INTVAL attr_str_2_num

RT#48260: Not yet documented!!!

PMC *Parrot_get_attrib_by_str

Returns attribute with full qualified name attr from object.

void Parrot_set_attrib_by_num

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

void Parrot_set_attrib_by_str

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

INTVAL Parrot_class_offset

RT#48260: Not yet documented!!!

PMC *Parrot_find_class_constructor

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).

PMC *Parrot_find_class_destructor

RT#48260: Not yet documented!!!

PMC *Parrot_find_class_fallback

RT#48260: Not yet documented!!!

void Parrot_set_class_constructor

RT#48260: Not yet documented!!!

void Parrot_set_class_destructor

RT#48260: Not yet documented!!!

void Parrot_set_class_fallback

RT#48260: Not yet documented!!!

static PMC *C3_merge

RT#48260: Not yet documented!!!

PMC *Parrot_ComputeMRO_C3

Computes the C3 linearization for the given class.

void Parrot_ComposeRole

Used by the Class and Object PMCs internally to compose a role into either of them. The role parameter is the role that we are composing into the class or role. methods_hash is the hash of method names to invokable PMCs that contains the methods the class or role has. roles_list is the list of roles the the class or method does.

The role parameter is only dealt with by its external interface. Whether this routine is usable by any other object system implemented in Parrot very much depends on how closely the role composition semantics they want are to the default implementation.

SEE ALSO ^

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


parrot