C# Class Rhino.Ast.FunctionNode

A JavaScript function declaration or expression.

Node type is Rhino.Token.FUNCTION .

FunctionDeclaration : function Identifier ( FormalParameterListopt ) { FunctionBody } FunctionExpression : function Identifieropt ( FormalParameterListopt ) { FunctionBody } FormalParameterList : Identifier FormalParameterList , Identifier FunctionBody : SourceElements Program : SourceElements SourceElements : SourceElement SourceElements SourceElement SourceElement : Statement FunctionDeclaration
JavaScript 1.8 introduces "function closures" of the form
function ([params] ) Expression
In this case the FunctionNode node will have no body but will have an expression.
Inheritance: ScriptNode
Afficher le fichier Open project: hazzik/Rhino.Net Class Usage Examples

Méthodes publiques

Méthode Description
AddFunction ( Rhino fnNode ) : int
AddLiveLocals ( Node node, int locals ) : void
AddParam ( AstNode param ) : void

Adds a parameter to the function parameter list.

Adds a parameter to the function parameter list. Sets the parent of the param node to this node.

AddResumptionPoint ( Node target ) : void
FunctionNode ( ) : System.Collections.Generic
FunctionNode ( int pos ) : System.Collections.Generic
FunctionNode ( int pos, Name name ) : System.Collections.Generic
GetBody ( ) : AstNode

Returns function body.

Returns function body. Normally a Block , but can be a plain AstNode if it's a function closure.

GetFunctionName ( ) : Name

Returns function name

GetFunctionType ( ) : int

Returns the function type (statement, expr, statement expr)

GetLiveLocals ( ) : int[]>.IDictionary
GetLp ( ) : int

Returns left paren position, -1 if missing

GetMemberExprNode ( ) : AstNode
GetName ( ) : string

Returns the function name as a string

GetParams ( ) : IList

Returns the function parameter list

GetResumptionPoints ( ) : IList
GetRp ( ) : int

Returns right paren position, -1 if missing

IsExpressionClosure ( ) : bool

Returns whether this is a 1.8 function closure

IsGenerator ( ) : bool
IsGetter ( ) : bool
IsGetterOrSetter ( ) : bool
IsParam ( AstNode node ) : bool

Returns true if the specified AstNode node is a parameter of this Function node. This provides a way during AST traversal to disambiguate the function name node from the parameter nodes.

IsSetter ( ) : bool
RequiresActivation ( ) : bool

Return true if this function requires an Ecma-262 Activation object.

Return true if this function requires an Ecma-262 Activation object. The Activation object is implemented by Rhino.NativeCall , and is fairly expensive to create, so when possible, the interpreter attempts to use a plain call frame instead.

SetBody ( AstNode body ) : void

Sets function body, and sets its parent to this node.

Sets function body, and sets its parent to this node. Also sets the encoded source bounds based on the body bounds. Assumes the function node absolute position has already been set, and the body node's absolute position and length are set.

SetFunctionIsGetter ( ) : void
SetFunctionIsSetter ( ) : void
SetFunctionName ( Name name ) : void

Sets function name, and sets its parent to this node.

Sets function name, and sets its parent to this node.

SetFunctionType ( int type ) : void
SetIsExpressionClosure ( bool isExpressionClosure ) : void

Sets whether this is a 1.8 function closure

SetIsGenerator ( ) : void
SetLp ( int lp ) : void

Sets left paren position

SetMemberExprNode ( AstNode node ) : void

Rhino supports a nonstandard Ecma extension that allows you to say, for instance, function a.b.c(arg1, arg) {...}, and it will be rewritten at codegen time to: a.b.c = function(arg1, arg2) {...} If we detect an expression other than a simple Name in the position where a function name was expected, we record that expression here.

Rhino supports a nonstandard Ecma extension that allows you to say, for instance, function a.b.c(arg1, arg) {...}, and it will be rewritten at codegen time to: a.b.c = function(arg1, arg2) {...} If we detect an expression other than a simple Name in the position where a function name was expected, we record that expression here.

This extension is only available by setting the CompilerEnv option "isAllowMemberExprAsFunctionName" in the Parser.

SetParams ( IList @params ) : void

Sets the function parameter list, and sets the parent for each element of the list.

Sets the function parameter list, and sets the parent for each element of the list.

SetParens ( int lp, int rp ) : void

Sets both paren positions

SetRequiresActivation ( ) : void
SetRp ( int rp ) : void

Sets right paren position

ToSource ( int depth ) : string
Visit ( NodeVisitor v ) : void

Visits this node, the function name node if supplied, the parameters, and the body.

Visits this node, the function name node if supplied, the parameters, and the body. If there is a member-expr node, it is visited last.

Method Details

AddFunction() public méthode

public AddFunction ( Rhino fnNode ) : int
fnNode Rhino
Résultat int

AddLiveLocals() public méthode

public AddLiveLocals ( Node node, int locals ) : void
node Node
locals int
Résultat void

AddParam() public méthode

Adds a parameter to the function parameter list.
Adds a parameter to the function parameter list. Sets the parent of the param node to this node.
/// if param is /// null ///
public AddParam ( AstNode param ) : void
param AstNode the parameter
Résultat void

AddResumptionPoint() public méthode

public AddResumptionPoint ( Node target ) : void
target Node
Résultat void

FunctionNode() public méthode

public FunctionNode ( ) : System.Collections.Generic
Résultat System.Collections.Generic

FunctionNode() public méthode

public FunctionNode ( int pos ) : System.Collections.Generic
pos int
Résultat System.Collections.Generic

