parrotcode: Parrot Operation | |
Contents | Perl Modules |
Parrot::Op - Parrot Operation
use Parrot::Op;
Parrot::Op
represents a Parrot operation (op, for short), as read from an ops file via Parrot::OpsFile
, or perhaps even generated by some other means. It is the Perl equivalent of the op_info_t
C struct
defined in include/parrot/op.h.
Ops are either auto or manual. Manual ops are responsible for having explicit next-op RETURN()
statements, while auto ops can count on an automatically generated next-op to be appended to the op body.
Note that tools/build/ops2c.pl supplies either 'inline' or 'function' as the op's type, depending on whether the inline
keyword is present in the op definition. This has the effect of causing all ops to be considered manual.
Note that argument 0 is considered to be the op itself, with arguments 1..9 being the arguments passed to the op.
Op argument direction and type are represented by short one or two letter descriptors.
Op Direction:
i The argument is incoming
o The argument is outgoing
io The argument is both incoming and outgoing
Op Type:
i The argument is an integer register index.
n The argument is a number register index.
p The argument is a PMC register index.
s The argument is a string register index.
ic The argument is an integer constant (in-line).
nc The argument is a number constant index.
pc The argument is a PMC constant index.
sc The argument is a string constant index.
kc The argument is a key constant index.
ki The argument is a key integer register index.
kic The argument is a key integer constant (in-line).
new($code, $type, $name, $args, $argdirs, $labels, $flags)
$code
is the integer identifier for the op.$type
is the type of op (see the note on op types above).$name
is the name of the op.$args
is a reference to an array of argument type descriptors.$argdirs
is a reference to an array of argument direction descriptors. Element x is the direction of argument $args->[x]
.$labels
is a reference to an array of boolean values indicating whether each argument direction was prefixed by 'label
'.$flags
is one or more (comma-separated) hints.code()
type()
name()
full_name()
name()
. For ops with arguments, an underscore followed by underscore-separated argument types are appended to the name.func_name()
full_name()
, but with 'Parrot_
' prefixed.arg_types()
arg_type($index)
$index
.arg_dirs()
labels()
flags(@flags)
flags()
arg_dir($index)
$index
.body($body)
body()
jump($jump)
jump()
op_jump_t
values joined with |
(see include/parrot/op.h). This indicates if and how an op may jump.full_body()
full_body()
is the same as body()
. For auto ops this method adds a final goto NEXT()
line to the code to represent the auto-computed return value. See the note on op types above.rewrite_body($body, $trans)
VTABLE_
macros are enforced by converting x->vtable->method
to VTABLE_method
.source($trans)
full_body()
of the op with substitutions made by $trans
(a subclass of Parrot::OpTrans
).size()
Author: Gregor N. Purdy <gregor@focusresearch.com>
|