Matt S Trout > Rakudo-Star-2012.08_001 > rakudo-star/nqp/src/PAST/NQP.pir


Annotate this POD



A PAST::Want node selects one of its children based on the rtype (context) in which it's being evaluated. The first child is the default PAST to be evaluated. The subsequent children consist of (signature,past) pairs, the signature is a string of rtypes, and the subsequent past node is the one to be used if the caller's rtype matches any of the ones listed in the signature.

Exactly one of the node's children will be selected. It's okay for a single PAST node to appear within multiple children, as only one of the children will be selected.


Select a single past child based on rtype.

lexotic(PAST::Op node)

Establish a lexotic label (continuation) that can be invoked via a lexical lookup. The name attribute gives the name of the lexical to be used to hold the continuation. The result of this node is any argument passed when invoking the continuation, or the result of the last child node if the continuation isn't invoked.

hash(PAST::Op node)

Create a hash from the children. The type of hash constructed is determined by the returns attribute, which defaults to Hash if not set.

xor_nqp(PAST::Op node)

A short-circuiting exclusive-or operation. Essentially the same as xor in Parrot, but a named child of 'false' determines the value to be returned if two children are true.

nqpdebug(PAST::Op node)

Generate debugging code using nqpdebskip and nqpevent. The first child is evaluated as an integer flag, used to skip over the evaluation and logging of the second child.


Shim that lets us embed QAST:: nodes inside of a PAST tree.

map_add(mapid, [hash])

Add entries from any hash arguments to the pseudo-opcode table with identifier mapid. Slurpy named arguments are also added to the hash (after all hash arguments have been processed). The resulting pseudo-opcode table hash for mapid is returned.

The hash entries being added consist of pseudo-opcode (key, spec) pairs describing the pseudo-opcode name and node type to be constructed. If spec is a plain string, it's assumed to be a Parrot pirop opcode name. (A future version may allow strings of the form 'mapid::opcode' to reference an entry of another map table.)

If spec is a hash, it contains attributes used to build a PAST node. For example, the following pseudo-code would cause the 'ifelse' pseudo-op in the 'nqp' mapping space to to translate to a PAST::Op node with 'pasttype' set to 'if':

    $x := hash( 'WHAT' => PAST::Op, 'pasttype'=>'if' );
    PAST::Node.map_add('nqp', 'ifelse' => $x );

The 'WHAT' entry of such a hash defaults to PAST::Op if not specified.

map_node([args], 'map'=>mapid, 'op'=>opname, [options])

Create a node based on the mapping specification for opname from the pseudo-op mapping table given by mapid. The args and options are combined with the mapping table entry to produce the node to be returned.

syntax highlighting: