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.
|
Modifier and Type | Method and Description |
---|---|
AssignableNode |
addAssign(ISourcePosition position,
RubySymbol symbolID,
Node value) |
int |
addNamedCaptureVariable(java.lang.String name)
Add a new named capture variable to this (current) scope.
|
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,
RubySymbol name,
Node value)
Make a DASgn or LocalAsgn node based on scope logic
|
AssignableNode |
assign(ISourcePosition position,
RubySymbol symbolID,
Node value,
StaticScope topScope,
int depth) |
AssignableNode |
assignKeyword(ISourcePosition position,
RubySymbol symbolID,
Node value)
Register a keyword argument with this staticScope.
|
<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(ISourcePosition position,
RubySymbol symbolID)
Make a DVar or LocalVar node based on scoping logic
|
Node |
declare(ISourcePosition position,
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.
|
long |
getCommandArgumentStack() |
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() |
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 |
isNamedCapture(int index) |
boolean |
keywordExists(java.lang.String name) |
void |
makeArgumentScope() |
void |
setCommandArgumentStack(long commandArgumentStack) |
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 final 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[] 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 addNamedCaptureVariable(java.lang.String name)
name
- name of variable.public 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 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(ISourcePosition position, RubySymbol name, Node value)
position
- name
- value
- public AssignableNode assignKeyword(ISourcePosition position, RubySymbol symbolID, Node value)
position
- symbolID
- 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(ISourcePosition position, RubySymbol symbolID, Node value)
public AssignableNode assign(ISourcePosition position, RubySymbol symbolID, Node value, StaticScope topScope, int depth)
public Node declare(ISourcePosition position, RubySymbol symbolID, int depth)
public Node declare(ISourcePosition position, RubySymbol symbolID)
position
- 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 void setCommandArgumentStack(long commandArgumentStack)
public long getCommandArgumentStack()
public boolean isNamedCapture(int index)
public java.lang.String toString()
toString
in class java.lang.Object
public StaticScope.Type getType()
public java.lang.String getFile()
public StaticScope duplicate()
public RubyModule getOverlayModuleForRead()
public RubyModule getOverlayModuleForWrite(ThreadContext context)
Copyright © 2001-2020 JRuby. All Rights Reserved.