NAME
Parrot::OpTrans - Transform Ops to C Code
DESCRIPTION
Parrot::OpTrans
is the abstract superclass for the Parrot op to C transforms.
Each transform contains various bits of information needed to generate the C code,
and creates a different type of run loop.
The methods defined here supply various default values and behaviour common to all transforms.
The subclass hierarchy is as follows:
OpTrans |_________________________ | | | C CGoto Compiled | | CPrederef | | | | | |_________| | | CSwitch CGP
Class Methods
new()
Returns a new instance.
Instance Methods
prefix()
Returns the default 'suffix()
Implemented in subclasses to return a suffix with which to individuate variable names. This default implementation returns an empty string.
defines()
Implemented in subclasses to return the C opsarraytype()
Returns the type for the array of opcodes. By default here it's an array core_type()
Implemented in subclasses to return the type of core created by the transform. This default implementation raises an exception indicating that the core type is missing. See the core_prefix()
Implemented in subclasses to return a short prefix indicating the core type used to individuate core function names.
run_core_func_decl($base)
Optionally implemented in subclasses to return the C code for the run core function declaration. ops_addr_decl($base_suffix)
Optionally implemented in subclasses to return the C code for the ops address declaration. run_core_func_decl($base)
Optionally implemented in subclasses to return the C code for the run core function declaration. run_core_func_start()
Implemented in subclasses, if run_core_after_addr_table($base_suffix)
Optionally implemented in subclasses to return the run core C code for section after the address table. run_core_finish($base)
Implemented in subclasses to return the C code following the run core function. init_func_init1($base)
Optionally implemented in subclasses to return the C code for the core's init function. init_set_dispatch($base_suffix)
Optionally implemented in subclasses to return the C code for initializing the dispatch mechanism within the core's init function.
Parrot_
' prefix.Used by Parrot::Op
's func_name()
to individuate op function names.
#define
macros required.
opcode_t
, but the prederef runops core uses an array of void*
to do its clever tricks.
Parrot_Run_core_t
enum
in include/parrot/interpreter.h for a list of the core types.
$base
is the name of the main ops file minus the .ops extension.
$base_suffix
is the name of the main ops file minus the .ops extension with suffix()
and an underscore appended.
$base
is the same as for run_core_func_decl()
.
run_core_func_decl()
is implemented, to return the C code prior to the run core function.
$base_suffix
is the same as for ops_addr_decl()
.
$base
is the same as for run_core_func_decl()
.
$base
is the same as for run_core_func_decl()
.
$base_suffix
is the same as for ops_addr_decl()
.Macro Substitutions
The following methods are called by Parrot::OpFile
to perform ops file macro substitutions.
access_arg($type, $value, $op)
Implemented in subclasses to return the C code for the specified op argument type and value. gen_goto($where)
The various restart_address($address)
Implemented in subclasses to return the C code for restart_offset($offset)
Implemented in subclasses to return the C code for goto_address($address)
Transforms the goto_offset($offset)
Transforms the goto_pop()
Transforms the expr_offset($offset)
Implemented in subclasses to return the C code for expr_address($address)
Implemented in subclasses to return the C code for
$op
is an instance of Parrot::Op
.
goto_X
methods below call this method with the return value of an expr_X
method (implemented in subclass).
restart ADDRESS($address)
.
restart OFFSET($offset)
.
goto ADDRESS($address)
macro in an ops file into the relevant C code.
goto OFFSET($offset)
macro in an ops file into the relevant C code.
goto POP($address)
macro in an ops file into the relevant C code.
OFFSET($offset)
. Called by goto_offset()
.
ADDRESS($address)
. Called by goto_address()
.