Class LiteralNode<T>
java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.Expression
com.oracle.js.parser.ir.LiteralNode<T>
- Type Parameters:
T- the literal type
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
LiteralNode.ArrayLiteralNode, LiteralNode.PrimitiveLiteralNode
Literal nodes represent JavaScript values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classArray literal node class.static classSuper class for primitive (side-effect free) literals. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLiteralNode(long token, int finish, T value) ConstructorprotectedLiteralNode(LiteralNode<T> literalNode) Copy constructorprotectedLiteralNode(LiteralNode<T> literalNode, T newValue) A copy constructor with value change. -
Method Summary
Modifier and TypeMethodDescriptionaccept(NodeVisitor<? extends LexicalContext> visitor) Assist in IR navigation.<R> Raccept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor) Provides a means to navigate the IR.Fetch Object value of node.Fetch String value of node.final TgetValue()Get the literal node valuebooleanisArray()Test if the value is an arraybooleanisString()Test if the value is a string.static LiteralNode<Object> newInstance(long token, int finish) Create a new null literalstatic LiteralNode<Boolean> newInstance(long token, int finish, boolean value) Create a new boolean literalstatic LiteralNode<Expression[]> newInstance(long token, int finish, Expression[] value) Create a new array literal of Nodesstatic LiteralNode<Lexer.LexerToken> newInstance(long token, int finish, Lexer.LexerToken value) Create a new literal node for a lexer tokenstatic LiteralNode<Number> newInstance(long token, int finish, Number value) Create a new number literalstatic LiteralNode<Number> newInstance(long token, int finish, Number value, Function<Number, com.oracle.truffle.api.strings.TruffleString> toStringConverter) Create a new number literalstatic LiteralNode<Expression[]> newInstance(long token, int finish, List<Expression> value) Create a new array literal of Nodes from a list of Node valuesstatic LiteralNode<Expression[]> newInstance(long token, int finish, List<Expression> value, boolean hasSpread, boolean hasTrailingComma) Create a new array literal of Nodes from a list of Node valuesstatic LiteralNode.PrimitiveLiteralNode<com.oracle.truffle.api.strings.TruffleString> newInstance(long token, com.oracle.truffle.api.strings.TruffleString value) Create a new string literalvoidtoString(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 valueMethods inherited from class Expression
getFinish, getFinishWithoutParens, getStart, getStartWithoutParens, isAlwaysFalse, isAlwaysTrue, isParenthesized, isSelfModifying, makeParenthesizedMethods inherited from class Node
clone, equals, getSourceOrder, getToken, hashCode, isAssignment, isLoop, isTokenType, tokenType, toString, toString
-
Field Details
-
value
Literal value
-
-
Constructor Details
-
LiteralNode
Constructor- Parameters:
token- tokenfinish- finishvalue- the value of the literal
-
LiteralNode
Copy constructor- Parameters:
literalNode- source node
-
LiteralNode
A copy constructor with value change.- Parameters:
literalNode- the original literal nodenewValue- new value for this node
-
-
Method Details
-
getString
-
getObject
-
isArray
public boolean isArray()Test if the value is an array- Returns:
- True if value is an array
-
getElementExpressions
-
isString
public boolean isString()Test if the value is a string.- Returns:
- True if value is a string.
-
accept
Assist in IR navigation. -
accept
Description copied from class:NodeProvides a means to navigate the IR. -
toString
Description copied from class:NodePrint 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 -
getValue
-
newInstance
Create a new null literal- Parameters:
token- tokenfinish- finish- Returns:
- the new literal node
-
newInstance
Create a new boolean literal- Parameters:
token- tokenfinish- finishvalue- true or false- Returns:
- the new literal node
-
newInstance
Create a new number literal- Parameters:
token- tokenfinish- finishvalue- literal value- Returns:
- the new literal node
-
newInstance
public static LiteralNode<Number> newInstance(long token, int finish, Number value, Function<Number, com.oracle.truffle.api.strings.TruffleString> toStringConverter) Create a new number literal- Parameters:
token- tokenfinish- finishvalue- literal value- Returns:
- the new literal node
-
newInstance
public static LiteralNode.PrimitiveLiteralNode<com.oracle.truffle.api.strings.TruffleString> newInstance(long token, com.oracle.truffle.api.strings.TruffleString value) Create a new string literal- Parameters:
token- tokenvalue- string value- Returns:
- the new literal node
-
newInstance
public static LiteralNode<Lexer.LexerToken> newInstance(long token, int finish, Lexer.LexerToken value) Create a new literal node for a lexer token- Parameters:
token- tokenfinish- finishvalue- lexer token value- Returns:
- the new literal node
-
newInstance
Create a new array literal of Nodes from a list of Node values- Parameters:
token- tokenfinish- finishvalue- literal value list- Returns:
- the new literal node
-
newInstance
public static LiteralNode<Expression[]> newInstance(long token, int finish, List<Expression> value, boolean hasSpread, boolean hasTrailingComma) Create a new array literal of Nodes from a list of Node values- Parameters:
token- tokenfinish- finishvalue- literal value listhasSpread- true if the array has a spread elementhasTrailingComma- true if the array literal has a comma after the last element- Returns:
- the new literal node
-
newInstance
Create a new array literal of Nodes- Parameters:
token- tokenfinish- finishvalue- literal value array- Returns:
- the new literal node
-