NAME ^

pmc.ops - PMC Operations

DESCRIPTION ^

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

Creation and Types ^

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

new(out PMC, in INT)

new(out PMC, inconst STR)

new(out PMC, in INT, in PMC)

Create a new PMC of class $2; look in core_pmcs.h for the base vtable types. The assembler allows you to specify PMCs by type name as well as by integer - you should do this for compatibility, to avoid problems if the base types get reassigned. For example:

  new P0, .PerlScalar
Optionally a PMC may be passed to the constructor. It's up to the class what to do with the intializer. s. PDD02 for more.

new(out PMC, in INT, in PMC, in PMC)

Like above. The fourth argument is a property hash - it isn't copied in, only referenced. The initializer may be NULL.

new(out PMC, in INT, in STR)

Create a new PMC of the type $2 according to the PMCs string representation in $3. See also instantiate for a more general form.

instantiate(out PMC)

Create a new PMC of the type of class REG_PMC(2). This is a classmethod. Arguments are passed according to the calling conventions in docs/pdds/pdd03_calling_conventions.pod. See also the getclass opcode to get a class PMC.

typeof(out STR, in PMC)

typeof(out INT, in PMC)

Return the type of PMC in $2.

typeof(out INT, in PMC, in KEY)

typeof(out INT, in PMC, in INTKEY)

Return the type of the entry in aggregate PMC in $2 at key $3.

typeof(out STR, in INT)

Return the (native) Parrot type of datatype $2.

find_type(out INT, in STR)

Find the PMC type or Parrot datatype by name.

valid_type(out INT, in INT)

Check if the PMC type or Parrot datatype $2 is valid.

get_repr(out STR, in PMC)

Set $1 to a string representation of $2

Basic Operations ^

A few simple and common PMC operations.

find_method(out PMC, in PMC, in STR)

Looks up method $3 in $2's vtable, placing the corresponding method PMC in $1.

defined(out INT, in PMC)

defined(out INT, in PMC, in INTKEY)

defined(out INT, in PMC, in KEY)

Test for PMC definedness.

exists(out INT, in PMC, in INTKEY)

exists(out INT, in PMC, in KEY)

Test for key existence.

delete(in PMC, in KEY)

delete(in PMC, in INTKEY)

Delete the specified entry $2 from aggregate $1.

elements(out INT, in PMC)

Returns the number of items in aggregate $2

Fast access ops ^

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

push(in PMC, in INT)

push(in PMC, in NUM)

push(in PMC, in STR)

push(in PMC, in PMC)

Push $2 onto the end of the aggregate PMC $1, if that operation is defined.

pop(out INT, in PMC)

pop(out NUM, in PMC)

pop(out STR, in PMC)

pop(out PMC, in PMC)

Pop off last entry in the aggregate $2, placing the result in $1.

unshift(in PMC, in INT)

unshift(in PMC, in NUM)

unshift(in PMC, in STR)

unshift(in PMC, in PMC)

Unshift $2 onto the end of the aggregate PMC $1, if that operation is defined.

shift(out INT, in PMC)

shift(out NUM, in PMC)

shift(out STR, in PMC)

shift(out PMC, in PMC)

Shift off last entry in the aggregate $2, placing the result in $1.

Properties ^

Ops to deal with PMC properties.

setprop(in PMC, in STR, in PMC)

Set property $2 to value $3 for PMC $1.

getprop(out PMC, in STR, in PMC)

Get property $2 of PMC $3 and put it in $1.

delprop(in PMC, in STR)

Delete property $2 from PMC $1.

prophash(out PMC, in PMC)

Get a hash for the properties in PMC $2 and put it in $1.

Freeze, thaw and friends ^

Ops to PMC freeze, thaw.

freeze(out STR, in 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.

mmdvtregister(in INT, in INT, in INT, in PMC)

Register method $4 as the MMD method for vtable entry $1 for classes $2 and $3.

mmdvtfind(out PMC, in INT, in INT, in INT)

Find the sub that would be called for vtable entry $2 for types $3 and $4.

Misc PMC related ops ^

register(in 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 DOD, 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 DOD run.

unregister(in PMC)

Remove one reference of $1.

hash(out INT, in PMC)

Set $1 to the hash value of $2.

get_mro(out PMC, in PMC)

Set $1 to the mro array of the PMC $2. Please note that this is a direct reference so messing with it can do harm to the method lookup.

COPYRIGHT ^

Copyright (C) 2001-2004 The Perl Foundation. All rights reserved.

LICENSE ^

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


parrot