C# Класс 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.
Наследование: ScriptNode
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Описание методов

AddFunction() публичный Метод

public AddFunction ( Rhino fnNode ) : int
fnNode Rhino
Результат int

AddLiveLocals() публичный Метод

public AddLiveLocals ( Node node, int locals ) : void
node Node
locals int
Результат void

AddParam() публичный Метод

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
Результат void

AddResumptionPoint() публичный Метод

public AddResumptionPoint ( Node target ) : void
target Node
Результат void

FunctionNode() публичный Метод

public FunctionNode ( ) : System.Collections.Generic
Результат System.Collections.Generic

FunctionNode() публичный Метод

public FunctionNode ( int pos ) : System.Collections.Generic
pos int
Результат System.Collections.Generic

FunctionNode() публичный Метод

public FunctionNode ( int pos, Name name ) : System.Collections.Generic
pos int
name Name
Результат System.Collections.Generic

GetBody() публичный Метод

Returns function body.
Returns function body. Normally a Block , but can be a plain AstNode if it's a function closure.
public GetBody ( ) : AstNode
Результат AstNode

GetFunctionName() публичный Метод

Returns function name
public GetFunctionName ( ) : Name
Результат Name

GetFunctionType() публичный Метод

Returns the function type (statement, expr, statement expr)
public GetFunctionType ( ) : int
Результат int

GetLiveLocals() публичный Метод

public GetLiveLocals ( ) : int[]>.IDictionary
Результат int[]>.IDictionary

GetLp() публичный Метод

Returns left paren position, -1 if missing
public GetLp ( ) : int
Результат int

GetMemberExprNode() публичный Метод

public GetMemberExprNode ( ) : AstNode
Результат AstNode

GetName() публичный Метод

Returns the function name as a string
public GetName ( ) : string
Результат string

GetParams() публичный Метод

Returns the function parameter list
public GetParams ( ) : IList
Результат IList

GetResumptionPoints() публичный Метод

public GetResumptionPoints ( ) : IList
Результат IList

GetRp() публичный Метод

Returns right paren position, -1 if missing
public GetRp ( ) : int
Результат int

IsExpressionClosure() публичный Метод

Returns whether this is a 1.8 function closure
public IsExpressionClosure ( ) : bool
Результат bool

IsGenerator() публичный Метод

public IsGenerator ( ) : bool
Результат bool

IsGetter() публичный Метод

public IsGetter ( ) : bool
Результат bool

IsGetterOrSetter() публичный Метод

public IsGetterOrSetter ( ) : bool
Результат bool

IsParam() публичный Метод

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
Результат bool

IsSetter() публичный Метод

public IsSetter ( ) : bool
Результат bool

RequiresActivation() публичный Метод

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
Результат bool

SetBody() публичный Метод

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. ///
Результат void

SetFunctionIsGetter() публичный Метод

public SetFunctionIsGetter ( ) : void
Результат void

SetFunctionIsSetter() публичный Метод

public SetFunctionIsSetter ( ) : void
Результат void

SetFunctionName() публичный Метод

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 ///
Результат void

SetFunctionType() публичный Метод

public SetFunctionType ( int type ) : void
type int
Результат void

SetIsExpressionClosure() публичный Метод

Sets whether this is a 1.8 function closure
public SetIsExpressionClosure ( bool isExpressionClosure ) : void
isExpressionClosure bool
Результат void

SetIsGenerator() публичный Метод

public SetIsGenerator ( ) : void
Результат void

SetLp() публичный Метод

Sets left paren position
public SetLp ( int lp ) : void
lp int
Результат void

SetMemberExprNode() публичный Метод

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
Результат void

SetParams() публичный Метод

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
Результат void

SetParens() публичный Метод

Sets both paren positions
public SetParens ( int lp, int rp ) : void
lp int
rp int
Результат void

SetRequiresActivation() публичный Метод

public SetRequiresActivation ( ) : void
Результат void

SetRp() публичный Метод

Sets right paren position
public SetRp ( int rp ) : void
rp int
Результат void

ToSource() публичный Метод

public ToSource ( int depth ) : string
depth int
Результат string

Visit() публичный Метод

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
Результат void