Class DynamicScope

java.lang.Object
org.jruby.runtime.DynamicScope
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ManyVarsDynamicScope

public abstract class DynamicScope extends Object implements Cloneable
  • Field Details

  • Constructor Details

  • Method Details

    • newDynamicScope

      public static DynamicScope newDynamicScope(StaticScope staticScope, DynamicScope parent)
    • newDynamicScope

      public static DynamicScope newDynamicScope(StaticScope staticScope, DynamicScope parent, EvalType evalType)
    • newDummyScope

      public static DynamicScope newDummyScope(StaticScope staticScope, DynamicScope parent)
    • getParentScope

      public final DynamicScope getParentScope()
      Get parent (capturing) scope. This is used by eval and closures to walk up to hard lexical boundary.
    • getNextCapturedScope

      @Deprecated public DynamicScope getNextCapturedScope()
      Deprecated.
    • getNthParentScope

      public DynamicScope getNthParentScope(int n)
      Returns the n-th parent scope of this scope. May return null.
      Parameters:
      n - - number of levels above to look.
      Returns:
      The n-th parent scope or null.
    • newDynamicScope

      public static DynamicScope newDynamicScope(StaticScope staticScope)
    • getStaticScope

      public final StaticScope getStaticScope()
      Get the static scope associated with this DynamicScope.
      Returns:
      static complement to this scope
    • getAllNamesInScope

      public final String[] getAllNamesInScope()
      Get all variable names captured (visible) by this scope (sans $~ and $_).
      Returns:
      a list of variable names
    • growIfNeeded

      public void growIfNeeded()
    • getValues

      public IRubyObject[] getValues()
    • getValue

      public abstract IRubyObject getValue(int offset, int depth)
      Get value from current scope or one of its captured scopes.
      Parameters:
      offset - zero-indexed value that represents where variable lives
      depth - how many captured scopes down this variable should be set
      Returns:
      the value here
    • getValueDepthZero

      public IRubyObject getValueDepthZero(int offset)
      Variation of getValue for depth 0
    • getValueZeroDepthZero

      public IRubyObject getValueZeroDepthZero()
      getValue for index 0, depth 0
    • getValueOneDepthZero

      public IRubyObject getValueOneDepthZero()
      getValue for index 1, depth 0
    • getValueTwoDepthZero

      public IRubyObject getValueTwoDepthZero()
      getValue for index 2, depth 0
    • getValueThreeDepthZero

      public IRubyObject getValueThreeDepthZero()
      getValue for index 3, depth 0
    • getValueFourDepthZero

      public IRubyObject getValueFourDepthZero()
      getValue for index 4, depth 0
    • getValueFiveDepthZero

      public IRubyObject getValueFiveDepthZero()
      getValue for index 5, depth 0
    • getValueSixDepthZero

      public IRubyObject getValueSixDepthZero()
      getValue for index 6, depth 0
    • getValueSevenDepthZero

      public IRubyObject getValueSevenDepthZero()
      getValue for index 7, depth 0
    • getValueEightDepthZero

      public IRubyObject getValueEightDepthZero()
      getValue for index 8, depth 0
    • getValueNineDepthZero

      public IRubyObject getValueNineDepthZero()
      getValue for index 9, depth 0
    • getValueOrNil

      public IRubyObject getValueOrNil(int offset, int depth, IRubyObject nil)
      Variation of getValue that checks for nulls, returning and setting the given value (presumably nil)
    • getValueDepthZeroOrNil

      public IRubyObject getValueDepthZeroOrNil(int offset, IRubyObject nil)
      getValueOrNil for depth 0
    • getValueZeroDepthZeroOrNil

      public IRubyObject getValueZeroDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 0, depth 0
    • getValueOneDepthZeroOrNil

      public IRubyObject getValueOneDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 1, depth 0
    • getValueTwoDepthZeroOrNil

      public IRubyObject getValueTwoDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 2, depth 0
    • getValueThreeDepthZeroOrNil

      public IRubyObject getValueThreeDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 3, depth 0
    • getValueFourDepthZeroOrNil

      public IRubyObject getValueFourDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 4, depth 0
    • getValueFiveDepthZeroOrNil

      public IRubyObject getValueFiveDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 5, depth 0
    • getValueSixDepthZeroOrNil

      public IRubyObject getValueSixDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 6, depth 0
    • getValueSevenDepthZeroOrNil

      public IRubyObject getValueSevenDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 7, depth 0
    • getValueEightDepthZeroOrNil

      public IRubyObject getValueEightDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 8, depth 0
    • getValueNineDepthZeroOrNil

      public IRubyObject getValueNineDepthZeroOrNil(IRubyObject nil)
      getValueOrNil for index 9, depth 0
    • setValue

      public IRubyObject setValue(int offset, IRubyObject value, int depth)
      Set value in current dynamic scope or one of its captured scopes.
      Parameters:
      offset - zero-indexed value that represents where variable lives
      value - to set
      depth - how many captured scopes down this variable should be set
    • setValue

      public IRubyObject setValue(IRubyObject value, int offset, int depth)
      Set value in current dynamic scope or one of its captured scopes.
      Parameters:
      value - to set
      offset - zero-indexed value that represents where variable lives
      depth - how many captured scopes down this variable should be set
    • setValueVoid

      public abstract void setValueVoid(IRubyObject value, int offset, int depth)
      Set value in current dynamic scope or one of its captured scopes.
      Parameters:
      value - to set
      offset - zero-indexed value that represents where variable lives
      depth - how many captured scopes down this variable should be set
    • setValueDepthZero

      public IRubyObject setValueDepthZero(IRubyObject value, int offset)
      setValue for depth zero
      Parameters:
      value - to set
      offset - zero-indexed value that represents where variable lives
    • setValueDepthZeroVoid

      public void setValueDepthZeroVoid(IRubyObject value, int offset)
      setValue for depth zero
      Parameters:
      value - to set
      offset - zero-indexed value that represents where variable lives
    • setValueZeroDepthZero

      public IRubyObject setValueZeroDepthZero(IRubyObject value)
      Set value zero in this scope;
    • setValueZeroDepthZeroVoid

      public void setValueZeroDepthZeroVoid(IRubyObject value)
      Set value zero in this scope;
    • setValueOneDepthZero

      public IRubyObject setValueOneDepthZero(IRubyObject value)
      Set value one in this scope.
    • setValueOneDepthZeroVoid

      public void setValueOneDepthZeroVoid(IRubyObject value)
      Set value one in this scope.
    • setValueTwoDepthZero

      public IRubyObject setValueTwoDepthZero(IRubyObject value)
      Set value two in this scope.
    • setValueTwoDepthZeroVoid

      public void setValueTwoDepthZeroVoid(IRubyObject value)
      Set value two in this scope.
    • setValueThreeDepthZero

      public IRubyObject setValueThreeDepthZero(IRubyObject value)
      Set value three in this scope.
    • setValueThreeDepthZeroVoid

      public void setValueThreeDepthZeroVoid(IRubyObject value)
      Set value three in this scope.
    • setValueFourDepthZeroVoid

      public void setValueFourDepthZeroVoid(IRubyObject value)
      Set value four in this scope.
    • setValueFiveDepthZeroVoid

      public void setValueFiveDepthZeroVoid(IRubyObject value)
      Set value five in this scope.
    • setValueSixDepthZeroVoid

      public void setValueSixDepthZeroVoid(IRubyObject value)
      Set value six in this scope.
    • setValueSevenDepthZeroVoid

      public void setValueSevenDepthZeroVoid(IRubyObject value)
      Set value seven in this scope.
    • setValueEightDepthZeroVoid

      public void setValueEightDepthZeroVoid(IRubyObject value)
      Set value eight in this scope.
    • setValueNineDepthZeroVoid

      public void setValueNineDepthZeroVoid(IRubyObject value)
      Set value nine in this scope.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(StringBuffer buf, String indent)
    • inInstanceEval

      public boolean inInstanceEval()
    • inModuleEval

      public boolean inModuleEval()
    • inBindingEval

      public boolean inBindingEval()
    • setEvalType

      public void setEvalType(EvalType evalType)
    • getEvalType

      public EvalType 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 public DynamicScope cloneScope()
      Deprecated.
    • dupEvalScope

      public DynamicScope dupEvalScope()
      Binding needs to clone its scope with all the current values.
      Returns:
      a duplicate of this scope with all the current values