|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jrubyparser.StaticScope
public abstract class StaticScope
StaticScope represents lexical scoping of variables and module/class constants. At a very high level every scopes enclosing scope contains variables in the next outer lexical layer. The enclosing scopes variables may or may not be reachable depending on the scoping rules for variables (governed by BlockStaticScope and LocalStaticScope). StaticScope also keeps track of current module/class that is in scope. previousCRefScope will point to the previous scope of the enclosing module/class (cref).
| Field Summary | |
|---|---|
protected StaticScope |
enclosingScope
|
| Constructor Summary | |
|---|---|
protected |
StaticScope(StaticScope enclosingScope,
String[] names)
|
| Method Summary | |
|---|---|
int |
addVariable(String name)
|
int |
addVariableThisScope(String name)
Add a new variable to this (current) scope unless it is already defined in the current scope. |
AssignableNode |
assign(SourcePosition position,
String name,
Node value)
Make a DASgn or LocalAsgn node based on scope logic |
protected abstract AssignableNode |
assign(SourcePosition position,
String name,
Node value,
StaticScope topScope,
int depth)
|
void |
capture(int index)
|
Node |
declare(SourcePosition position,
String name)
Make a DVar or LocalVar node based on scoping logic |
protected abstract Node |
declare(SourcePosition position,
String name,
int depth)
|
int |
exists(String name)
Does the variable exist? |
abstract String[] |
getAllNamesInScope()
Get all visible variables that we can see from this scope that have been assigned (e.g. |
StaticScope |
getEnclosingScope()
Next outer most scope in list of scopes. |
abstract StaticScope |
getLocalScope()
Gets the Local Scope relative to the current Scope. |
int |
getNumberOfVariables()
|
StaticScope |
getPreviousCRefScope()
|
String[] |
getVariables()
|
boolean |
isArgumentScope()
|
boolean |
isCaptured(int index)
|
int |
isDefined(String name)
Is this name in the visible to the current scope |
protected abstract int |
isDefined(String name,
int depth)
|
void |
setArgumentScope(boolean isArgumentScope)
|
void |
setVariables(String[] names)
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final StaticScope enclosingScope
| Constructor Detail |
|---|
protected StaticScope(StaticScope enclosingScope,
String[] names)
| Method Detail |
|---|
public int addVariableThisScope(String name)
name - of new variable
public int addVariable(String name)
public String[] getVariables()
public int getNumberOfVariables()
public void setVariables(String[] names)
public StaticScope getEnclosingScope()
public int exists(String name)
name - of the variable to find
public int isDefined(String name)
name - to be looked for
public AssignableNode assign(SourcePosition position,
String name,
Node value)
position - name - value -
public abstract String[] getAllNamesInScope()
protected abstract int isDefined(String name,
int depth)
protected abstract AssignableNode assign(SourcePosition position,
String name,
Node value,
StaticScope topScope,
int depth)
protected abstract Node declare(SourcePosition position,
String name,
int depth)
public Node declare(SourcePosition position,
String name)
position - the location that in the source that the new node will come fromname - of the variable to be created is named
public void capture(int index)
public boolean isCaptured(int index)
public abstract StaticScope getLocalScope()
public StaticScope getPreviousCRefScope()
public boolean isArgumentScope()
public void setArgumentScope(boolean isArgumentScope)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||