|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.parser.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,
java.lang.String[] names)
Construct a new static scope. |
Method Summary | |
---|---|
int |
addVariable(java.lang.String name)
|
AssignableNode |
assign(ISourcePosition position,
java.lang.String name,
Node value)
Make a DASgn or LocalAsgn node based on scope logic |
protected abstract AssignableNode |
assign(ISourcePosition position,
java.lang.String name,
Node value,
StaticScope topScope,
int depth)
|
void |
capture(int index)
|
Node |
declare(ISourcePosition position,
java.lang.String name)
Make a DVar or LocalVar node based on scoping logic |
protected abstract Node |
declare(ISourcePosition position,
java.lang.String name,
int depth)
|
RubyModule |
determineModule()
Update current scoping structure to populate with proper cref scoping values. |
int |
exists(java.lang.String name)
Does the variable exist? |
abstract java.lang.String[] |
getAllNamesInScope()
Get all visible variables that we can see from this scope that have been assigned (e.g. |
Arity |
getArity()
|
IRubyObject |
getConstant(Ruby runtime,
java.lang.String internedName,
RubyModule object)
|
IRubyObject |
getConstantWithConstMissing(Ruby runtime,
java.lang.String internedName,
RubyModule object)
|
DynamicScope |
getDummyScope()
|
StaticScope |
getEnclosingScope()
Next outer most scope in list of scopes. |
abstract StaticScope |
getLocalScope()
Gets the Local Scope relative to the current Scope. |
RubyModule |
getModule()
Get the live CRef module associated with this scope. |
int |
getNumberOfVariables()
|
int |
getOptionalArgs()
|
StaticScope |
getPreviousCRefScope()
|
int |
getRequiredArgs()
|
int |
getRestArg()
|
java.lang.String[] |
getVariables()
|
boolean |
isArgumentScope()
|
boolean |
isBackrefLastlineScope()
|
boolean |
isCaptured(int index)
|
int |
isDefined(java.lang.String name)
Is this name in the visible to the current scope |
protected abstract int |
isDefined(java.lang.String name,
int depth)
|
void |
setArgumentScope(boolean isArgumentScope)
|
void |
setArities(int required,
int optional,
int rest)
|
void |
setBackrefLastlineScope(boolean isBackrefLastlineScope)
|
void |
setModule(RubyModule module)
|
void |
setPreviousCRefScope(StaticScope crefScope)
|
void |
setRequiredArgs(int requiredArgs)
|
void |
setRestArg(int restArg)
|
void |
setVariables(java.lang.String[] names)
|
java.lang.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, java.lang.String[] names)
enclosingScope
- The lexically containing scope.names
- The list of interned String variable names.Method Detail |
---|
public int addVariable(java.lang.String name)
public java.lang.String[] getVariables()
public int getNumberOfVariables()
public void setVariables(java.lang.String[] names)
public IRubyObject getConstantWithConstMissing(Ruby runtime, java.lang.String internedName, RubyModule object)
public IRubyObject getConstant(Ruby runtime, java.lang.String internedName, RubyModule object)
public StaticScope getEnclosingScope()
public int exists(java.lang.String name)
name
- of the variable to find
public int isDefined(java.lang.String name)
name
- to be looked for
public AssignableNode assign(ISourcePosition position, java.lang.String name, Node value)
position
- name
- value
-
public abstract java.lang.String[] getAllNamesInScope()
protected abstract int isDefined(java.lang.String name, int depth)
protected abstract AssignableNode assign(ISourcePosition position, java.lang.String name, Node value, StaticScope topScope, int depth)
protected abstract Node declare(ISourcePosition position, java.lang.String name, int depth)
public Node declare(ISourcePosition position, java.lang.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 RubyModule getModule()
public StaticScope getPreviousCRefScope()
public void setPreviousCRefScope(StaticScope crefScope)
public void setModule(RubyModule module)
public RubyModule determineModule()
public int getOptionalArgs()
public int getRequiredArgs()
public void setRequiredArgs(int requiredArgs)
public int getRestArg()
public void setRestArg(int restArg)
public boolean isArgumentScope()
public void setArgumentScope(boolean isArgumentScope)
public boolean isBackrefLastlineScope()
public void setBackrefLastlineScope(boolean isBackrefLastlineScope)
public Arity getArity()
public void setArities(int required, int optional, int rest)
public DynamicScope getDummyScope()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |