Class Block
java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.Block
- All Implemented Interfaces:
BreakableNode,Flags<Block>,LexicalContextNode,LexicalContextScope,Terminal,Cloneable
public class Block
extends Node
implements BreakableNode, Terminal, Flags<Block>, LexicalContextScope
IR representation for a list of statements.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intDoes the block/function need a new scope? Is this synthetic?static final intIs this the function body block? May not be the first, if parameter list contains expressions.static final intIs this an expression block (class or do expression) that should return its completion value.static final intIs this block the eager global scope - i.e.static final intMarks the module body block.static final intIs this the parameter initialization block? If present, must be the first block, immediately wrapping the function body block.static final intMarks the variable declaration block for case clauses of a switch statement.static final intIs this block a synthetic one introduced by Parser?static final intIs this block tagged as terminal based on its contents (usually the last statement)static final intFlag indicating that this block needs scopeprotected final ScopeList of statements -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor) Assist in IR navigation.<R> Raccept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext, R> visitor) accept(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.getExistingSymbol(String name) Retrieves an existing symbol defined in the current block.Returns the first statement in the block.intReturns the line number of the first statement in the block.booleangetFlag(int flag) Check if a flag is set in a lexical context nodeintgetFlags()Get all flags of a LexicalContextNodeReturns the last statement in the block.getScope()intReturns the number of statements in the block.Get the list of statements in this blockintGet the number of symbols defined in this block.Get all the symbols defined in this block, in definition order.booleanTest if a symbol with this name is defined in the current block.booleanCheck whether this can be broken out from without using a label, e.g.booleanTest if this block represents a catch block in a try statement.booleanbooleanbooleanIs this block the outermost eager global scope - i.e.booleanbooleanbooleanbooleanCheck whether this block is synthetic or not.booleanIs this a terminal block, i.e.booleanCheck whether scope is necessary for this BlocksetFlag(LexicalContext lc, int flag) Set a flag of a LexicalContextNodesetFlags(LexicalContext lc, int flags) Set all flags of a LexicalContextNode, overwriting previous flagssetStatements(LexicalContext lc, List<Statement> statements) Reset the statement list for this blockvoidtoString(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 com.oracle.js.parser.ir.Node
clone, equals, getFinish, getSourceOrder, getStart, getToken, hashCode, isAssignment, isLoop, isTokenType, tokenType, toString, toString
-
Field Details
-
statements
-
scope
-
flags
protected final int flagsDoes the block/function need a new scope? Is this synthetic? -
NEEDS_SCOPE
public static final int NEEDS_SCOPEFlag indicating that this block needs scope- See Also:
-
IS_TERMINAL
public static final int IS_TERMINALIs this block tagged as terminal based on its contents (usually the last statement)- See Also:
-
IS_GLOBAL_SCOPE
public static final int IS_GLOBAL_SCOPEIs this block the eager global scope - i.e. the original program. This isn't true for the outermost level of recompiles- See Also:
-
IS_SYNTHETIC
public static final int IS_SYNTHETICIs this block a synthetic one introduced by Parser?- See Also:
-
IS_BODY
public static final int IS_BODYIs this the function body block? May not be the first, if parameter list contains expressions.- See Also:
-
IS_PARAMETER_BLOCK
public static final int IS_PARAMETER_BLOCKIs this the parameter initialization block? If present, must be the first block, immediately wrapping the function body block.- See Also:
-
IS_SWITCH_BLOCK
public static final int IS_SWITCH_BLOCKMarks the variable declaration block for case clauses of a switch statement.- See Also:
-
IS_EXPRESSION_BLOCK
public static final int IS_EXPRESSION_BLOCKIs this an expression block (class or do expression) that should return its completion value.- See Also:
-
IS_MODULE_BODY
public static final int IS_MODULE_BODYMarks the module body block.- See Also:
-
-
Constructor Details
-
Block
-
-
Method Details
-
isGlobalScope
public boolean isGlobalScope()Is this block the outermost eager global scope - i.e. the primordial program? Used for global anchor point for scope depth computation for recompilation code- Returns:
- true if outermost eager global scope
-
accept
Assist in IR navigation.- Specified by:
acceptin interfaceLexicalContextNode- Parameters:
lc- lexical contextvisitor- IR navigating visitor.- Returns:
- new or same node
-
accept
- Specified by:
acceptin interfaceLexicalContextNode
-
getSymbols
-
getExistingSymbol
-
hasSymbol
Test if a symbol with this name is defined in the current block.- Parameters:
name- the name of the symbol
-
getSymbolCount
public int getSymbolCount()Get the number of symbols defined in this block. -
isCatchBlock
public boolean isCatchBlock()Test if this block represents a catch block in a try statement.- Returns:
- true if this block represents a catch block in a try statement.
-
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 -
getFlags
-
isTerminal
public boolean isTerminal()Is this a terminal block, i.e. does it end control flow like ending with a throw or return?- Specified by:
isTerminalin interfaceTerminal- Returns:
- true if this node statement is terminal
-
getStatements
-
getStatementCount
public int getStatementCount()Returns the number of statements in the block.- Returns:
- the number of statements in the block.
-
getFirstStatementLineNumber
public int getFirstStatementLineNumber()Returns the line number of the first statement in the block.- Returns:
- the line number of the first statement in the block, or -1 if the block has no statements.
-
getFirstStatement
Returns the first statement in the block.- Returns:
- the first statement in the block, or null if the block has no statements.
-
getLastStatement
Returns the last statement in the block.- Returns:
- the last statement in the block, or null if the block has no statements.
-
setStatements
Reset the statement list for this block- Parameters:
lc- lexical contextstatements- new statement list- Returns:
- new block if statements changed, identity of statements == block.statements
-
needsScope
public boolean needsScope()Check whether scope is necessary for this Block- Returns:
- true if this function needs a scope
-
isSynthetic
public boolean isSynthetic()Check whether this block is synthetic or not.- Returns:
- true if this is a synthetic block
-
setFlags
Description copied from interface:FlagsSet all flags of a LexicalContextNode, overwriting previous flags -
setFlag
Description copied from interface:FlagsSet a flag of a LexicalContextNode -
getFlag
-
isBreakableWithoutLabel
public boolean isBreakableWithoutLabel()Description copied from interface:BreakableNodeCheck 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
-
getScope
- Specified by:
getScopein interfaceLexicalContextScope
-
isFunctionBody
public boolean isFunctionBody() -
isParameterBlock
public boolean isParameterBlock() -
isSwitchBlock
public boolean isSwitchBlock() -
isExpressionBlock
public boolean isExpressionBlock() -
isModuleBody
public boolean isModuleBody()
-