FunctionNode
A JavaScript function declaration or expression. Node type is Token.FUNCTION.
FunctionDeclaration : function Identifier ( FormalParameterList? ) { FunctionBody }
FunctionExpression : function Identifier? ( FormalParameterList? ) { FunctionBody }JavaScript 1.8 also allows a "function closure" of the form function ([params]) Expression. Such a node has no body but does have an expression.
Types
Properties
The absolute document position, computed by adding this node's relative position to the relative positions of all its parents.
Base (starting) line number for this script or function. Setting it is a one-time operation and fails if the line number is already set.
The scopes whose parent is this scope, or null if there are none.
The innermost enclosing function, or null. The search begins with the parent.
Sets the function name and reparents it to this node. Null means an anonymous function.
The function type: statement, expression, or expression statement.
IR block for default parameter init in generators.
Comments on the same line as the statement, for example the trailing comment in if (x == 2) // note.
Rhino supports a nonstandard extension letting you write function a.b.c(arg) {...}, rewritten at codegen time to a.b.c = function(arg) {...}. When the parser sees an expression other than a simple Name where the function name belongs, it records that expression here. Enabled by the allowMemberExprAsFunctionName compiler option.
Number of parameters, counted as Token.LP symbols arrive.
End offset of the raw source. Only valid when rawSource is non-null.
Start offset of the raw source. Only valid when rawSource is non-null.
True when this function requires an Ecma-262 Activation object. The activation is expensive to create, so the interpreter uses a plain call frame when it can. A lexical closure is one of several situations that force one.
The URI, path or descriptive text naming the origin of this script's source.
A copy of the child list, with each child cast to an AstNode. Throws once the code generator has begun the tree transformation and non-AstNode children appear.
Every symbol in this script or function, in declaration order.
Insertion-ordered so that iteration follows declaration order.
The current script or function scope.
The node type, e.g. Token.NAME.
Functions
Adds a scope to the child list and sets the child's parent scope to this scope.
Adds a FunctionNode to the functions table for codegen. Does not set the parent of the node.
Called by IRFactory to add a RegExp to the regexp table.
Called by IRFactory to add a template literal to the table.
Used only for code generation.
A debugging representation of the parse tree starting at this node. Each line reads abs-pos name position length [identifier].
Assigns every symbol a unique integer index and builds the name and constness arrays that can be indexed by it.
The scope in which name is defined: this scope, one of its parents, or null when the name is not defined anywhere in this scope chain.
Checks that every return usage in a function body is consistent with strict mode. See the END_* flags for what the analysis reports.
Constructs an indentation string of indent steps.
Used by the parser. Repoints this scope's child scopes at newScope and copies this scope's symbols into it.
Recursively unlabel every TARGET or YIELD node in the tree. Used only for inlining finally blocks where jsr instructions used to be.
Used by the code generator.
Makes this node's position relative to a parent. The current position is assumed to be absolute and is decremented by parentPosition.
Visits this node, the function name if present, the parameters and the body. A member-expr node is visited last.