NAME ^

Parrot::Pmc2c - PMC to C Code Generation

SYNOPSIS ^

    use Parrot::Pmc2c;

DESCRIPTION ^

Parrot::Pmc2c (and the subclasses defined in this file) is used by tools/build/pmc2c.pl to generate C code from PMC files.

Functions ^

count_newlines($string)

Returns the number of newlines (\n) in $string.

dont_edit($pmcfile)

Returns the "DO NOT EDIT THIS FILE" warning text. $pmcfile is the name of the original source *.pmc file.

gen_ret($method, $body)

Generate the C code for a return statement, if the body is empty then make a cast if needed.

This method is imported by subclasses.

class_name($self, $class)

Returns the appropriate Parrot::Pmc2c subclass for the PMC ($self->{class}). $self is the hash reference passed to new(), and $class is Parrot::Pmc2c.

dynext_load_code($library_name, %classes)

$library_name is the name of the dynamic library to be created.

%classes is a map from the PMC names for which code is to be generated, to dump info (PMC metadata).

This function is exported.

Class Methods ^

new($self, $opt)

Returns $self as a new instance.

$self is a hash reference eval-ed from a *.dump file generated by tools/build/pmc2c.pl from a *.pmc file. It is bless-ed either into Parrot::Pmc2c::Standard, or into one of the other special PMCs: default, delegate, Null, Ref or SharedRef.

$opt is a hash reference.

Instance Methods ^

does_write($method)

Returns true if the vtable method $method writes our value.

line_directive($self,$line,$file)

Generates the C pre processor string for a #line directive, or an empty string if $self-{opt}{nolines}> is true.

line_directive_here($self,$output,$file)

Generates the C pre processor string for a #line directive to reset the compiler's line number to the next physical line in the output.

get_vtable_section()

Creates a hash of all the method names containing vtable section. Called from init().

get_vtable_attrs()

Creates a hash of all the methods names correspdoning to their attributes. Called from init()

make_constlike($class, $type, $is_variant)

Create a variant for Const or RO.

make_const($class)

If the PMC had its const_too flag set then this method is called in init() to to create the read-only set methods.

make_ro($class)

If the PMC doesn't have const_too set (FIXME?) then this method is called to create the read-only set methods and vtable variant.

init($class)

Initializes the instance. $class is its class.

decl($classname, $method, $for_header)

Returns the C code for the PMC method declaration. $for_header indicates whether the code is for a header or implementation file.

includes()

Returns the C #include for the header file of each of the PMC's superclasses.

full_arguments($args)

Prepends INTERP, SELF to $args.

proto($type,$parameters)

Determines the prototype (argument signature) for a method body (see src/call_list).

rewrite_nci_method($class, $method, $super, $super_table)

Rewrites the method body performing the various macro substitutions for nci method bodies (see tools/build/pmc2c.pl).

rewrite_vtable_method($class, $method, $super, $super_table)

Rewrites the method body performing the various macro substitutions for vtable method bodies (see tools/build/pmc2c.pl).

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

methods($line, $out_name)

Returns the C code for the vtable methods. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

lib_load_code()

Returns the C code for loading a library.

pmc_is_dynpmc

Determines if a given PMC type is dynamically loaded or not.

find_mmd_methods()

Returns three values:

The first is an arrayref of <[ mmd_number, left, right, implementation_func]> suitable for initializing the MMD list.

The second is a arrayref listing dynamic PMCs which will need to be looked up.

The third is a list of [index, dynamic PMC] pairs of right entries in the MMD table that will need to be resolved at runtime.

find_vtable_methods()

Returns an arrayref containing the vtable methods in the order they appear in the vtable.

vtable_decl($name)

Returns the C code for the declaration of a vtable temporary named $name with the functions for this class.

init_func()

Returns the C code for the PMC's initialization method, or an empty string if the PMC has a no_init flag.

gen_c($out_name)

Generates the C implementation file code for the PMC. $out_name is the name of the output file we are generating.

hdecls()

Returns the C code function declarations for all the methods for inclusion in the PMC's C header file.

TODO include MMD variants.

gen_h($out_name)

Generates the C header file code for the PMC. $out_name is the name of the output file we are generating.

c_code_coda()

Returns the Parrot C code coda (PDD07)

implements($method)

True if this class generates code for the method $method.

implements_vtable($method)

True if this class generates code for VTABLE method $method.

SUBCLASSES ^

Parrot::Pmc2c::Standard Instance Methods ^

Standard behavior.

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

Parrot::Pmc2c::Standard::Const Instance Methods ^

Returns the C code for the method body.

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

Parrot::Pmc2c::Standard::RO Instance Methods ^

Returns the C code for the method body.

implements($method)

Returns true if we implement $method. This is true in the special case of find_method and for all read-only methods.

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

Parrot::Pmc2c::Ref Instance Methods ^

implements($method)

Always true for vtables.

prederef($method)

Returns C code to be executed before executing a delegated method. Default versions always returns an empty string.

postderef($method)

Returns C code to be executed after executing a delegated method through this reference. Default version returns an empty string.

raw_deref($method)

Returns C code that can be used to access the underlying PMC in the delegated methods. Defualt is PMC_pmc_val(pmc)

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

Overrides the default implementation to direct all unknown methods to the thing referred to.

Parrot::Pmc2c::STMRef Instance Methods ^

Parrot::Pmc2c::SharedRef Instance Methods ^

prederef($method)

Returns code that will lock the PMC for calling the underlying implementation of $method.

postderef($method)

Returns the unlocking code.

Parrot::Pmc2c::default Instance Methods ^

implements($method)

Always true.

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

Overrides the default implementation to throw an execption for unknown methods.

Parrot::Pmc2c::Null Instance Methods ^

implements($method)

True for vtable methods.

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

The Null PMC throws an execption for all methods.

Parrot::Pmc2c::delegate Instance Methods ^

implements($method)

True for vtables.

trans($type)

Used in signature() to normalize argument types.

signature($params)

Returns the method signature for $params.

gen_ret($type)

Generate the C code for a return statement.

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

The delegate PMC redirects all methods to bytecode.

implements($method)

Always true for vtables.

body($method, $line, $out_name)

Returns the C code for the method body. $line is used to accumulate the number of lines, $out_name is the name of the output file we are generating.

Overrides the default implementation to direct all unknown methods to the PMC in the first attribute slot.


parrot