objects.c - Class and object
Handles class and object manipulation.
Parrot_get_vtable_index
- Return index if
name
is a valid vtable slot name.
find_vtable_meth_ns
- Return Sub PMC if a method with the vtable name exists in ns
Parrot_find_vtable_meth
- Given pmc,
run through its mro looking for the meth vtable method.
Return the vtable method PMC if found.
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
fail_if_exist
- Throws an exception if a PMC or class with the same name already exists.
- RT#45969 uses global class registry
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.
Parrot_MMD_method_name
- Return the method name for the given MMD enum.
Parrot_MMD_method_idx
- Return the MMD function number for method name or -1 on failure.
- RT#45973 allow dynamic expansion at runtime.
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.
Parrot_new_class
- Creates a new class,
named
class_name
.
Parrot_class_lookup
- Looks for the class named
class_name
and returns it if it exists.
Otherwise it returns PMCNULL
.
Parrot_class_lookup_p
- Looks for the class named
class_name
and returns it if it exists.
Otherwise it returns PMCNULL
.
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
.
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.
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
Parrot_remove_parent
- This currently does nothing but return
PMCNULL
.
Parrot_multi_subclass
- This currently does nothing but return
PMCNULL
.
Parrot_object_isa
- Returns whether the object
pmc
is an instance of class _class
.
Parrot_new_method_cache
- This should create and return a new method cache PMC.
- Currently it does nothing but return
PMCNULL
.
Parrot_invalidate_method_cache
- Clear method cache for the given class.
If class is NULL,
caches for all classes are invalidated.
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.
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.
Parrot_note_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.
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.
Parrot_get_attrib_by_num
- Returns attribute number
attrib
from object
. Presumably the code is asking for the correct attribute number.
Parrot_get_attrib_by_str
- Returns attribute with full qualified name
attr
from object
.
Parrot_set_attrib_by_num
- Set attribute number
attrib
from object
to value
. Presumably the code is asking for the correct attribute number.
Parrot_set_attrib_by_str
- Sets attribute with full qualified name
attr
from object
to value
.
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).
Parrot_ComputeMRO_C3
- Computes the C3 linearization for the given class.
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.
include/parrot/objects.h, docs/pdds/pdd15_objects.pod.