| java.lang.Object com.go.tea.compiler.Scope
Scope | public class Scope (Code) | | 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.
author: Brian S O'Neill version: 28 , 00/11/16 |
bindToVariable | public boolean bindToVariable(VariableRef ref)(Code) | | Attempt to bind variable reference to a variable in this scope or a
parent scope. If the variable to bind to isn't available or doesn't
exist, false is returned.
true if reference has been bound |
declareVariable | public Variable declareVariable(Variable var)(Code) | | Declare a variable for use in this scope. If no variable of this name
and type has been defined, it is added to the shared set of pooled
variables. Returns the actual Variable object that should be used.
|
declareVariable | public Variable declareVariable(Variable var, boolean isPrivate)(Code) | | Declare a variable for use in this scope. If no variable of this name
and type has been defined, it is added to the shared set of pooled
variables. Returns the actual Variable object that should be used
instead.
Parameters: isPrivate - when true, variable declaration doesn't leave thisscope during an intersection or promotion |
declareVariables | public void declareVariables(Variable[] vars)(Code) | | Declare new variables in this scope. Entries in the array are replaced
with actual Variable objects that should be used instead.
|
delete | public void delete()(Code) | | Delete this scope by detaching it from its parent.
|
getChildren | public Scope[] getChildren()(Code) | | Returns an empty array if this scope has no children.
|
getDeclaredVariable | public Variable getDeclaredVariable(String name)(Code) | | Returns a declared variable by name. Search begins in this scope and
moves up into parent scopes. If not found, null is returned. The
returned variable may be private or public to a scope.
Null if no declared variable found with the given name |
getDeclaredVariable | public Variable getDeclaredVariable(String name, boolean publicOnly)(Code) | | Returns a declared variable by name. Search begins in this scope and
moves up into parent scopes. If not found, null is returned. A public-
only variable can be requested.
Null if no declared variable found with the given name |
getEnclosingScope | public Scope getEnclosingScope(Scope scope)(Code) | | Returns the innermost enclosing scope of this and the one given. If no
enclosing scope exists, null is returned.
|
getLocalOutOfScopeVariableRefs | public VariableRef[] getLocalOutOfScopeVariableRefs()(Code) | | Returns all the references made from this scope to variables declared
outside of this scope.
|
getLocalVariableRefs | public VariableRef[] getLocalVariableRefs()(Code) | | Returns all the references made from this scope to variables declared
in this scope or in a parent.
non-null array of VariableRefs. |
getOutOfScopeVariableRefs | public VariableRef[] getOutOfScopeVariableRefs()(Code) | | Returns all the references made from this scope and all child scopes to
variables declared outside of this scope.
|
getParent | public Scope getParent()(Code) | | Returns null if this scope has no parent.
|
getVariableRefs | public VariableRef[] getVariableRefs()(Code) | | Returns all the variable references made from this scope and all child
scopes.
non-null array of VariableRefs. |
intersect | public Variable[] intersect(Scope scope)(Code) | | Returns the intersection of this scope against the one given. An
intersection operates on each scope's locally declared variables,
producing a list of variables that both scopes may inherit.
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.
variables representing the intersection |
isEnclosing | public boolean isEnclosing(Scope scope)(Code) | | Returns true if this scope is the same as or a parent of the one given.
|
promote | public Variable[] promote()(Code) | | Returns variables to promote from this scope to a parent scope.
Promote is similar to intersect, except it operates on this scope and
its parent (if it has one).
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.
variables to promote |
|
|