public final class Scope extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.graalvm.collections.EconomicMap<String,Symbol> |
symbols
Symbol table - keys must be returned in the order they were put in.
|
protected org.graalvm.collections.EconomicMap<String,com.oracle.js.parser.ir.Scope.UseInfo> |
uses
Use map.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addIdentifierReference(String name)
Records the use of an identifier reference in this scope to be resolved.
|
boolean |
addPrivateName(com.oracle.truffle.api.strings.TruffleString name,
int symbolFlags)
Add a private bound identifier.
|
void |
close()
Closes the scope for symbol registration.
|
static Scope |
createBlock(Scope parent) |
static Scope |
createCatchParameter(Scope parent) |
static Scope |
createClassBody(Scope parent) |
static Scope |
createClassHead(Scope parent) |
static Scope |
createEval(Scope parent,
boolean strict) |
static Scope |
createFunctionBody(Scope parent) |
static Scope |
createFunctionBody(Scope parent,
int functionFlags,
boolean functionTopScope) |
static Scope |
createFunctionParameter(Scope parent,
int functionFlags) |
static Scope |
createGlobal() |
static Scope |
createModule() |
static Scope |
createSwitchBlock(Scope parent) |
Symbol |
findBlockScopedSymbolInFunction(String varName)
Returns a block scoped symbol in this scope or any of its enclosing scopes within this
function.
|
boolean |
findPrivateName(String name) |
Symbol |
getExistingSymbol(String name)
Retrieves an existing symbol defined in the current block.
|
Scope |
getParent() |
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 |
hasBlockScopedOrRedeclaredSymbols() |
boolean |
hasClosures()
Returns true if the scope has closed over variables.
|
boolean |
hasDeclarations() |
boolean |
hasEval()
Does this scope contain a direct eval.
|
boolean |
hasNestedEval()
Does this scope or any nested scopes contain a direct eval.
|
boolean |
hasPrivateNames() |
boolean |
hasSymbol(String name)
Test if a symbol with this name is defined in the current block.
|
boolean |
inClassFieldInitializer() |
boolean |
inDerivedConstructor() |
boolean |
inFunction() |
boolean |
inMethod() |
boolean |
isArrowFunctionParameterScope() |
boolean |
isBlockScope() |
boolean |
isCatchParameterScope() |
boolean |
isClassBodyScope() |
boolean |
isClassHeadScope() |
boolean |
isClosed() |
boolean |
isEvalScope() |
boolean |
isFunctionBodyScope() |
boolean |
isFunctionParameterScope() |
boolean |
isFunctionTopScope() |
boolean |
isGlobalScope() |
boolean |
isLexicallyDeclaredName(String varName,
boolean annexB,
boolean includeParameters)
Returns true if the name is lexically declared in this scope or any of its enclosing scopes
within this function.
|
boolean |
isModuleScope() |
boolean |
isSwitchBlockScope() |
void |
kill()
Clears defined symbols and moves any local uses into the parent scope.
|
Symbol |
putSymbol(Symbol symbol)
Add symbol to the scope if it does not already exist.
|
void |
resolveUses()
Resolves free variables in this scope and forwards unresolved uses to the parent scope.
|
void |
setHasEval()
Marks this scope as containing a direct eval.
|
void |
setHasNestedEval() |
String |
toString() |
protected final org.graalvm.collections.EconomicMap<String,Symbol> symbols
protected org.graalvm.collections.EconomicMap<String,com.oracle.js.parser.ir.Scope.UseInfo> uses
public static Scope createGlobal()
public static Scope createModule()
public static Scope createFunctionBody(Scope parent, int functionFlags, boolean functionTopScope)
public static Scope createFunctionParameter(Scope parent, int functionFlags)
public Scope getParent()
public 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 Symbol putSymbol(Symbol symbol)
public boolean hasBlockScopedOrRedeclaredSymbols()
public boolean hasPrivateNames()
public boolean hasDeclarations()
public boolean isLexicallyDeclaredName(String varName, boolean annexB, boolean includeParameters)
varName - the declared nameannexB - if true, ignore catch parametersincludeParameters - include parameter scope?public Symbol findBlockScopedSymbolInFunction(String varName)
varName - the symbol namepublic boolean addPrivateName(com.oracle.truffle.api.strings.TruffleString name,
int symbolFlags)
public boolean findPrivateName(String name)
public boolean isBlockScope()
public boolean isFunctionBodyScope()
public boolean isFunctionParameterScope()
public boolean isCatchParameterScope()
public boolean isGlobalScope()
public boolean isModuleScope()
public boolean isFunctionTopScope()
public boolean isSwitchBlockScope()
public boolean isClassBodyScope()
public boolean isClassHeadScope()
public boolean isEvalScope()
public boolean isArrowFunctionParameterScope()
public boolean inFunction()
public boolean inMethod()
public boolean inDerivedConstructor()
public boolean inClassFieldInitializer()
public void close()
public boolean isClosed()
public void kill()
public void addIdentifierReference(String name)
public void resolveUses()
public boolean hasClosures()
public boolean hasEval()
public void setHasEval()
public boolean hasNestedEval()
public void setHasNestedEval()