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.
Parrot::Op
Parrot::OpsFile
op_info_t
struct
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.
RETURN()
Note that build_tools/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.
inline
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:
op The opcode itself, argument 0. 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.
new($code, $type, $name, $args, $argdirs, $labels, $flags)
Allocates a new bodyless op. A body must be provided eventually for the op to be usable.
$code is the integer identifier for the op.
$code
$type is the type of op (see the note on op types above).
$type
$name is the name of the op.
$name
$args is a reference to an array of argument type descriptors.
$args
$argdirs is a reference to an array of argument direction descriptors. Element x is the direction of argument $args->[x].
$argdirs
$args->[x]
$labels is a reference to an array of boolean values indicating whether each argument direction was prefixed by 'label'.
$labels
label
$flags is one or more (comma-separated) hints.
$flags
code()
Returns the op code.
type()
The type of the op, either 'inline' or 'function'.
name()
The (short or root) name of the op.
full_name()
For argumentless ops, it's the same as name(). For ops with arguments, an underscore followed by underscore-separated argument types are appended to the name.
func_name()
The same as full_name(), but with 'Parrot_' prefixed.
Parrot_
arg_types()
Returns the types of the op's arguments.
arg_type($index)
Returns the type of the op's argument at $index.
$index
arg_dirs()
Returns the directions of the op's arguments.
labels()
Returns the labels.
flags(@flags)
flags()
Sets/gets the op's flags.
arg_dir($index)
Returns the direction of the op's argument at $index.
body($body)
body()
Sets/gets the op's code body.
jump($jump)
jump()
Sets/gets a string containing one or more op_jump_t values joined with | (see include/parrot/op.h). This indicates if and how an op may jump.
op_jump_t
|
full_body()
For manual ops, 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.
goto NEXT()
rewrite_body($body, $trans)
Performs the various macro substitutions using the specified transform, correctly handling nested substitions, and repeating over the whole string until no more substitutions can be made.
VTABLE_ macros are enforced by converting x->vtable->method to VTABLE_method.
VTABLE_
x->vtable->method
VTABLE_method
source($trans)
Returns the full_body() of the op with substitutions made by $trans (a subclass of Parrot::OpTrans).
$trans
Parrot::OpTrans
size()
Returns the op's number of arguments. Note that this also includes the op itself as one argument.
Author: Gregor N. Purdy <gregor@focusresearch.com>
To install Ruby, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ruby
CPAN shell
perl -MCPAN -e shell install Ruby
For more information on module installation, please visit the detailed CPAN module installation guide.