|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.dart.compiler.backend.js.ast.JsScope
public class JsScope
A scope is a factory for creating and allocating
JsName
s. A JavaScript AST is
built in terms of abstract name objects without worrying about obfuscation,
keyword/identifier blacklisting, and so on.
JsFunction
s, but the two are
not equivalent. Functions have scopes, but a scope does not
necessarily have an associated Function. Examples of this include the
JsRootScope
and synthetic
scopes that might be created by a client.
Scopes can have parents to provide constraints when allocating actual
identifiers for names. Specifically, names in child scopes are chosen such
that they do not conflict with names in their parent scopes. The ultimate
parent is usually the global scope (see
JsProgram.getRootScope()
),
but parentless scopes are useful for managing names that are always accessed
with a qualifier and could therefore never be confused with the global scope
hierarchy.
Field Summary | |
---|---|
protected int |
tempIndex
|
Constructor Summary | |
---|---|
|
JsScope(JsScope parent)
|
|
JsScope(JsScope parent,
java.lang.String description)
|
|
JsScope(JsScope parent,
java.lang.String description,
java.lang.String scopeId)
|
protected |
JsScope(java.lang.String description)
|
Method Summary | |
---|---|
JsName |
declareFreshName(java.lang.String suggestedName)
Creates a new variable with an unique ident in this scope. |
JsName |
declareName(java.lang.String identifier)
Gets a name object associated with the specified identifier in this scope, creating it if necessary. If the JsName does not exist yet, a new JsName is created. |
JsName |
declareTemporary()
Creates a temporary variable with an unique name in this scope. |
protected JsName |
doCreateName(java.lang.String ident)
|
JsName |
findName(java.lang.String ident)
Attempts to find the name object for the specified ident, searching in this scope, and if not found, in the parent scopes. |
protected JsName |
findOwnName(java.lang.String ident)
Attempts to find the name object for the specified ident, searching in this scope only. |
JsScope |
getParent()
Returns the parent scope of this scope, or null if this is the
root scope. |
JsProgram |
getProgram()
|
protected boolean |
hasOwnName(java.lang.String name)
|
JsScope |
innerScope(java.lang.String scopeName)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int tempIndex
Constructor Detail |
---|
public JsScope(JsScope parent, @Nullable java.lang.String description)
public JsScope(JsScope parent)
public JsScope(JsScope parent, @Nullable java.lang.String description, @Nullable java.lang.String scopeId)
protected JsScope(@Nullable java.lang.String description)
Method Detail |
---|
@NotNull public JsScope innerScope(@Nullable java.lang.String scopeName)
public JsName declareName(java.lang.String identifier)
identifier
- An identifier that is unique within this scope.@NotNull public JsName declareFreshName(java.lang.String suggestedName)
public JsName declareTemporary()
@Nullable public final JsName findName(java.lang.String ident)
null
if the identifier has no associated nameprotected boolean hasOwnName(@NotNull java.lang.String name)
public final JsScope getParent()
null
if this is the
root scope.
public JsProgram getProgram()
public final java.lang.String toString()
toString
in class java.lang.Object
protected JsName doCreateName(java.lang.String ident)
protected JsName findOwnName(java.lang.String ident)
null
if the identifier has no associated name
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |