|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.javascript.jscomp.Scope
public class Scope
Scope contains information about a variable scope in javascript. Scopes can be nested, a scope points back to its parent scope. A Scope contains information about variables defined in that scope.
A Scope is also used as a lattice element for flow-sensitive type inference.
As a lattice element, a Scope is viewed as a map from names to types. A name
not in the map is considered to have the bottom type. The join of two maps m1
and m2 is the map of the union of names with JSType.getLeastSupertype(com.google.javascript.rhino.jstype.JSType)
to meet the m1 type and m2 type.
NodeTraversal
,
DataFlowAnalysis
Nested Class Summary | |
---|---|
static class |
Scope.Arguments
A special subclass of Var used to distinguish "arguments" in the current scope. |
static class |
Scope.Var
Stores info about a variable |
Method Summary | |
---|---|
Iterable<Scope.Var> |
getAllSymbols()
Returns all variables in this symbol table. |
Scope.Var |
getArgumentsVar()
Get a unique VAR object to represents "arguments" within this scope |
Iterator<Scope.Var> |
getDeclarativelyUnboundVarsWithoutTypes()
Gets all variables declared with "var" but without declared types attached. |
StaticSlot<JSType> |
getOwnSlot(String name)
Like getSlot but does not recurse into parent scopes. |
Scope |
getParent()
|
StaticScope<JSType> |
getParentScope()
Returns the scope enclosing this one or null if none. |
Iterable<Scope.Var> |
getReferences(Scope.Var var)
Returns the references that point to the given symbol. |
Node |
getRootNode()
Gets the container node of the scope. |
StaticScope<JSType> |
getScope(Scope.Var var)
Returns the scope for a given symbol. |
StaticSlot<JSType> |
getSlot(String name)
Returns any defined slot within this scope for this name. |
ObjectType |
getTypeOfThis()
Gets the type of this in the current scope. |
Scope.Var |
getVar(String name)
Returns the variable, may be null |
int |
getVarCount()
Returns number of variables in this scope |
Iterator<Scope.Var> |
getVars()
Return an iterator over all of the variables declared in this scope. |
boolean |
isDeclared(String name,
boolean recurse)
Returns true if a variable is declared. |
boolean |
isGlobal()
Returns whether this is the global scope. |
boolean |
isLocal()
Returns whether this is a local scope (i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public Node getRootNode()
getRootNode
in interface StaticScope<JSType>
public Scope getParent()
public StaticScope<JSType> getParentScope()
StaticScope
getParentScope
in interface StaticScope<JSType>
public ObjectType getTypeOfThis()
this
in the current scope.
getTypeOfThis
in interface StaticScope<JSType>
public StaticSlot<JSType> getSlot(String name)
StaticScope
getSlot
in interface StaticScope<JSType>
name
- The name of the variable slot to look up.
null
if no
definition exists.public StaticSlot<JSType> getOwnSlot(String name)
StaticScope
getSlot
but does not recurse into parent scopes.
getOwnSlot
in interface StaticScope<JSType>
public Scope.Var getVar(String name)
public Scope.Var getArgumentsVar()
public boolean isDeclared(String name, boolean recurse)
public Iterator<Scope.Var> getVars()
public Iterable<Scope.Var> getReferences(Scope.Var var)
StaticSymbolTable
getReferences
in interface StaticSymbolTable<Scope.Var,Scope.Var>
public StaticScope<JSType> getScope(Scope.Var var)
StaticSymbolTable
getScope
in interface StaticSymbolTable<Scope.Var,Scope.Var>
public Iterable<Scope.Var> getAllSymbols()
StaticSymbolTable
getAllSymbols
in interface StaticSymbolTable<Scope.Var,Scope.Var>
public int getVarCount()
public boolean isGlobal()
public boolean isLocal()
public Iterator<Scope.Var> getDeclarativelyUnboundVarsWithoutTypes()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |