Class SwitchNode
java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.Statement
com.oracle.js.parser.ir.SwitchNode
- All Implemented Interfaces:
BreakableNode, LexicalContextNode, Terminal, Cloneable
IR representation of a SWITCH statement.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSwitchNode(int lineNumber, long token, int finish, Expression expression, List<CaseNode> cases, int defaultCaseIndex) Constructor -
Method Summary
Modifier and TypeMethodDescriptionaccept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor) Accept function for the node given a lexical context.<R> Raccept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext, R> visitor) final Nodeaccept(NodeVisitor<? extends LexicalContext> visitor) Provides a means to navigate the IR.final <R> Raccept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor) Provides a means to navigate the IR.getCases()Get the cases in this switchReturn the case node that is default caseReturn the expression to switch ongetTag()Get the tag symbol for this switch.booleanbooleanCheck whether this can be broken out from without using a label, e.g.booleanbooleanIs this a terminal statement, i.e.setExpression(LexicalContext lc, Expression expression) Set or reset the expression to switch onvoidSet the tag symbol for this switch.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 valueMethods inherited from class Statement
getLineNumber, hasGoto, hasTerminalFlagsMethods inherited from class Node
clone, equals, getFinish, getSourceOrder, getStart, getToken, hashCode, isAssignment, isLoop, isTokenType, tokenType, toString, toStringMethods inherited from interface LexicalContextNode
accept, accept
-
Constructor Details
-
SwitchNode
public SwitchNode(int lineNumber, long token, int finish, Expression expression, List<CaseNode> cases, int defaultCaseIndex) Constructor- Parameters:
lineNumber- lineNumbertoken- tokenfinish- finishexpression- switch expressioncases- casesdefaultCaseIndex- the default case index; -1 if none, otherwise has to be present in cases list
-
-
Method Details
-
isTerminal
public boolean isTerminal()Description copied from class:StatementIs this a terminal statement, i.e. does it end control flow like a throw or return?- Specified by:
isTerminalin interfaceTerminal- Overrides:
isTerminalin classStatement- Returns:
- true if this node statement is terminal
-
accept
Description copied from interface:LexicalContextNodeAccept function for the node given a lexical context. It must be prepared to replace itself if present in the lexical context- Parameters:
lc- lexical contextvisitor- node visitor- Returns:
- new node or same node depending on state change
-
accept
-
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 -
getDefaultCase
Return the case node that is default case- Returns:
- default case or null if none
-
getCases
-
getExpression
-
setExpression
Set or reset the expression to switch on- Parameters:
lc- lexical contextexpression- switch expression- Returns:
- new switch node or same if no state was changed
-
getTag
Get the tag symbol for this switch. The tag symbol is where the switch expression result is stored- Returns:
- tag symbol
-
setTag
Set the tag symbol for this switch. The tag symbol is where the switch expression result is stored- Parameters:
tag- a symbol
-
hasDefaultCase
public boolean hasDefaultCase()- Returns:
- true if this switch has a default case.
-
isCompletionValueNeverEmpty
public boolean isCompletionValueNeverEmpty()- Overrides:
isCompletionValueNeverEmptyin classStatement- Returns:
- true if the completion value of this statement is never the value
empty
-
isBreakableWithoutLabel
public boolean isBreakableWithoutLabel()Check whether this can be broken out from without using a label, e.g. everything but Blocks, basically- Specified by:
isBreakableWithoutLabelin interfaceBreakableNode- Returns:
- true if breakable without label
-
accept
Description copied from class:NodeProvides a means to navigate the IR.- Specified by:
acceptin interfaceLexicalContextNode- Specified by:
acceptin classNode- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-
accept
Description copied from class:NodeProvides a means to navigate the IR.- Specified by:
acceptin interfaceLexicalContextNode- Specified by:
acceptin classNode- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-