NAME

pmc.ops - PMC Opcodes

DESCRIPTION

Operations that deal with PMCs, including creation and destruction, manipulation, and introspection.

When making changes to any ops file, run make bootstrap-ops to regenerate all generated ops files.

Creation and Types

These operations are used to create PMCs and examine type information.

new(out PMC, in STR)
new(out PMC, in STR, in PMC)
new(out PMC, in PMC)
new(out PMC, in PMC, in PMC)
Instantiate a new object from a string PMC or key name, or from a class object. For strings and keys, first check the namespace for a class object, then fall back to the type ID if no class object is stored in the namespace.
  new $P0, 'ResizableBooleanArray'
Optionally a PMC may be passed to the constructor. It's up to the class what to do with the initializer. See PDD17 and the init_pmc function for more.
root_new(out PMC, in PMC)
root_new(out PMC, in PMC, in PMC)
Instantiate a new object from a key name relative to the root namespace.
  root_new $P0, ['parrot';'ResizableBooleanArray']
Optionally a PMC may be passed to the constructor. It's up to the class what to do with the initializer.
typeof(out STR, invar PMC)
typeof(out PMC, invar PMC)
Return the type of PMC in $2.
get_repr(out STR, invar PMC)
Set $1 to a string representation of $2

Basic Operations

A few simple and common PMC operations.

find_method(out PMC, invar PMC, in STR)
Looks up method $3 in $2's vtable, placing the corresponding method PMC in $1.
defined(out INT, invar PMC)
defined(out INT, invar PMC, in INTKEY)
defined(out INT, invar PMC, in KEY)
Test PMC for definedness.
exists(out INT, invar PMC, in INTKEY)
exists(out INT, invar PMC, in KEY)
Tests whether KEY or INTKEY exists in the aggregate PMC. Places the answer in INT.
delete(invar PMC, in KEY)
delete(invar PMC, in INTKEY)
Delete the specified entry $2 from aggregate $1.
elements(out INT, invar PMC)
Returns the number of items in aggregate $2

Fast access ops

The fast access ops are shortcuts to common operations implemented in var PMCs.

push(invar PMC, in INT)
push(invar PMC, in NUM)
push(invar PMC, in STR)
push(invar PMC, invar PMC)
Push $2 onto the end of the aggregate PMC $1, if that operation is defined.
pop(out INT, invar PMC)
pop(out NUM, invar PMC)
pop(out STR, invar PMC)
pop(out PMC, invar PMC)
Pop off last entry in the aggregate $2, placing the result in $1.
unshift(invar PMC, in INT)
unshift(invar PMC, in NUM)
unshift(invar PMC, in STR)
unshift(invar PMC, invar PMC)
Unshift $2 onto the front of the aggregate PMC $1.
shift(out INT, invar PMC)
shift(out NUM, invar PMC)
shift(out STR, invar PMC)
shift(out PMC, invar PMC)
Shift off the first entry in the aggregate $2 and places it in $1.
splice(invar PMC, invar PMC, in INT, in INT)
Replace $4 values at offset $3 in aggregate $1 with the PMCs in aggregate $2. The values are put into the aggregate by a shallow copy. If the values would be reused, they have to be cloned.

Properties

Ops to deal with PMC properties.

setprop(invar PMC, in STR, invar PMC)
Set property $2 to value $3 for PMC $1.
getprop(out PMC, in STR, invar PMC)
Get property $2 of PMC $3 and put it in $1.
delprop(invar PMC, in STR)
Delete property $2 from PMC $1.
prophash(out PMC, invar PMC)
Get a hash for the properties invar PMC $2 and put it in $1. If the property hash doesn't exist, the Null PMC is returned.

Freeze, thaw and friends

Ops to PMC freeze, thaw.

freeze(out STR, invar PMC)
Set $1 to the frozen image of $2.
thaw(out PMC, in STR)
Set $1 to a newly created PMC from the image $2.

Vtable MMD manipulation functions

These functions manipulate the vtable MMD function table.

These functions allow bytecode to register subs or methods and query which sub or method would get called for a particular vtable operation. This way you're not required to drop to C to register a new method variant for addition or subtraction, or one of the other binary MMD operations.

add_multi(in STR, in STR, invar PMC)
Register method $3 as the MMD method for the sub named $1 with signature $2.
find_multi(out PMC, in STR, in STR)
Set $1 to the sub that would be called for sub named $2 with signature $3.

Misc PMC related ops

register(invar PMC)
Add a reference of PMC $1 to the interpreter's root set of PMCs. This is needed for extensions to make sure that the PMC is properly marked during GC, if that PMC is not known to Parrot's core elsewhere.A PMC can be registered multiple times. If it's unregistered and the registration count reaches zero, it will be destroyed during the next GC run.
unregister(invar PMC)
Remove one reference of $1.
box(out PMC, in INT)
box(out PMC, in NUM)
box(out PMC, in STR)
Create a HLL-mapped PMC containing the provided primitive.
iter(out PMC, invar PMC)
Return a new Iterator PMC $1 for aggregate $2.
morph(invar PMC, in PMC)
Have $1 turn itself into a PMC of type $2.

COPYRIGHT

Copyright (C) 2001-2010, Parrot Foundation.

LICENSE

This program is free software. It is subject to the same license as the Parrot interpreter itself.