public 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 |
|---|---|
protected StaticScope |
enclosingScope |
static int |
MAX_SPECIALIZED_SIZE |
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,
java.lang.String file) |
protected |
StaticScope(StaticScope.Type type,
StaticScope enclosingScope,
java.lang.String[] names) |
protected |
StaticScope(StaticScope.Type type,
StaticScope enclosingScope,
java.lang.String[] names,
int firstKeywordIndex)
Construct a new static scope.
|
protected |
StaticScope(StaticScope.Type type,
StaticScope enclosingScope,
java.lang.String file,
java.lang.String[] names,
int firstKeywordIndex) |
| Modifier and Type | Method and Description |
|---|---|
AssignableNode |
addAssign(int line,
RubySymbol symbolID,
Node value) |
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(int line,
RubySymbol name,
Node value)
Make a DASgn or LocalAsgn node based on scope logic
Note: This is private code made public only for parser.
|
AssignableNode |
assign(int line,
RubySymbol symbolID,
Node value,
StaticScope topScope,
int depth) |
AssignableNode |
assignKeyword(int line,
RubySymbol symbolID,
Node value)
Register a keyword argument with this staticScope.
|
void |
captureParentRefinements(ThreadContext context)
Duplicate the parent scope's refinements overlay to get a moment-in-time snapshot.
|
<T> T |
collectVariables(java.util.function.IntFunction<T> collectionFactory,
java.util.function.BiConsumer<T,java.lang.String> collectionPopulator)
Populate a deduplicated collection of variable names in scope using the given functions.
|
DynamicScope |
construct(DynamicScope parent) |
Node |
declare(int line,
RubySymbol symbolID)
Make a DVar or LocalVar node based on scoping logic
|
Node |
declare(int line,
RubySymbol symbolID,
int depth) |
RubyModule |
determineModule()
Update current scoping structure to populate with proper cref scoping values.
|
StaticScope |
duplicate() |
int |
exists(java.lang.String name)
Does the variable exist?
|
java.lang.String[] |
getAllNamesInScope()
Get all visible variables that we can see from this scope that have been assigned
(e.g.
|
IRubyObject |
getConstant(java.lang.String internedName) |
IRubyObject |
getConstantDefined(java.lang.String internedName)
Gets a constant back from lexical search from the cref in this scope.
|
IRubyObject |
getConstantDefinedNoObject(java.lang.String internedName) |
IRubyObject |
getConstantInner(java.lang.String internedName) |
DynamicScope |
getDummyScope() |
StaticScope |
getEnclosingScope()
Next outer most scope in list of scopes.
|
java.lang.String |
getFile() |
int |
getFirstKeywordIndex() |
java.util.Collection<java.lang.String> |
getInstanceVariableNames() |
IRScope |
getIRScope() |
StaticScope |
getLocalScope()
Gets the Local Scope relative to the current Scope.
|
RubyArray |
getLocalVariables(Ruby runtime)
Convenience wrapper around
collectVariables(IntFunction, BiConsumer). |
RubyModule |
getModule()
Get the live CRef module associated with this scope.
|
int |
getNumberOfVariables() |
RubyModule |
getOverlayModuleForRead() |
RubyModule |
getOverlayModuleForWrite(ThreadContext context) |
StaticScope |
getPreviousCRefScope() |
IRScopeType |
getScopeType() |
Signature |
getSignature()
For all block or method associated with static scopes this will return the signature for that
signature-providing scope.
|
StaticScope.Type |
getType() |
java.lang.String[] |
getVariables() |
boolean |
isArgumentScope()
Argument scopes represent scopes which contain arguments for zsuper.
|
boolean |
isBlockScope() |
int |
isDefined(java.lang.String name)
Is this name in the visible to the current scope
|
int |
isDefined(java.lang.String name,
int depth) |
boolean |
isWithinMethod()
Determine if we happen to be within a method definition.
|
boolean |
keywordExists(java.lang.String name) |
void |
makeArgumentScope() |
void |
setEnclosingScope(StaticScope parent) |
void |
setFile(java.lang.String file) |
void |
setInstanceVariableNames(java.util.Collection<java.lang.String> ivarWrites) |
void |
setIRScope(IRScope irScope) |
void |
setModule(RubyModule module) |
void |
setPreviousCRefScope(StaticScope crefScope) |
void |
setScopeType(IRScopeType scopeType) |
void |
setSignature(Signature signature)
This happens in when first defining ArgsNodes or when reifying a method from AOT.
|
void |
setVariables(java.lang.String[] names) |
java.lang.String |
toString() |
public static final int MAX_SPECIALIZED_SIZE
protected StaticScope enclosingScope
protected IRScopeType scopeType
protected StaticScope(StaticScope.Type type, StaticScope enclosingScope, java.lang.String file)
protected StaticScope(StaticScope.Type type, StaticScope enclosingScope)
type - the type of scopeenclosingScope - the lexically containing scope.protected StaticScope(StaticScope.Type type, StaticScope enclosingScope, java.lang.String[] names, int firstKeywordIndex)
type - the type of scopeenclosingScope - the lexically containing scope.names - The list of interned String variable names.protected StaticScope(StaticScope.Type type, StaticScope enclosingScope, java.lang.String file, java.lang.String[] names, int firstKeywordIndex)
protected StaticScope(StaticScope.Type type, StaticScope enclosingScope, java.lang.String[] names)
public int getFirstKeywordIndex()
public DynamicScope construct(DynamicScope parent)
public IRScope getIRScope()
public IRScopeType getScopeType()
public void setScopeType(IRScopeType scopeType)
public void setIRScope(IRScope irScope)
public 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 getConstantDefined(java.lang.String internedName)
public IRubyObject getConstantDefinedNoObject(java.lang.String internedName)
public IRubyObject getConstant(java.lang.String internedName)
public IRubyObject getConstantInner(java.lang.String internedName)
public StaticScope getEnclosingScope()
public void setEnclosingScope(StaticScope parent)
public int exists(java.lang.String name)
name - of the variable to findpublic int isDefined(java.lang.String name)
name - to be looked forpublic AssignableNode assign(int line, RubySymbol name, Node value)
public AssignableNode assignKeyword(int line, RubySymbol symbolID, Node value)
public boolean keywordExists(java.lang.String name)
public java.lang.String[] getAllNamesInScope()
public <T> T collectVariables(java.util.function.IntFunction<T> collectionFactory,
java.util.function.BiConsumer<T,java.lang.String> collectionPopulator)
T - resulting collection typecollectionFactory - used to construct the collectioncollectionPopulator - used to pass values into the collectionpublic RubyArray getLocalVariables(Ruby runtime)
collectVariables(IntFunction, BiConsumer).runtime - current runtimepublic int isDefined(java.lang.String name,
int depth)
public AssignableNode addAssign(int line, RubySymbol symbolID, Node value)
public AssignableNode assign(int line, RubySymbol symbolID, Node value, StaticScope topScope, int depth)
public Node declare(int line, RubySymbol symbolID, int depth)
public Node declare(int line, RubySymbol symbolID)
line - the location that in the source that the new node will come fromsymbolID - 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 boolean isBlockScope()
public boolean isArgumentScope()
public void makeArgumentScope()
public Signature getSignature()
public void setSignature(Signature signature)
public DynamicScope getDummyScope()
public boolean isWithinMethod()
public java.lang.String toString()
toString in class java.lang.Objectpublic StaticScope.Type getType()
public java.lang.String getFile()
public void setFile(java.lang.String file)
public StaticScope duplicate()
public RubyModule getOverlayModuleForRead()
public RubyModule getOverlayModuleForWrite(ThreadContext context)
public void captureParentRefinements(ThreadContext context)
context - public java.util.Collection<java.lang.String> getInstanceVariableNames()
public void setInstanceVariableNames(java.util.Collection<java.lang.String> ivarWrites)
Copyright © 2001-2022 JRuby. All Rights Reserved.