public final class VarNode extends Statement implements Assignment<IdentNode>
Modifier and Type | Field and Description |
---|---|
static int |
IS_CONST
Flag for ES6 CONST declaration
|
static int |
IS_DESTRUCTURING
Flag synthetic destructuring var node
|
static int |
IS_EXPORT
Flag synthetic export var node
|
static int |
IS_LAST_FUNCTION_DECLARATION
Flag that determines if this is the last function declaration in a function This is used to
micro optimize the placement of return value assignments for a program node
|
static int |
IS_LET
Flag for ES6 LET declaration
|
Constructor and Description |
---|
VarNode(int lineNumber,
long token,
int finish,
IdentNode name,
Expression init)
Constructor
|
VarNode(int lineNumber,
long token,
int finish,
IdentNode name,
Expression init,
int flags)
Constructor
|
VarNode(int lineNumber,
long token,
int sourceOrder,
int finish,
IdentNode name,
Expression init,
int flags)
Constructor
|
VarNode(int lineNumber,
long token,
int sourceOrder,
int start,
int finish,
IdentNode name,
Expression init,
int flags)
Constructor
|
Modifier and Type | Method and Description |
---|---|
Node |
accept(NodeVisitor<? extends LexicalContext> visitor)
Assist in IR navigation.
|
<R> R |
accept(TranslatorNodeVisitor<? extends LexicalContext,R> visitor)
Provides a means to navigate the IR.
|
IdentNode |
getAssignmentDest()
Get assignment destination.
|
Expression |
getAssignmentSource()
Get the assignment source.
|
boolean |
getFlag(int flag)
Check if a flag is set for this var node
|
Expression |
getInit()
If this is an assignment of the form
var x = init; , get the init part. |
IdentNode |
getName()
Get the identifier for the variable
|
int |
getSourceOrder()
Integer to sort nodes in source order.
|
int |
getSymbolFlags()
Return the flags to use for symbols for this declaration.
|
boolean |
hasInit()
Does this variable declaration have an init value
|
boolean |
isAssignment()
Is this an assignment node - for example a var node with an init or a binary node that writes
to a destination
|
boolean |
isBlockScoped()
Is this a VAR node block scoped? This returns true for ECMAScript 6 LET and CONST nodes.
|
boolean |
isClassDeclaration()
Returns true if this is a Class declaration.
|
boolean |
isConst()
Is this an ECMAScript 6 CONST node?
|
boolean |
isDestructuring() |
boolean |
isExport() |
boolean |
isFunctionDeclaration()
Returns true if this is a FunctionDeclaration.
|
boolean |
isHoistableDeclaration()
Returns true if this is a HoistableDeclaration (i.e., FunctionDeclaration,
GeneratorDeclaration, AsyncFunctionDeclaration, or AsyncGeneratorDeclaration).
|
boolean |
isLet()
Is this an ECMAScript 6 LET node?
|
VarNode |
setFlag(int flag)
Set a flag for this var node
|
void |
toString(StringBuilder sb,
boolean printType)
Print logic that decides whether to show the optimistic type or not - for example it should
not be printed after just parse, when it hasn't been computed, or has been set to a trivially
provable value
|
getLineNumber, hasGoto, hasTerminalFlags, isCompletionValueNeverEmpty, isTerminal
public static final int IS_LET
public static final int IS_CONST
public static final int IS_LAST_FUNCTION_DECLARATION
public static final int IS_EXPORT
public static final int IS_DESTRUCTURING
public VarNode(int lineNumber, long token, int finish, IdentNode name, Expression init)
lineNumber
- line numbertoken
- tokenfinish
- finishname
- name of variableinit
- init node or null if just a declarationpublic VarNode(int lineNumber, long token, int finish, IdentNode name, Expression init, int flags)
lineNumber
- line numbertoken
- tokenfinish
- finishname
- name of variableinit
- init node or null if just a declarationflags
- flagspublic VarNode(int lineNumber, long token, int sourceOrder, int finish, IdentNode name, Expression init, int flags)
lineNumber
- line numbertoken
- tokensourceOrder
- source orderfinish
- finishname
- name of variableinit
- init node or null if just a declarationflags
- flagspublic VarNode(int lineNumber, long token, int sourceOrder, int start, int finish, IdentNode name, Expression init, int flags)
lineNumber
- line numbertoken
- tokensourceOrder
- source orderstart
- startfinish
- finishname
- name of variableinit
- init node or null if just a declarationflags
- flagspublic int getSourceOrder()
Node
getSourceOrder
in class Node
public boolean isAssignment()
Node
isAssignment
in class Node
public IdentNode getAssignmentDest()
Assignment
getAssignmentDest
in interface Assignment<IdentNode>
public Expression getAssignmentSource()
Assignment
getAssignmentSource
in interface Assignment<IdentNode>
public boolean isBlockScoped()
public boolean isLet()
public boolean isConst()
public int getSymbolFlags()
public boolean hasInit()
public Node accept(NodeVisitor<? extends LexicalContext> visitor)
public <R> R accept(TranslatorNodeVisitor<? extends LexicalContext,R> visitor)
Node
public void toString(StringBuilder sb, boolean printType)
Node
public Expression getInit()
var x = init;
, get the init part.public IdentNode getName()
public boolean getFlag(int flag)
flag
- flagpublic VarNode setFlag(int flag)
flag
- flagpublic boolean isHoistableDeclaration()
public boolean isFunctionDeclaration()
public boolean isExport()
public boolean isDestructuring()
public boolean isClassDeclaration()