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 classes/pmc2c2.pl to generate C code from PMC files.
Functions
does_write($method, $section)
-
Returns whether a method writes.
count_newlines($string)
-
Returns the number of newlines (
\n
) in$string
. 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 tonew()
, and$class
isParrot::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 referenceeval
-ed from a *.dump file generated by classes/pmc2c.pl from a *.pmc file. It isbless
-ed either intoParrot::Pmc2c::::Standard
, or into one of the other special PMCs: default,delegate
,Null
,Ref
orSharedRef
.$opt
is a hash reference.
Instance Methods
get_vtable_section()
-
Creates a hash of all the method names containing vtable section. Called from
init()
. make_const($class)
-
If the PMC had its
const_too
flag set then this method is called ininit()
to to create the read-only set methods. init($class)
-
Initializes the instance.
$class
is its class. dont_edit($pmcfile)
-
Returns the "DO NOT EDIT THIS FILE" warning text.
$pmcfile
is the name of the original source *.pmc file. 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
. rewrite_method($class, $method, $super, $super_table)
-
Rewrites the method body performing the various macro subsitiutions for vtable method bodies (see classes/pmc2c.pl).
body($method)
-
Returns the C code for the method body.
methods($line)
-
Returns the C code for the vtable methods.
$line
is used to accumulate the number of lines. 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.
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($file)
-
Generates the C implementation file code for the PMC.
$file
is the name of the original source *.pmc file. 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($file)
-
Generates the C header file code for the PMC.
$file
is the name of the original source *.pmc file. implements($method)
-
True if this class generates code for
$method
.
SUBCLASSES
Parrot::Pmc2c::Standard Instance Methods
Standard behavior.
Parrot::Pmc2c::Standard::Const Instance Methods
Returns the C code for the method body.
Parrot::Pmc2c::Ref Instance Methods
implements($method)
-
Always true.
body($method, $line)
-
Returns the C code for the method body.
Overrides the default implementation to direct all unknown methods to the thing referred to.
Parrot::Pmc2c::SharedRef Instance Methods
SharedRef
is like Ref
but with locking.
implements($method)
-
Always true.
gen_ret($type)
-
Generate the C code for a
return
statement. body($method, $line)
-
Returns the C code for the method body.
Overrides the default implementation to perform locking.
Parrot::Pmc2c::default Instance Methods
implements($method)
-
Always true.
body($method, $line)
-
Returns the C code for the method body.
Overrides the default implementation to throw an execption for unknown methods.
Parrot::Pmc2c::Null Instance Methods
implements($method)
-
Always true.
body($method, $line)
-
Returns the C code for the method body.
The
Null
PMC throws an execption for all methods.
Parrot::Pmc2c::delegate Instance Methods
implements($method)
-
Always true.
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)
-
Returns the C code for the method body.
The
delegate
PMC redirects all methods to bytecode. implements($method)
-
Always true.
body($method, $line)
-
Returns the C code for the method body.
Overrides the default implementation to direct all unknown methods to the PMC in the first attribute slot.
Parrot::Pmc2c::Library
This class is a wrapper around a collection of PMCs linked in the same dynamic library. A degenerate case is having an unnamed library with just ne PMC, which is the case used by the Parrot core.
Parrot::Pmc2c::Library Instance Methods
new($opt, $vtable_dump, %pmcs)
-
$library = Parrot::Pmc2c::Library->new ( $options, # hash refernce, the same passet to other constructors $vtable_dump, # vtable.dump pmc1 => $pmc1_dump, pmc2 => $pmc2_dump, ... );
Creates a new library object. If the
$options
hash contains alibrary
key its value will be used for the library name. write_all_files()
-
Writes C and header files for all the PMCs in the library, plus <libname>.c and pmc_<libname>.h if his object represents a named library.
gen_h
-
Writes the header file for the library.
gen_c
-
Writes the C file for the library.
SEE ALSO
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1419:
Unterminated C<...> sequence