public class StaticScope extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
StaticScope.Type |
Modifier and Type | Field and Description |
---|---|
protected StaticScope |
enclosingScope |
protected IRScopeType |
scopeType |
Modifier | Constructor and Description |
---|---|
protected |
StaticScope(StaticScope.Type type,
StaticScope enclosingScope)
Construct a new static scope.
|
protected |
StaticScope(StaticScope.Type type,
StaticScope enclosingScope,
String[] names)
Construct a new static scope.
|
Modifier and Type | Method and Description |
---|---|
AssignableNode |
addAssign(ISourcePosition position,
String name,
Node value) |
int |
addVariable(String name)
Add a new variable to this (current) scope unless it is already defined in any
reachable scope.
|
int |
addVariableThisScope(String name)
Add a new variable to this (current) scope unless it is already defined in the
current scope.
|
AssignableNode |
assign(ISourcePosition position,
String name,
Node value)
Make a DASgn or LocalAsgn node based on scope logic
|
AssignableNode |
assign(ISourcePosition position,
String name,
Node value,
StaticScope topScope,
int depth) |
Node |
declare(ISourcePosition position,
String name)
Make a DVar or LocalVar node based on scoping logic
|
Node |
declare(ISourcePosition position,
String name,
int depth) |
RubyModule |
determineModule()
Update current scoping structure to populate with proper cref scoping values.
|
StaticScope |
duplicate() |
int |
exists(String name)
Does the variable exist?
|
String[] |
getAllNamesInScope()
Get all visible variables that we can see from this scope that have been assigned
(e.g.
|
Arity |
getArity() |
IRubyObject |
getConstant(String internedName) |
IRubyObject |
getConstantInner(String internedName) |
IRubyObject |
getConstantWithConstMissing(String internedName) |
DynamicScope |
getDummyScope() |
StaticScope |
getEnclosingScope()
Next outer most scope in list of scopes.
|
IRScope |
getIRScope() |
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() |
int |
getScopeId() |
IRScopeType |
getScopeType() |
StaticScope.Type |
getType() |
String[] |
getVariables() |
boolean |
isArgumentScope()
Argument scopes represent scopes which contain arguments for zsuper.
|
boolean |
isBlockScope() |
boolean |
isConstantDefined(String internedName) |
int |
isDefined(String name)
Is this name in the visible to the current scope
|
int |
isDefined(String name,
int depth) |
void |
makeArgumentScope() |
void |
setArities(int required,
int optional,
int rest) |
IRubyObject |
setConstant(String internedName,
IRubyObject result) |
void |
setIRScope(IRScope irScope) |
void |
setIRScope(IRScope irScope,
boolean isForLoopBody) |
void |
setModule(RubyModule module) |
void |
setPreviousCRefScope(StaticScope crefScope) |
void |
setRequiredArgs(int requiredArgs) |
void |
setRestArg(int restArg) |
void |
setScopeType(IRScopeType scopeType) |
void |
setVariables(String[] names) |
String |
toString() |
protected final StaticScope enclosingScope
protected IRScopeType scopeType
protected StaticScope(StaticScope.Type type, StaticScope enclosingScope)
type
- the type of scopeenclosingScope
- the lexically containing scope.protected StaticScope(StaticScope.Type type, StaticScope enclosingScope, String[] names)
type
- the type of scopeenclosingScope
- the lexically containing scope.names
- The list of interned String variable names.public IRScope getIRScope()
public int getScopeId()
public IRScopeType getScopeType()
public void setScopeType(IRScopeType scopeType)
public void setIRScope(IRScope irScope, boolean isForLoopBody)
public void setIRScope(IRScope irScope)
public int addVariableThisScope(String name)
name
- of new variablepublic int addVariable(String name)
name
- of new variablepublic String[] getVariables()
public int getNumberOfVariables()
public void setVariables(String[] names)
public IRubyObject getConstantWithConstMissing(String internedName)
public boolean isConstantDefined(String internedName)
public IRubyObject getConstant(String internedName)
public IRubyObject getConstantInner(String internedName)
public IRubyObject setConstant(String internedName, IRubyObject result)
public StaticScope getEnclosingScope()
public int exists(String name)
name
- of the variable to findpublic int isDefined(String name)
name
- to be looked forpublic AssignableNode assign(ISourcePosition position, String name, Node value)
position
- name
- value
- public String[] getAllNamesInScope()
public int isDefined(String name, int depth)
public AssignableNode addAssign(ISourcePosition position, String name, Node value)
public AssignableNode assign(ISourcePosition position, String name, Node value, StaticScope topScope, int depth)
public Node declare(ISourcePosition position, String name, int depth)
public Node declare(ISourcePosition position, String name)
position
- the location that in the source that the new node will come fromname
- of the variable to be created is namedpublic 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 isBlockScope()
public boolean isArgumentScope()
public void makeArgumentScope()
public Arity getArity()
public void setArities(int required, int optional, int rest)
public DynamicScope getDummyScope()
public StaticScope.Type getType()
public StaticScope duplicate()
Copyright © 2001-2015 JRuby. All Rights Reserved.