The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Nodes

This file declares the different node-types that occur in the parse tree. These types may be generated from the parser output (see Tree.pm), or by the compiler itself during a pass.

sv_literal

Represents a scalar literal value.

type

The literal's type, either one of the scalar types, PerlHash for an anonymous hash reference, or PerlArray for an anonymous array reference.

lval

The thing's value. This is not the same as the code-generating val method. For scalar types, lval is a string; for reference types, a reference to the contents' parse tree.

variable

A variable.

type

Either one of the scalar types, PerlHash, or PerlArray.

global

True if the variable is global (currently unimplemented).

implicit

True for implicit block parameters, e.g. $^a.

topical

True for members of the current topic, e.g. $.foo.

name

The variable's name. For simple variables, this is the literal name, including sigil (e.g. $foo). For "complicated" variables, this is a reference to their parse tree (currently unimplemented).

Binop

A node type representing a binary infix operation. Note that comparison operators are not binary, since they can be chained. Both comma and semicolon are binary.

op

For simple operators, the operator name as a string. For hyper operators, a reference to a hype node.

l, r

The left and right operands of the operator.

hype

A "hyped" operator. Its single member, op is the normal operator that has been lifted. If it turns out that other things besides operators can be hyped, op may refer to more complex nodes.

apply_rhs

The right-hand side of an apply operation (e.g. the "foo()" in "$a.foo()").

prop

The function- or property-name being accessed (e.g. "foo").

subscripts

A reference to a list of subscripts, or an empty array if none are present. Subscripts may be either an indices node, as for variable subscripts, or "something else" representing a parameter list. This is kind of ugly, and may change once these things actually get implemented.

indices

A single subscript, e.g. [@xs].

type

The type of thing on which the subscript operates, either PerlHash or PerlArray.

indices

The parse tree for the subscript contents.

subscript_exp

An item and one or more indices.

thing

The expression or variable to be subscripted.

subscripts

A reference to an array of indices.

incr

An increment or decrement operator.

post

True if the operator is a postincrement.

op

The operator.

thing

The incremented expression.

prefix

A prefix operator. Many things are prefix operators: filetests (possibly combined), declared functions, and unary -, ~, \\, and !.

name

The operator name.

args

The argument tree.

context

A single context operator (eg the * in *@arr).

ctx

The operator.

thing

The operand.

pair

A pair (e.g. a => "pair").

l, r

The left and right operands of the pair constructor.

compare

A comparison sequence. Its single member, seq, is a reference to a list of operators and operands in left-to-right order. For example, 1 lt 3 lt "three" becomes [1, "lt", 3, "lt", "three"]

ternary

A ternary operation.

if

The test.

then

The "true" branch.

else

The "false" branch.

scope_class

Qualifiers that occur before the variables in a declaration.

scope

The variable scope, e.g. "my", "our", "temp".

class

The variable class, e.g. "int".

decl

A declaration of one or more variables, not including initializers.

qual

The variables' scope/class.

vars

The variables' names.

props

A list of properties (e.g. "is foo(42)").

property

A single variable, class, or function property.

name

The property name.

args

The argument list (for e.g. something(1, 2)).

but

A node representing a "but" clause, e.g. $foo = 23 but false but Inf.

thing

The exceptional thing.

buts

A reference to an array of exception clauses.

adverb

An adverbial modifier (i.e. ':').

thing

The left-hand side of the colon.

adv

The right-hand side.

signature

A sub parameter list (not argument list).

positional

A reference to an array of required positional parameters, or an empty array if none.

optional

A reference to an array of optional positional parameters, i.e. those occurring after the ';', or an empty array if none.

required_named

A reference to an array of required named parameters.

slurpy_array

The final "slurping" parameter, or undef if none present.

slurpy_named

The "slurping" parameter for named arguments, or undef if none present.

optional_named

A reference to an array of optional named parameters.

sigparam

A subroutine parameter.

type

The type of the parameter.

zone

Which zone the parameter is in -- positional, optional, named, etc.

var

The variable.

traits

Its traits.

init

An initializer expression, or undef if none.

Private variable: 'no_named' means that named arguments are not used. For the caller, this means that the extra hash containing named arguments is not passed. For the callee, this means that the extra hash is not expected, and therefore is not read off of the passed-in arguments. Both of these had better agree!

initializer

A parameter initializer (not an initializer in a variable declaration).

op

The initializing operator, probably =.

expr

The initialization expression.

sub_def

A subroutine definition or declaration. This is created for all of: method X ... sub X ... rule X ...

The sub_def contains only the name and properties; the signature and body are stored in a P6C::closure object.

qual

Sub scope. (my/our/...)

name
props

An array of subroutine properties, or an empty array if none.

closure

The closure associated with this name.

closure

A closure, which may be either an anonymous function or the parameters and body of a named subroutine -- or merely a bare block.

params

The subroutine parameter list, or undef if no parameter list was given. The appropriate implicit parameter list then depends on context.

rettype

The subroutine's return type.

block

The sequence of statements making up the closure body. This is a reference to an array of statements, or a single yadda node for ... definitions, or undef for a declaration.

bare

True only for bare blocks, eg $x = { print "hi!" } or just { print "hi!" }

Appears to be used only to determine that a particular block is an anonymous subroutine (Addcontext.pm's is_anon_sub() says that it is an anonymous subroutine unless it is marked noreturn, or it is a sub_def, or it's both a bare block and in a "last statement" context. Urk?)

is_rule

A boolean flag saying whether the closure is a rule (as opposed to a sub).

yadda

A node representing a ... statement. Its single member, msg, is either undef or an appropriate error message to be generated if the statement is reached.

guard

A guard (statement modifier?), e.g. the unless in die unless $foo.

name

The modifier name, either "if", "unless", "while", "until", or "for".

expr
test
directive

A "use", "package", or "module" directive

name

The directive name (e.g. "use").

thing

The directive's object (e.g. "perl" in "use perl").

args

Whatever else is on the directive line.

label

A statement label. It will appear before the labeled statement in a statement sequence.

loop

A loop(;;) { ... } statement.

init
test
incr

The initialization, test, and increment expressions in the loop header.

block

The block (sequence of statements, not closure) controlled by the loop.

label
name

The string name of the label.

class_def

A class definition

qual

Class scope.

name
props
block
Regexes or rules
P6C::ValueList

List operators and functions with named parameters currently receive their arguments in different formats -- the former as a tree of binary ',' ops, the latter as an array. This is a common class to do context handling for both.

P6C::Register

Gratuitous object? Not quite... It's a way of passing a temporary register in place of an unexpanded rvalue. Useful for e.g. autoincrement, where we have the register lying around.

NOTE: this would be a good place to take care of conversions between register types. Right now things are always passed in P regs, but we could do better by passing back a wrapped S, I, or N register, which would be promoted if necessary. On the other hand, we might do better using context to do this. Hopefully all will be clear once things get a bit more developed.