Class Node
java.lang.Object
com.oracle.js.parser.ir.Node
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
Block,CaseNode,ExportNode,ExportSpecifierNode,Expression,ImportClauseNode,ImportNode,ImportSpecifierNode,NamedExportsNode,NamedImportsNode,NameSpaceImportNode,PropertyNode,Statement
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Nodeaccept(NodeVisitor<? extends LexicalContext> visitor) Provides a means to navigate the IR.abstract <R> Raccept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor) Provides a means to navigate the IR.protected Objectclone()final booleanintGet the finish position for this node in the source stringintInteger to sort nodes in source order.intgetStart()Get start position for nodelonggetToken()Get the token for this node.final inthashCode()booleanIs this an assignment node - for example a var node with an init or a binary node that writes to a destinationbooleanisLoop()Is this a loop node?booleanisTokenType(TokenType type) Tests if this node has the specific token type.Returns this node's token's type.final StringtoString()final StringtoString(boolean includeTypeInfo) Return String representation of this Node.abstract voidtoString(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
-
Field Details
-
start
protected final int startStart of source range. -
finish
protected final int finishEnd of source range.
-
-
Constructor Details
-
Node
public Node(long token, int finish) Constructor- Parameters:
token- tokenfinish- finish
-
Node
protected Node(long token, int start, int finish) Constructor- Parameters:
token- tokenstart- startfinish- finish
-
Node
-
Node
Copy constructor that overrides finish- Parameters:
node- source nodefinish- Last character
-
-
Method Details
-
isLoop
public boolean isLoop()Is this a loop node?- Returns:
- true if atom
-
isAssignment
public boolean isAssignment()Is this an assignment node - for example a var node with an init or a binary node that writes to a destination- Returns:
- true if assignment
-
accept
Provides a means to navigate the IR.- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-
accept
Provides a means to navigate the IR.- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-
toString
-
toString
Return String representation of this Node.- Parameters:
includeTypeInfo- include type information or not
-
toString
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- Parameters:
sb- string builderprintType- print type?
-
getFinish
public int getFinish()Get the finish position for this node in the source string- Returns:
- finish
-
getStart
public int getStart()Get start position for node- Returns:
- start position
-
getSourceOrder
public int getSourceOrder()Integer to sort nodes in source order. This order is used by parser API to sort statements in correct order. By default, this is the start position of this node.- Returns:
- int code to sort this node.
-
clone
-
equals
-
hashCode
-
tokenType
Returns this node's token's type. If you want to check for the node having a specific token type, consider usingisTokenType(TokenType)instead.- Returns:
- type of token.
-
isTokenType
Tests if this node has the specific token type.- Parameters:
type- a token type to check this node's token type against- Returns:
- true if token types match.
-
getToken
public long getToken()Get the token for this node. If you want to retrieve the token's type, consider usingtokenType()orisTokenType(TokenType)instead.- Returns:
- the token
-