FunctionNode() public méthode

public FunctionNode ( int pos, Name name ) : System.Collections.Generic
pos int
name Name
Résultat System.Collections.Generic

GetBody() public méthode

Returns function body.
Returns function body. Normally a Block , but can be a plain AstNode if it's a function closure.
public GetBody ( ) : AstNode
Résultat AstNode

GetFunctionName() public méthode

Returns function name
public GetFunctionName ( ) : Name
Résultat Name

GetFunctionType() public méthode

Returns the function type (statement, expr, statement expr)
public GetFunctionType ( ) : int
Résultat int

GetLiveLocals() public méthode

public GetLiveLocals ( ) : int[]>.IDictionary
Résultat int[]>.IDictionary

GetLp() public méthode

Returns left paren position, -1 if missing
public GetLp ( ) : int
Résultat int

GetMemberExprNode() public méthode

public GetMemberExprNode ( ) : AstNode
Résultat AstNode

GetName() public méthode

Returns the function name as a string
public GetName ( ) : string
Résultat string

GetParams() public méthode

Returns the function parameter list
public GetParams ( ) : IList
Résultat IList

GetResumptionPoints() public méthode

public GetResumptionPoints ( ) : IList
Résultat IList

GetRp() public méthode

Returns right paren position, -1 if missing
public GetRp ( ) : int
Résultat int

IsExpressionClosure() public méthode

Returns whether this is a 1.8 function closure
public IsExpressionClosure ( ) : bool
Résultat bool

IsGenerator() public méthode

public IsGenerator ( ) : bool
Résultat bool

IsGetter() public méthode

public IsGetter ( ) : bool
Résultat bool

IsGetterOrSetter() public méthode

public IsGetterOrSetter ( ) : bool
Résultat bool

IsParam() public méthode

Returns true if the specified AstNode node is a parameter of this Function node. This provides a way during AST traversal to disambiguate the function name node from the parameter nodes.
public IsParam ( AstNode node ) : bool
node AstNode
Résultat bool

IsSetter() public méthode

public IsSetter ( ) : bool
Résultat bool

RequiresActivation() public méthode

Return true if this function requires an Ecma-262 Activation object.
Return true if this function requires an Ecma-262 Activation object. The Activation object is implemented by Rhino.NativeCall , and is fairly expensive to create, so when possible, the interpreter attempts to use a plain call frame instead.
public RequiresActivation ( ) : bool
Résultat bool

SetBody() public méthode

Sets function body, and sets its parent to this node.
Sets function body, and sets its parent to this node. Also sets the encoded source bounds based on the body bounds. Assumes the function node absolute position has already been set, and the body node's absolute position and length are set.

/// if body is /// null ///
public SetBody ( AstNode body ) : void
body AstNode /// function body. Its parent is set to this node, and its /// position is updated to be relative to this node. ///
Résultat void

SetFunctionIsGetter() public méthode

public SetFunctionIsGetter ( ) : void
Résultat void

SetFunctionIsSetter() public méthode

public SetFunctionIsSetter ( ) : void
Résultat void

SetFunctionName() public méthode

Sets function name, and sets its parent to this node.
Sets function name, and sets its parent to this node.
public SetFunctionName ( Name name ) : void
name Name /// function name, /// null /// for anonymous functions ///
Résultat void

SetFunctionType() public méthode

public SetFunctionType ( int type ) : void
type int
Résultat void

SetIsExpressionClosure() public méthode

Sets whether this is a 1.8 function closure
public SetIsExpressionClosure ( bool isExpressionClosure ) : void
isExpressionClosure bool
Résultat void

SetIsGenerator() public méthode

public SetIsGenerator ( ) : void
Résultat void

SetLp() public méthode

Sets left paren position
public SetLp ( int lp ) : void
lp int
Résultat void

SetMemberExprNode() public méthode

Rhino supports a nonstandard Ecma extension that allows you to say, for instance, function a.b.c(arg1, arg) {...}, and it will be rewritten at codegen time to: a.b.c = function(arg1, arg2) {...} If we detect an expression other than a simple Name in the position where a function name was expected, we record that expression here.
Rhino supports a nonstandard Ecma extension that allows you to say, for instance, function a.b.c(arg1, arg) {...}, and it will be rewritten at codegen time to: a.b.c = function(arg1, arg2) {...} If we detect an expression other than a simple Name in the position where a function name was expected, we record that expression here.

This extension is only available by setting the CompilerEnv option "isAllowMemberExprAsFunctionName" in the Parser.

public SetMemberExprNode ( AstNode node ) : void
node AstNode
Résultat void

SetParams() public méthode

Sets the function parameter list, and sets the parent for each element of the list.
Sets the function parameter list, and sets the parent for each element of the list.
public SetParams ( IList @params ) : void
@params IList
Résultat void

SetParens() public méthode

Sets both paren positions
public SetParens ( int lp, int rp ) : void
lp int
rp int
Résultat void

SetRequiresActivation() public méthode

public SetRequiresActivation ( ) : void
Résultat void

SetRp() public méthode

Sets right paren position
public SetRp ( int rp ) : void
rp int
Résultat void

ToSource() public méthode

public ToSource ( int depth ) : string
depth int
Résultat string

Visit() public méthode

Visits this node, the function name node if supplied, the parameters, and the body.
Visits this node, the function name node if supplied, the parameters, and the body. If there is a member-expr node, it is visited last.
public Visit ( NodeVisitor v ) : void
v NodeVisitor
Résultat void