public abstract class StaticScope
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
StaticScope.Type |
| Modifier and Type | Field and Description |
|---|---|
private RubyModule |
cref |
private DynamicScope |
dummyScope |
protected StaticScope |
enclosingScope |
private int |
optionalArgs |
private StaticScope |
previousCRefScope |
private int |
requiredArgs |
private int |
restArg |
private static long |
serialVersionUID |
private java.lang.String[] |
variableNames |
| Modifier | Constructor and Description |
|---|---|
protected |
StaticScope(StaticScope enclosingScope,
java.lang.String[] names)
Construct a new static scope.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addVariable(java.lang.String name)
Add a new variable to this (current) scope unless it is already defined in any
reachable scope.
|
int |
addVariableThisScope(java.lang.String name)
Add a new variable to this (current) scope unless it is already defined in the
current scope.
|
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) |
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?
|
private int |
findVariableName(java.lang.String name) |
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(java.lang.String internedName) |
IRubyObject |
getConstantInner(java.lang.String internedName) |
private IRubyObject |
getConstantInnerNoObject(java.lang.String internedName) |
IRubyObject |
getConstantWithConstMissing(java.lang.String internedName) |
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() |
abstract StaticScope.Type |
getType() |
java.lang.String[] |
getVariables() |
private void |
growVariableNames(java.lang.String name) |
abstract boolean |
isArgumentScope()
Argument scopes represent scopes which contain arguments for zsuper.
|
boolean |
isBlockScope() |
boolean |
isConstantDefined(java.lang.String internedName) |
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) |
abstract void |
makeArgumentScope() |
private static boolean |
namesAreInterned(java.lang.String[] names)
Check that all strings in the given array are the interned versions.
|
void |
setArities(int required,
int optional,
int rest) |
IRubyObject |
setConstant(java.lang.String internedName,
IRubyObject result) |
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() |
private static final long serialVersionUID
protected final StaticScope enclosingScope
private transient RubyModule cref
private StaticScope previousCRefScope
private java.lang.String[] variableNames
private int requiredArgs
private int optionalArgs
private int restArg
private DynamicScope dummyScope
protected StaticScope(StaticScope enclosingScope, java.lang.String[] names)
enclosingScope - The lexically containing scope.names - The list of interned String variable names.private static boolean namesAreInterned(java.lang.String[] names)
names - The array of stringspublic int addVariableThisScope(java.lang.String name)
name - of new variablepublic int addVariable(java.lang.String name)
name - of new variablepublic java.lang.String[] getVariables()
public int getNumberOfVariables()
public void setVariables(java.lang.String[] names)
public IRubyObject getConstantWithConstMissing(java.lang.String internedName)
public boolean isConstantDefined(java.lang.String internedName)
public IRubyObject getConstant(java.lang.String internedName)
public IRubyObject getConstantInner(java.lang.String internedName)
private IRubyObject getConstantInnerNoObject(java.lang.String internedName)
public IRubyObject setConstant(java.lang.String internedName, IRubyObject result)
public StaticScope getEnclosingScope()
public int exists(java.lang.String name)
name - of the variable to findprivate int findVariableName(java.lang.String name)
public int isDefined(java.lang.String name)
name - to be looked forpublic 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 namedpublic 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 abstract boolean isArgumentScope()
public abstract void makeArgumentScope()
public boolean isBlockScope()
public Arity getArity()
public void setArities(int required,
int optional,
int rest)
public DynamicScope getDummyScope()
private void growVariableNames(java.lang.String name)
public java.lang.String toString()
toString in class java.lang.Objectpublic abstract StaticScope.Type getType()