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 0voidMake a larger dynamic scope if the static scope grew.voidsetValueDepthZeroVoid(IRubyObject value, int offset) setValue for depth zerovoidSet value eight in this scope.voidSet value five in this scope.voidSet value four in this scope.voidSet value nine in this scope.voidSet value one in this scope.voidSet value seven in this scope.voidSet value six in this scope.voidSet value three in this scope.voidSet value two in this scope.voidsetValueVoid(IRubyObject value, int offset, int depth) Set value in current dynamic scope or one of its captured scopes.voidSet value zero in this scope;voidsetVariableValues(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:
getValuesin 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:
getValuein 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:DynamicScopeVariation of getValue for depth 0- Overrides:
getValueDepthZeroin classDynamicScope
-
getValueZeroDepthZero
Description copied from class:DynamicScopegetValue for index 0, depth 0- Overrides:
getValueZeroDepthZeroin classDynamicScope
-
getValueOneDepthZero
Description copied from class:DynamicScopegetValue for index 1, depth 0- Overrides:
getValueOneDepthZeroin classDynamicScope
-
getValueTwoDepthZero
Description copied from class:DynamicScopegetValue for index 2, depth 0- Overrides:
getValueTwoDepthZeroin classDynamicScope
-
getValueThreeDepthZero
Description copied from class:DynamicScopegetValue for index 3, depth 0- Overrides:
getValueThreeDepthZeroin classDynamicScope
-
getValueOrNil
Variation of getValue that checks for nulls, returning and setting the given value (presumably nil)- Overrides:
getValueOrNilin classDynamicScope
-
getValueDepthZeroOrNil
Description copied from class:DynamicScopegetValueOrNil for depth 0- Overrides:
getValueDepthZeroOrNilin classDynamicScope
-
getValueZeroDepthZeroOrNil
Description copied from class:DynamicScopegetValueOrNil for index 0, depth 0- Overrides:
getValueZeroDepthZeroOrNilin classDynamicScope
-
getValueOneDepthZeroOrNil
Description copied from class:DynamicScopegetValueOrNil for index 1, depth 0- Overrides:
getValueOneDepthZeroOrNilin classDynamicScope
-
getValueTwoDepthZeroOrNil
Description copied from class:DynamicScopegetValueOrNil for index 2, depth 0- Overrides:
getValueTwoDepthZeroOrNilin classDynamicScope
-
getValueThreeDepthZeroOrNil
Description copied from class:DynamicScopegetValueOrNil for index 3, depth 0- Overrides:
getValueThreeDepthZeroOrNilin classDynamicScope
-
setValueVoid
Set value in current dynamic scope or one of its captured scopes.- Specified by:
setValueVoidin 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:DynamicScopesetValue for depth zero- Overrides:
setValueDepthZeroVoidin classDynamicScope- Parameters:
value- to setoffset- zero-indexed value that represents where variable lives
-
setValueZeroDepthZeroVoid
Description copied from class:DynamicScopeSet value zero in this scope;- Overrides:
setValueZeroDepthZeroVoidin classDynamicScope
-
setValueOneDepthZeroVoid
Description copied from class:DynamicScopeSet value one in this scope.- Overrides:
setValueOneDepthZeroVoidin classDynamicScope
-
setValueTwoDepthZeroVoid
Description copied from class:DynamicScopeSet value two in this scope.- Overrides:
setValueTwoDepthZeroVoidin classDynamicScope
-
setValueThreeDepthZeroVoid
Description copied from class:DynamicScopeSet value three in this scope.- Overrides:
setValueThreeDepthZeroVoidin classDynamicScope
-
setValueFourDepthZeroVoid
Description copied from class:DynamicScopeSet value four in this scope.- Overrides:
setValueFourDepthZeroVoidin classDynamicScope
-
setValueFiveDepthZeroVoid
Description copied from class:DynamicScopeSet value five in this scope.- Overrides:
setValueFiveDepthZeroVoidin classDynamicScope
-
setValueSixDepthZeroVoid
Description copied from class:DynamicScopeSet value six in this scope.- Overrides:
setValueSixDepthZeroVoidin classDynamicScope
-
setValueSevenDepthZeroVoid
Description copied from class:DynamicScopeSet value seven in this scope.- Overrides:
setValueSevenDepthZeroVoidin classDynamicScope
-
setValueEightDepthZeroVoid
Description copied from class:DynamicScopeSet value eight in this scope.- Overrides:
setValueEightDepthZeroVoidin classDynamicScope
-
setValueNineDepthZeroVoid
Description copied from class:DynamicScopeSet value nine in this scope.- Overrides:
setValueNineDepthZeroVoidin 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:
growIfNeededin classDynamicScope
-
cloneScope
Deprecated.- Overrides:
cloneScopein classDynamicScope
-