Class TernaryNode
java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.Expression
com.oracle.js.parser.ir.TernaryNode
- All Implemented Interfaces:
Cloneable
TernaryNode represent the ternary operator
?:. Note that for control-flow calculation
reasons its branch expressions (but not its test expression) are always wrapped in instances of
JoinPredecessorExpression.-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTernaryNode(long token, Expression test, JoinPredecessorExpression trueExpr, JoinPredecessorExpression falseExpr) Constructor -
Method Summary
Modifier and TypeMethodDescriptionaccept(NodeVisitor<? extends LexicalContext> visitor) Provides a means to navigate the IR.<R> Raccept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor) Provides a means to navigate the IR.Get the false expression for this ternary expression, i.e.getTest()Get the test expression for this ternary expression, i.e.Get the true expression for this ternary expression, i.e.setFalseExpression(JoinPredecessorExpression falseExpr) Set the false expression for this nodesetTest(Expression test) Set the test expression for this nodesetTrueExpression(JoinPredecessorExpression trueExpr) Set the true expression for this nodevoidtoString(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
-
Constructor Details
-
TernaryNode
public TernaryNode(long token, Expression test, JoinPredecessorExpression trueExpr, JoinPredecessorExpression falseExpr) Constructor- Parameters:
token- tokentest- test expressiontrueExpr- expression evaluated when test evaluates to truefalseExpr- expression evaluated when test evaluates to true
-
-
Method Details
-
accept
Description copied from class:NodeProvides a means to navigate the IR. -
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 -
getTest
Get the test expression for this ternary expression, i.e. "x" in x ? y : z- Returns:
- the test expression
-
getTrueExpression
Get the true expression for this ternary expression, i.e. "y" in x ? y : z- Returns:
- the true expression
-
getFalseExpression
Get the false expression for this ternary expression, i.e. "z" in x ? y : z- Returns:
- the false expression
-
setTest
Set the test expression for this node- Parameters:
test- new test expression- Returns:
- a node equivalent to this one except for the requested change.
-
setTrueExpression
Set the true expression for this node- Parameters:
trueExpr- new true expression- Returns:
- a node equivalent to this one except for the requested change.
-
setFalseExpression
Set the false expression for this node- Parameters:
falseExpr- new false expression- Returns:
- a node equivalent to this one except for the requested change.
-