<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Parrot - Subroutine</title> <link rel="stylesheet" type="text/css" href="../../../resources/parrot.css" media="all"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <div id="wrapper"> <div id="header"> <a href="http://www.parrot.org"> <img border=0 src="../../../resources/parrot_logo.png" id="logo" alt="parrot"> </a> </div> <!-- "header" --> <div id="divider"></div> <div id="mainbody"> <div id="breadcrumb"> <a href="../../../html/index.html">Home</a> » <a href="../../../html/pmc.html">PMCs</a> » Subroutine </div> <h1><a name="NAME" >NAME</a></h1> <p>src/pmc/sub.pmc - Subroutine</p> <h1><a name="DESCRIPTION" >DESCRIPTION</a></h1> <p>These are the vtable functions for the Sub (subroutine) base class</p> <h2><a name="Functions" >Functions</a></h2> <dl> <dt><a name="static_void_print_sub_name(PARROT_INTERP,_PMC_*sub)" ><b><code>static void print_sub_name(PARROT_INTERP, PMC *sub)</b></code></a></dt> static function to print the name of the sub (for tracing/debugging) <dt><a name="void_init()" ><b><code>void init()</b></code></a></dt> Initializes the subroutine. <dt><a name="void_init_pmc()" ><b><code>void init_pmc()</b></code></a></dt> Initializes the "detached" subroutine from passed Hash. "Detached" means that surboutine is fully constructed but not attached to interpreter. <dt><a name="void_destroy()" ><b><code>void destroy()</b></code></a></dt> Destroys the subroutine. <dt><a name="STRING_*get_string()" ><b><code>STRING *get_string()</b></code></a></dt> Returns the name of the subroutine. <dt><a name="void_set_string_native(STRING_*subname)" ><b><code>void set_string_native(STRING *subname)</b></code></a></dt> Sets the name of the subroutine. <dt><a name="void_set_pointer(void_*value)" ><b><code>void set_pointer(void *value)</b></code></a></dt> Sets the pointer to the actual subroutine.*** Don't use that - use <code>.const 'Sub'</code> in PIR instead *** <dt><a name="void_*get_pointer()" ><b><code>void *get_pointer()</b></code></a></dt> Returns the address of the actual subroutine. <dt><a name="INTVAL_get_integer_keyed(PMC_*key)" ><b><code>INTVAL get_integer_keyed(PMC *key)</b></code></a></dt> <i>This just unconditionally returns the start of bytecode. It's wrong, wrong, wrong, *WRONG*. And there's no other good way, so it's here for now.</i> -DRS <dt><a name="INTVAL_defined()" ><b><code>INTVAL defined()</b></code></a></dt> <dt><a name="INTVAL_get_bool()" ><b><code>INTVAL get_bool()</b></code></a></dt> Returns True. <dt><a name="opcode_t_*invoke(void_*next)" ><b><code>opcode_t *invoke(void *next)</b></code></a></dt> Invokes the subroutine. <dt><a name="PMC_*clone()" ><b><code>PMC *clone()</b></code></a></dt> Creates and returns a clone of the subroutine. <dt><a name="void_assign_pmc(PMC_*other)" ><b><code>void assign_pmc(PMC *other)</b></code></a></dt> Set SELF to the data in other. <dt><a name="void_mark()" ><b><code>void mark()</b></code></a></dt> Marks the sub as live. <dt><a name="INTVAL_is_equal(PMC_*value)" ><b><code>INTVAL is_equal(PMC *value)</b></code></a></dt> Returns whether the two subroutines are equal. <dt><a name="void_visit(PMC_*info)" ><b><code>void visit(PMC *info)</b></code></a></dt> This is used by freeze/thaw to visit the contents of the sub. <dt><a name="void_freeze(PMC_*info)" ><b><code>void freeze(PMC *info)</b></code></a></dt> Archives the subroutine. <dt><a name="void_thaw(PMC_*info)" ><b><code>void thaw(PMC *info)</b></code></a></dt> Unarchives the subroutine. <dt><a name="PMC_*inspect()" ><b><code>PMC *inspect()</b></code></a></dt> Returns the full set of meta-data about the sub. <dt><a name="PMC_*inspect_str(STRING_*what)" ><b><code>PMC *inspect_str(STRING *what)</b></code></a></dt> Returns the specified item of metadata about the sub. Allowable values are: <dl> <dt><a name="pos_required" >pos_required</a></dt> The number of required positional arguments <dt><a name="pos_optional" >pos_optional</a></dt> The number of optional positional arguments <dt><a name="named_required" >named_required</a></dt> The number of required named arguments <dt><a name="named_optional" >named_optional</a></dt> The number of optional named arguments <dt><a name="pos_slurpy" >pos_slurpy</a></dt> 1 if it takes slurpy positional arguments, 0 if not <dt><a name="named_slurpy" >named_slurpy</a></dt> 1 if it takes slurpy named arguments, 0 if not</dl> </dl> <h2><a name="METHODS" >METHODS</a></h2> <dl> <dt><a name="INTVAL_start_offs()" ><b><code>INTVAL start_offs()</b></code></a></dt> Returns the start offset of the Sub. <dt><a name="INTVAL_end_offs()" ><b><code>INTVAL end_offs()</b></code></a></dt> Returns the end offset of the Sub. <dt><a name="PMC_*get_namespace()" ><b><code>PMC *get_namespace()</b></code></a></dt> Returns the namespace PMC, where the Sub is defined.TODO return <code>namespace_stash</code> instead. <dt><a name="INTVAL___get_regs_used(char_*kind)" ><b><code>INTVAL __get_regs_used(char *kind)</b></code></a></dt> Returns the number of used registers for register kinds "I", "S", "P", "N". <dt><a name="PMC_*get_lexinfo()" ><b><code>PMC *get_lexinfo()</b></code></a></dt> Returns the LexInfo PMC, if any or a Null PMC. <dt><a name="PMC_*get_multisig()" ><b><code>PMC *get_multisig()</b></code></a></dt> Returns the MMD signature PMC, if any, or a Null PMC. <dt><a name="PMC_*get_outer()" ><b><code>PMC *get_outer()</b></code></a></dt> Gets the sub that is the outer of this one, if any, or a Null PMC. <dt><a name="void_set_outer(PMC_*outer)" ><b><code>void set_outer(PMC *outer)</b></code></a></dt> Sets the sub that is the outer of this one. <dt><a name="void_set_outer_ctx(PMC_*outer_ctx)" ><b><code>void set_outer_ctx(PMC *outer_ctx)</b></code></a></dt> Set the outer context to be used on the next invocation of this sub. <dt><a name="INTVAL_arity()" ><b><code>INTVAL arity()</b></code></a></dt> Returns the arity of the Sub (the number of arguments, excluding optional and slurpy arguments). <dt><a name="INTVAL_comp_flags()" ><b><code>INTVAL comp_flags()</b></code></a></dt> <dt><a name="INTVAL_pf_flags()" ><b><code>INTVAL pf_flags()</b></code></a></dt> (Experimental) Returns Sub flags.</dl> </div> <!-- "mainbody" --> <div id="divider"></div> <div id="footer"> Copyright © 2002-2011, Parrot Foundation. </div> </div> <!-- "wrapper" --> </body> </html>