public class Block extends Node implements BreakableNode, Terminal, Flags<Block>, LexicalContextScope
| Modifier and Type | Field and Description |
|---|---|
protected int |
flags
Does the block/function need a new scope? Is this synthetic?
|
static int |
IS_BODY
Is this the function body block? May not be the first, if parameter list contains
expressions.
|
static int |
IS_EXPRESSION_BLOCK
Is this an expression block (class or do expression) that should return its completion value.
|
static int |
IS_GLOBAL_SCOPE
Is this block the eager global scope - i.e.
|
static int |
IS_MODULE_BODY
Marks the module body block.
|
static int |
IS_PARAMETER_BLOCK
Is this the parameter initialization block? If present, must be the first block, immediately
wrapping the function body block.
|
static int |
IS_SWITCH_BLOCK
Marks the variable declaration block for case clauses of a switch statement.
|
static int |
IS_SYNTHETIC
Is this block a synthetic one introduced by Parser?
|
static int |
IS_TERMINAL
Is this block tagged as terminal based on its contents (usually the last statement)
|
static int |
NEEDS_SCOPE
Flag indicating that this block needs scope
|
protected Scope |
scope |
protected List<Statement> |
statements
List of statements
|
| Constructor and Description |
|---|
Block(long token,
int finish,
int flags,
Scope scope,
List<Statement> statements)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
Node |
accept(LexicalContext lc,
NodeVisitor<? extends LexicalContext> visitor)
Assist in IR navigation.
|
<R> R |
accept(LexicalContext lc,
TranslatorNodeVisitor<? extends LexicalContext,R> visitor) |
Node |
accept(NodeVisitor<? extends LexicalContext> visitor)
Provides a means to navigate the IR.
|
<R> R |
accept(TranslatorNodeVisitor<? extends LexicalContext,R> visitor)
Provides a means to navigate the IR.
|
Symbol |
getExistingSymbol(String name)
Retrieves an existing symbol defined in the current block.
|
Statement |
getFirstStatement()
Returns the first statement in the block.
|
int |
getFirstStatementLineNumber()
Returns the line number of the first statement in the block.
|
boolean |
getFlag(int flag)
Check if a flag is set in a lexical context node
|
int |
getFlags()
Get all flags of a LexicalContextNode
|
Statement |
getLastStatement()
Returns the last statement in the block.
|
Scope |
getScope() |
int |
getStatementCount()
Returns the number of statements in the block.
|
List<Statement> |
getStatements()
Get the list of statements in this block
|
int |
getSymbolCount()
Get the number of symbols defined in this block.
|
Iterable<Symbol> |
getSymbols()
Get all the symbols defined in this block, in definition order.
|
boolean |
hasSymbol(String name)
Test if a symbol with this name is defined in the current block.
|
boolean |
isBreakableWithoutLabel()
Check whether this can be broken out from without using a label, e.g.
|
boolean |
isCatchBlock()
Test if this block represents a catch block in a try statement.
|
boolean |
isExpressionBlock() |
boolean |
isFunctionBody() |
boolean |
isGlobalScope()
Is this block the outermost eager global scope - i.e.
|
boolean |
isModuleBody() |
boolean |
isParameterBlock() |
boolean |
isSwitchBlock() |
boolean |
isSynthetic()
Check whether this block is synthetic or not.
|
boolean |
isTerminal()
Is this a terminal block, i.e.
|
boolean |
needsScope()
Check whether scope is necessary for this Block
|
Block |
setFlag(LexicalContext lc,
int flag)
Set a flag of a LexicalContextNode
|
Block |
setFlags(LexicalContext lc,
int flags)
Set all flags of a LexicalContextNode, overwriting previous flags
|
Block |
setStatements(LexicalContext lc,
List<Statement> statements)
Reset the statement list for this block
|
void |
toString(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
|
clone, equals, getFinish, getSourceOrder, getStart, getToken, hashCode, isAssignment, isLoop, isTokenType, tokenType, toString, toStringprotected final Scope scope
protected final int flags
public static final int NEEDS_SCOPE
public static final int IS_TERMINAL
public static final int IS_GLOBAL_SCOPE
public static final int IS_SYNTHETIC
public static final int IS_BODY
public static final int IS_PARAMETER_BLOCK
public static final int IS_SWITCH_BLOCK
public static final int IS_EXPRESSION_BLOCK
public static final int IS_MODULE_BODY
public boolean isGlobalScope()
public Node accept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor)
accept in interface LexicalContextNodevisitor - IR navigating visitor.lc - lexical contextpublic <R> R accept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext,R> visitor)
accept in interface LexicalContextNodepublic Iterable<Symbol> getSymbols()
public Symbol getExistingSymbol(String name)
name - the name of the symbolpublic boolean hasSymbol(String name)
name - the name of the symbolpublic int getSymbolCount()
public boolean isCatchBlock()
public void toString(StringBuilder sb, boolean printType)
Nodepublic int getFlags()
Flagspublic boolean isTerminal()
isTerminal in interface Terminalpublic List<Statement> getStatements()
public int getStatementCount()
public int getFirstStatementLineNumber()
public Statement getFirstStatement()
public Statement getLastStatement()
public Block setStatements(LexicalContext lc, List<Statement> statements)
lc - lexical contextstatements - new statement listpublic boolean needsScope()
public boolean isSynthetic()
public Block setFlags(LexicalContext lc, int flags)
Flagspublic Block setFlag(LexicalContext lc, int flag)
Flagspublic boolean getFlag(int flag)
Flagspublic boolean isBreakableWithoutLabel()
BreakableNodeisBreakableWithoutLabel in interface BreakableNodepublic Node accept(NodeVisitor<? extends LexicalContext> visitor)
Nodeaccept in interface LexicalContextNodeaccept in class Nodevisitor - Node visitor.public <R> R accept(TranslatorNodeVisitor<? extends LexicalContext,R> visitor)
Nodeaccept in interface LexicalContextNodeaccept in class Nodevisitor - Node visitor.public Scope getScope()
getScope in interface LexicalContextScopepublic boolean isFunctionBody()
public boolean isParameterBlock()
public boolean isSwitchBlock()
public boolean isExpressionBlock()
public boolean isModuleBody()