Class Scope
java.lang.Object
com.oracle.js.parser.ir.Scope
Represents a binding scope (corresponds to LexicalEnvironment or VariableEnvironment).
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIdentifierReference(String name) Records the use of an identifier reference in this scope to be resolved.booleanaddPrivateName(com.oracle.truffle.api.strings.TruffleString name, int symbolFlags) Add a private bound identifier.voidclose()Closes the scope for symbol registration.static ScopecreateBlock(Scope parent) static ScopecreateCatchParameter(Scope parent) static ScopecreateClassBody(Scope parent) static ScopecreateClassHead(Scope parent) static ScopecreateEval(Scope parent, boolean strict) static ScopecreateFunctionBody(Scope parent) static ScopecreateFunctionBody(Scope parent, int functionFlags, boolean functionTopScope) static ScopecreateFunctionParameter(Scope parent, int functionFlags) static Scopestatic Scopestatic ScopecreateSwitchBlock(Scope parent) findBlockScopedSymbolInFunction(String varName) Returns a block scoped symbol in this scope or any of its enclosing scopes within this function.booleanfindPrivateName(String name) getExistingSymbol(String name) Retrieves an existing symbol defined in the current block.intGet the number of symbols defined in this block.Get all the symbols defined in this block, in definition order.booleanbooleanReturns true if the scope has closed over variables.booleanbooleanhasEval()Does this scope contain a direct eval.booleanDoes this scope or any nested scopes contain a direct eval.booleanbooleanTest if a symbol with this name is defined in the current block.booleanbooleanbooleanbooleaninMethod()booleanbooleanbooleanbooleanbooleanbooleanisClosed()booleanbooleanbooleanbooleanbooleanbooleanisLexicallyDeclaredName(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.booleanbooleanvoidkill()Clears defined symbols and moves any local uses into the parent scope.Add symbol to the scope if it does not already exist.voidResolves free variables in this scope and forwards unresolved uses to the parent scope.voidMarks this scope as containing a direct eval.voidtoString()
-
Field Details
-
symbols
-
uses
Use map.
-
-
Method Details
-
createGlobal
-
createModule
-
createFunctionBody
-
createFunctionBody
-
createBlock
-
createCatchParameter
-
createFunctionParameter
-
createSwitchBlock
-
createClassHead
-
createClassBody
-
createEval
-
getParent
-
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. -
putSymbol
-
hasBlockScopedOrRedeclaredSymbols
public boolean hasBlockScopedOrRedeclaredSymbols() -
hasPrivateNames
public boolean hasPrivateNames() -
hasDeclarations
public boolean hasDeclarations() -
isLexicallyDeclaredName
Returns true if the name is lexically declared in this scope or any of its enclosing scopes within this function.- Parameters:
varName- the declared nameannexB- if true, ignore catch parametersincludeParameters- include parameter scope?
-
findBlockScopedSymbolInFunction
-
addPrivateName
public boolean addPrivateName(com.oracle.truffle.api.strings.TruffleString name, int symbolFlags) Add a private bound identifier.- Returns:
- true if the private name was added, false if it was already declared (duplicate name)
-
findPrivateName
-
isBlockScope
public boolean isBlockScope() -
isFunctionBodyScope
public boolean isFunctionBodyScope() -
isFunctionParameterScope
public boolean isFunctionParameterScope() -
isCatchParameterScope
public boolean isCatchParameterScope() -
isGlobalScope
public boolean isGlobalScope() -
isModuleScope
public boolean isModuleScope() -
isFunctionTopScope
public boolean isFunctionTopScope() -
isSwitchBlockScope
public boolean isSwitchBlockScope() -
isClassBodyScope
public boolean isClassBodyScope() -
isClassHeadScope
public boolean isClassHeadScope() -
isEvalScope
public boolean isEvalScope() -
isArrowFunctionParameterScope
public boolean isArrowFunctionParameterScope() -
inFunction
public boolean inFunction() -
inMethod
public boolean inMethod() -
inDerivedConstructor
public boolean inDerivedConstructor() -
inClassFieldInitializer
public boolean inClassFieldInitializer() -
close
public void close()Closes the scope for symbol registration. -
isClosed
public boolean isClosed() -
kill
public void kill()Clears defined symbols and moves any local uses into the parent scope. -
addIdentifierReference
Records the use of an identifier reference in this scope to be resolved. -
resolveUses
public void resolveUses()Resolves free variables in this scope and forwards unresolved uses to the parent scope. -
hasClosures
public boolean hasClosures()Returns true if the scope has closed over variables. -
hasEval
public boolean hasEval()Does this scope contain a direct eval. -
setHasEval
public void setHasEval()Marks this scope as containing a direct eval. -
hasNestedEval
public boolean hasNestedEval()Does this scope or any nested scopes contain a direct eval. -
setHasNestedEval
public void setHasNestedEval() -
toString
-