Package org.jruby.runtime
Class DynamicScope
java.lang.Object
org.jruby.runtime.DynamicScope
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ManyVarsDynamicScope
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DynamicScope
(StaticScope staticScope, DynamicScope parent) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.Binding needs to clone its scope with all the current values.final String[]
Get all variable names captured (visible) by this scope (sans $~ and $_).Deprecated.getNthParentScope
(int n) Returns the n-th parent scope of this scope.final DynamicScope
Get parent (capturing) scope.final StaticScope
Get the static scope associated with this DynamicScope.abstract IRubyObject
getValue
(int offset, int depth) Get value from current scope or one of its captured scopes.getValueDepthZero
(int offset) Variation of getValue for depth 0getValueDepthZeroOrNil
(int offset, IRubyObject nil) getValueOrNil for depth 0getValue for index 8, depth 0getValueOrNil for index 8, depth 0getValue for index 5, depth 0getValueOrNil for index 5, depth 0getValue for index 4, depth 0getValueOrNil for index 4, depth 0getValue for index 9, depth 0getValueOrNil for index 9, depth 0getValue for index 1, depth 0getValueOrNil for index 1, depth 0getValueOrNil
(int offset, int depth, IRubyObject nil) Variation of getValue that checks for nulls, returning and setting the given value (presumably nil)getValue for index 7, depth 0getValueOrNil for index 7, depth 0getValue for index 6, depth 0getValueOrNil for index 6, depth 0getValue for index 3, depth 0getValueOrNil for index 3, depth 0getValue for index 2, depth 0getValueOrNil for index 2, depth 0getValue for index 0, depth 0getValueOrNil for index 0, depth 0void
boolean
boolean
boolean
boolean
isLambda()
boolean
A DynamicScope is the target of a non-local return if it is one of the following: * A method scope * A top-level script scope * A block scope that is either marked as the argument scope (define_method) or a lambdastatic DynamicScope
newDummyScope
(StaticScope staticScope, DynamicScope parent) static DynamicScope
newDynamicScope
(StaticScope staticScope) static DynamicScope
newDynamicScope
(StaticScope staticScope, DynamicScope parent) static DynamicScope
newDynamicScope
(StaticScope staticScope, DynamicScope parent, EvalType evalType) void
setEvalType
(EvalType evalType) void
setLambda
(boolean lambda) setValue
(int offset, IRubyObject value, int depth) Set value in current dynamic scope or one of its captured scopes.setValue
(IRubyObject value, int offset, int depth) Set value in current dynamic scope or one of its captured scopes.setValueDepthZero
(IRubyObject value, int offset) setValue for depth zerovoid
setValueDepthZeroVoid
(IRubyObject value, int offset) setValue for depth zerovoid
Set value eight in this scope.void
Set value five in this scope.void
Set value four in this scope.void
Set value nine in this scope.setValueOneDepthZero
(IRubyObject value) Set value one in this scope.void
Set value one in this scope.void
Set value seven in this scope.void
Set value six in this scope.Set value three in this scope.void
Set value three in this scope.setValueTwoDepthZero
(IRubyObject value) Set value two in this scope.void
Set value two in this scope.abstract void
setValueVoid
(IRubyObject value, int offset, int depth) Set value in current dynamic scope or one of its captured scopes.setValueZeroDepthZero
(IRubyObject value) Set value zero in this scope;void
Set value zero in this scope;toString()
toString
(StringBuffer buf, String indent)
-
Field Details
-
staticScope
-
parent
-
-
Constructor Details
-
DynamicScope
-
-
Method Details
-
newDynamicScope
-
newDynamicScope
public static DynamicScope newDynamicScope(StaticScope staticScope, DynamicScope parent, EvalType evalType) -
newDummyScope
-
getParentScope
Get parent (capturing) scope. This is used by eval and closures to walk up to hard lexical boundary. -
getNextCapturedScope
Deprecated. -
getNthParentScope
Returns the n-th parent scope of this scope. May returnnull
.- Parameters:
n
- - number of levels above to look.- Returns:
- The n-th parent scope or
null
.
-
newDynamicScope
-
getStaticScope
Get the static scope associated with this DynamicScope.- Returns:
- static complement to this scope
-
getAllNamesInScope
Get all variable names captured (visible) by this scope (sans $~ and $_).- Returns:
- a list of variable names
-
growIfNeeded
public void growIfNeeded() -
getValues
-
getValue
Get value from current scope or one of its captured scopes.- Parameters:
offset
- zero-indexed value that represents where variable livesdepth
- how many captured scopes down this variable should be set- Returns:
- the value here
-
getValueDepthZero
Variation of getValue for depth 0 -
getValueZeroDepthZero
getValue for index 0, depth 0 -
getValueOneDepthZero
getValue for index 1, depth 0 -
getValueTwoDepthZero
getValue for index 2, depth 0 -
getValueThreeDepthZero
getValue for index 3, depth 0 -
getValueFourDepthZero
getValue for index 4, depth 0 -
getValueFiveDepthZero
getValue for index 5, depth 0 -
getValueSixDepthZero
getValue for index 6, depth 0 -
getValueSevenDepthZero
getValue for index 7, depth 0 -
getValueEightDepthZero
getValue for index 8, depth 0 -
getValueNineDepthZero
getValue for index 9, depth 0 -
getValueOrNil
Variation of getValue that checks for nulls, returning and setting the given value (presumably nil) -
getValueDepthZeroOrNil
getValueOrNil for depth 0 -
getValueZeroDepthZeroOrNil
getValueOrNil for index 0, depth 0 -
getValueOneDepthZeroOrNil
getValueOrNil for index 1, depth 0 -
getValueTwoDepthZeroOrNil
getValueOrNil for index 2, depth 0 -
getValueThreeDepthZeroOrNil
getValueOrNil for index 3, depth 0 -
getValueFourDepthZeroOrNil
getValueOrNil for index 4, depth 0 -
getValueFiveDepthZeroOrNil
getValueOrNil for index 5, depth 0 -
getValueSixDepthZeroOrNil
getValueOrNil for index 6, depth 0 -
getValueSevenDepthZeroOrNil
getValueOrNil for index 7, depth 0 -
getValueEightDepthZeroOrNil
getValueOrNil for index 8, depth 0 -
getValueNineDepthZeroOrNil
getValueOrNil for index 9, depth 0 -
setValue
Set value in current dynamic scope or one of its captured scopes.- Parameters:
offset
- zero-indexed value that represents where variable livesvalue
- to setdepth
- how many captured scopes down this variable should be set
-
setValue
Set value in current dynamic scope or one of its captured scopes.- Parameters:
value
- to setoffset
- zero-indexed value that represents where variable livesdepth
- how many captured scopes down this variable should be set
-
setValueVoid
Set value in current dynamic scope or one of its captured scopes.- Parameters:
value
- to setoffset
- zero-indexed value that represents where variable livesdepth
- how many captured scopes down this variable should be set
-
setValueDepthZero
setValue for depth zero- Parameters:
value
- to setoffset
- zero-indexed value that represents where variable lives
-
setValueDepthZeroVoid
setValue for depth zero- Parameters:
value
- to setoffset
- zero-indexed value that represents where variable lives
-
setValueZeroDepthZero
Set value zero in this scope; -
setValueZeroDepthZeroVoid
Set value zero in this scope; -
setValueOneDepthZero
Set value one in this scope. -
setValueOneDepthZeroVoid
Set value one in this scope. -
setValueTwoDepthZero
Set value two in this scope. -
setValueTwoDepthZeroVoid
Set value two in this scope. -
setValueThreeDepthZero
Set value three in this scope. -
setValueThreeDepthZeroVoid
Set value three in this scope. -
setValueFourDepthZeroVoid
Set value four in this scope. -
setValueFiveDepthZeroVoid
Set value five in this scope. -
setValueSixDepthZeroVoid
Set value six in this scope. -
setValueSevenDepthZeroVoid
Set value seven in this scope. -
setValueEightDepthZeroVoid
Set value eight in this scope. -
setValueNineDepthZeroVoid
Set value nine in this scope. -
toString
-
toString
-
inInstanceEval
public boolean inInstanceEval() -
inModuleEval
public boolean inModuleEval() -
inBindingEval
public boolean inBindingEval() -
setEvalType
-
getEvalType
-
clearEvalType
public void clearEvalType() -
setLambda
public void setLambda(boolean lambda) -
isLambda
public boolean isLambda() -
isReturnTarget
public boolean isReturnTarget()A DynamicScope is the target of a non-local return if it is one of the following: * A method scope * A top-level script scope * A block scope that is either marked as the argument scope (define_method) or a lambda- Returns:
- true if this scope is the nearest return scope, false otherwise
-
cloneScope
Deprecated. -
dupEvalScope
Binding needs to clone its scope with all the current values.- Returns:
- a duplicate of this scope with all the current values
-