|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.teatrove.tea.compiler.Scope
public class Scope
A Scope encapsulates a set of declared variables and references to them. Scopes can be nested, and child scopes have access to variables in the parent scope.
| Constructor Summary | |
|---|---|
Scope()
|
|
Scope(Scope parent)
|
|
| Method Summary | |
|---|---|
boolean |
bindToVariable(VariableRef ref)
Attempt to bind variable reference to a variable in this scope or a parent scope. |
Variable |
declareVariable(Variable var)
Declare a variable for use in this scope. |
Variable |
declareVariable(Variable var,
boolean isPrivate)
Declare a variable for use in this scope. |
void |
declareVariables(Variable[] vars)
Declare new variables in this scope. |
void |
delete()
Delete this scope by detaching it from its parent. |
Scope[] |
getChildren()
Returns an empty array if this scope has no children. |
Variable |
getDeclaredVariable(String name)
Returns a declared variable by name. |
Variable |
getDeclaredVariable(String name,
boolean publicOnly)
Returns a declared variable by name. |
Scope |
getEnclosingScope(Scope scope)
Returns the innermost enclosing scope of this and the one given. |
VariableRef[] |
getLocalOutOfScopeVariableRefs()
Returns all the references made from this scope to variables declared outside of this scope. |
VariableRef[] |
getLocalVariableRefs()
Returns all the references made from this scope to variables declared in this scope or in a parent. |
VariableRef[] |
getOutOfScopeVariableRefs()
Returns all the references made from this scope and all child scopes to variables declared outside of this scope. |
Scope |
getParent()
Returns null if this scope has no parent. |
VariableRef[] |
getVariableRefs()
Returns all the variable references made from this scope and all child scopes. |
Variable[] |
intersect(Scope scope)
Returns the intersection of this scope against the one given. |
boolean |
isEnclosing(Scope scope)
Returns true if this scope is the same as or a parent of the one given. |
Variable[] |
promote()
Returns variables to promote from this scope to a parent scope. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Scope()
public Scope(Scope parent)
| Method Detail |
|---|
public Scope getParent()
public Scope[] getChildren()
public Variable declareVariable(Variable var)
public Variable declareVariable(Variable var,
boolean isPrivate)
isPrivate - when true, variable declaration doesn't leave this
scope during an intersection or promotionpublic void declareVariables(Variable[] vars)
public Variable getDeclaredVariable(String name)
public Variable getDeclaredVariable(String name,
boolean publicOnly)
public boolean bindToVariable(VariableRef ref)
public VariableRef[] getVariableRefs()
public VariableRef[] getLocalVariableRefs()
public VariableRef[] getOutOfScopeVariableRefs()
public VariableRef[] getLocalOutOfScopeVariableRefs()
public boolean isEnclosing(Scope scope)
public Scope getEnclosingScope(Scope scope)
public Variable[] intersect(Scope scope)
The list may contain undeclared variables, and so all returned variables must be re-declared in a common parent scope. This responsibility is left to the caller, intersect does not alter the internal state of either scope.
This method is designed specifically for combining the locally declared variables of the "then" and "else" parts of an if statement.
public Variable[] promote()
The list may contain undeclared variables, and so all returned variables must be re-declared in a common parent scope. This responsibility is left to the caller, promote does not alter the internal state of this scope or its parent.
This method is designed specifically for promoting the locally declared variables of a loop statement's body.
public void delete()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||