Package org.jruby.runtime.scope
Class ManyVarsDynamicScope
java.lang.Object
org.jruby.runtime.DynamicScope
org.jruby.runtime.scope.ManyVarsDynamicScope
- All Implemented Interfaces:
Cloneable
Represents the the dynamic portion of scoping information. The variableValues are the
values of assigned local or block variables. The staticScope identifies which sort of
scope this is (block or local).
Properties of Dynamic Scopes:
1. static and dynamic scopes have the same number of names to values
2. size of variables (and thus names) is determined during parsing. So those structured do
not need to change
FIXME: When creating dynamic scopes we sometimes accidentally pass in extra parents. This
is harmless (other than wasting memory), but we should not do that. We can fix this in two
ways:
1. Fix all callers
2. Check parent that is passed in and make if new instance is local, then its parent is not local
-
Field Summary
FieldsFields inherited from class org.jruby.runtime.DynamicScope
parent, staticScope
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.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 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 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
Make a larger dynamic scope if the static scope grew.void
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.void
Set value one in this scope.void
Set value seven in this scope.void
Set value six in this scope.void
Set value three in this scope.void
Set value two in this scope.void
setValueVoid
(IRubyObject value, int offset, int depth) Set value in current dynamic scope or one of its captured scopes.void
Set value zero in this scope;void
setVariableValues
(IRubyObject[] variableValues) Methods inherited from class org.jruby.runtime.DynamicScope
clearEvalType, dupEvalScope, getAllNamesInScope, getEvalType, getNextCapturedScope, getNthParentScope, getParentScope, getStaticScope, getValueEightDepthZero, getValueEightDepthZeroOrNil, getValueFiveDepthZero, getValueFiveDepthZeroOrNil, getValueFourDepthZero, getValueFourDepthZeroOrNil, getValueNineDepthZero, getValueNineDepthZeroOrNil, getValueSevenDepthZero, getValueSevenDepthZeroOrNil, getValueSixDepthZero, getValueSixDepthZeroOrNil, inBindingEval, inInstanceEval, inModuleEval, isLambda, isReturnTarget, newDummyScope, newDynamicScope, newDynamicScope, newDynamicScope, setEvalType, setLambda, setValue, setValue, setValueDepthZero, setValueOneDepthZero, setValueThreeDepthZero, setValueTwoDepthZero, setValueZeroDepthZero, toString, toString
-
Field Details
-
CONSTRUCTOR
-
-
Constructor Details
-
ManyVarsDynamicScope
-
-
Method Details
-
setVariableValues
-
getValues
- Overrides:
getValues
in classDynamicScope
-
getValue
Get value from current scope or one of its captured scopes. FIXME: block variables are not getting primed to nil so we need to null check those until we prime them properly. Also add assert back in.- Specified by:
getValue
in classDynamicScope
- 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
Description copied from class:DynamicScope
Variation of getValue for depth 0- Overrides:
getValueDepthZero
in classDynamicScope
-
getValueZeroDepthZero
Description copied from class:DynamicScope
getValue for index 0, depth 0- Overrides:
getValueZeroDepthZero
in classDynamicScope
-
getValueOneDepthZero
Description copied from class:DynamicScope
getValue for index 1, depth 0- Overrides:
getValueOneDepthZero
in classDynamicScope
-
getValueTwoDepthZero
Description copied from class:DynamicScope
getValue for index 2, depth 0- Overrides:
getValueTwoDepthZero
in classDynamicScope
-
getValueThreeDepthZero
Description copied from class:DynamicScope
getValue for index 3, depth 0- Overrides:
getValueThreeDepthZero
in classDynamicScope
-
getValueOrNil
Variation of getValue that checks for nulls, returning and setting the given value (presumably nil)- Overrides:
getValueOrNil
in classDynamicScope
-
getValueDepthZeroOrNil
Description copied from class:DynamicScope
getValueOrNil for depth 0- Overrides:
getValueDepthZeroOrNil
in classDynamicScope
-
getValueZeroDepthZeroOrNil
Description copied from class:DynamicScope
getValueOrNil for index 0, depth 0- Overrides:
getValueZeroDepthZeroOrNil
in classDynamicScope
-
getValueOneDepthZeroOrNil
Description copied from class:DynamicScope
getValueOrNil for index 1, depth 0- Overrides:
getValueOneDepthZeroOrNil
in classDynamicScope
-
getValueTwoDepthZeroOrNil
Description copied from class:DynamicScope
getValueOrNil for index 2, depth 0- Overrides:
getValueTwoDepthZeroOrNil
in classDynamicScope
-
getValueThreeDepthZeroOrNil
Description copied from class:DynamicScope
getValueOrNil for index 3, depth 0- Overrides:
getValueThreeDepthZeroOrNil
in classDynamicScope
-
setValueVoid
Set value in current dynamic scope or one of its captured scopes.- Specified by:
setValueVoid
in classDynamicScope
- Parameters:
value
- to setoffset
- zero-indexed value that represents where variable livesdepth
- how many captured scopes down this variable should be set
-
setValueDepthZeroVoid
Description copied from class:DynamicScope
setValue for depth zero- Overrides:
setValueDepthZeroVoid
in classDynamicScope
- Parameters:
value
- to setoffset
- zero-indexed value that represents where variable lives
-
setValueZeroDepthZeroVoid
Description copied from class:DynamicScope
Set value zero in this scope;- Overrides:
setValueZeroDepthZeroVoid
in classDynamicScope
-
setValueOneDepthZeroVoid
Description copied from class:DynamicScope
Set value one in this scope.- Overrides:
setValueOneDepthZeroVoid
in classDynamicScope
-
setValueTwoDepthZeroVoid
Description copied from class:DynamicScope
Set value two in this scope.- Overrides:
setValueTwoDepthZeroVoid
in classDynamicScope
-
setValueThreeDepthZeroVoid
Description copied from class:DynamicScope
Set value three in this scope.- Overrides:
setValueThreeDepthZeroVoid
in classDynamicScope
-
setValueFourDepthZeroVoid
Description copied from class:DynamicScope
Set value four in this scope.- Overrides:
setValueFourDepthZeroVoid
in classDynamicScope
-
setValueFiveDepthZeroVoid
Description copied from class:DynamicScope
Set value five in this scope.- Overrides:
setValueFiveDepthZeroVoid
in classDynamicScope
-
setValueSixDepthZeroVoid
Description copied from class:DynamicScope
Set value six in this scope.- Overrides:
setValueSixDepthZeroVoid
in classDynamicScope
-
setValueSevenDepthZeroVoid
Description copied from class:DynamicScope
Set value seven in this scope.- Overrides:
setValueSevenDepthZeroVoid
in classDynamicScope
-
setValueEightDepthZeroVoid
Description copied from class:DynamicScope
Set value eight in this scope.- Overrides:
setValueEightDepthZeroVoid
in classDynamicScope
-
setValueNineDepthZeroVoid
Description copied from class:DynamicScope
Set value nine in this scope.- Overrides:
setValueNineDepthZeroVoid
in classDynamicScope
-
growIfNeeded
public void growIfNeeded()Make a larger dynamic scope if the static scope grew. Eval's with bindings require us to possibly change the size of the dynamic scope if things like 'eval "b = 2", binding' happens.- Overrides:
growIfNeeded
in classDynamicScope
-
cloneScope
Deprecated.- Overrides:
cloneScope
in classDynamicScope
-