org.jruby.runtime
Class DynamicScope

java.lang.Object
  extended by org.jruby.runtime.DynamicScope
Direct Known Subclasses:
ManyVarsDynamicScope, NoVarsDynamicScope

public abstract class DynamicScope
extends java.lang.Object


Field Summary
protected  DynamicScope evalScope
           
protected  DynamicScope parent
           
protected  StaticScope staticScope
           
 
Constructor Summary
protected DynamicScope(StaticScope staticScope)
           
protected DynamicScope(StaticScope staticScope, DynamicScope parent)
           
 
Method Summary
abstract  DynamicScope cloneScope()
           
 java.lang.String[] getAllNamesInScope()
          Get all variable names captured (visible) by this scope (sans $~ and $_).
abstract  IRubyObject[] getArgValues()
          Copy variable values back for ZSuper call.
 IRubyObject getBackRef(Ruby runtime)
          Get backref
 DynamicScope getEvalScope()
           
 DynamicScope getFlipScope()
          Find the scope to use for flip-flops.
 IRubyObject getLastLine(Ruby runtime)
          Get lastline
 DynamicScope getNextCapturedScope()
          Get next 'captured' scope.
 DynamicScope getNthParentScope(int n)
          Returns the n-th parent scope of this scope.
 StaticScope getStaticScope()
          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.
abstract  IRubyObject getValueDepthZeroOrNil(int offset, IRubyObject nil)
          getValueOrNil for depth 0
abstract  IRubyObject getValueOneDepthZeroOrNil(IRubyObject nil)
          getValueOrNil for index 1, depth 0
abstract  IRubyObject getValueOrNil(int offset, int depth, IRubyObject nil)
          Variation of getValue that checks for nulls, returning and setting the given value (presumably nil)
abstract  IRubyObject[] getValues()
           
abstract  IRubyObject getValueThreeDepthZeroOrNil(IRubyObject nil)
          getValueOrNil for index 3, depth 0
abstract  IRubyObject getValueTwoDepthZeroOrNil(IRubyObject nil)
          getValueOrNil for index 2, depth 0
abstract  IRubyObject getValueZeroDepthZeroOrNil(IRubyObject nil)
          getValueOrNil for index 0, depth 0
abstract  void growIfNeeded()
           
static DynamicScope newDummyScope(StaticScope staticScope, DynamicScope parent)
           
static DynamicScope newDynamicScope(StaticScope staticScope)
           
static DynamicScope newDynamicScope(StaticScope staticScope, DynamicScope parent)
           
 void setArgValues()
           
 void setArgValues(IRubyObject arg0)
           
abstract  void setArgValues(IRubyObject[] values, int size)
          Set all values which represent 'normal' parameters in a call list to this dynamic scope.
 void setArgValues(IRubyObject arg0, IRubyObject arg1)
           
 void setArgValues(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2)
           
 void setArgValues(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3)
           
 void setArgValues(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4)
           
 void setArgValues(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, IRubyObject arg5)
           
 void setArgValues(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, IRubyObject arg5, IRubyObject arg6)
           
 void setArgValues(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, IRubyObject arg5, IRubyObject arg6, IRubyObject arg7)
           
 void setArgValues(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, IRubyObject arg5, IRubyObject arg6, IRubyObject arg7, IRubyObject arg8)
           
 void setArgValues(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, IRubyObject arg5, IRubyObject arg6, IRubyObject arg7, IRubyObject arg8, IRubyObject arg9)
           
 IRubyObject setBackRef(IRubyObject backref)
          Set backref
abstract  void setEndArgValues(IRubyObject[] values, int index, int size)
           
 IRubyObject setLastLine(IRubyObject lastline)
          Set lastline
abstract  IRubyObject setValue(int offset, IRubyObject value, int depth)
          Set value in current dynamic scope or one of its captured scopes.
 IRubyObject setValue(IRubyObject value, int offset, int depth)
          Set value in current dynamic scope or one of its captured scopes.
abstract  IRubyObject setValueDepthZero(IRubyObject value, int offset)
          setValue for depth zero
abstract  IRubyObject setValueOneDepthZero(IRubyObject value)
          Set value one in this scope.
abstract  IRubyObject setValueThreeDepthZero(IRubyObject value)
          Set value three in this scope.
abstract  IRubyObject setValueTwoDepthZero(IRubyObject value)
          Set value two in this scope.
abstract  IRubyObject setValueZeroDepthZero(IRubyObject value)
          Set value zero in this scope;
 java.lang.String toString()
           
 java.lang.String toString(java.lang.StringBuffer buf, java.lang.String indent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

staticScope

protected final StaticScope staticScope

parent

protected final DynamicScope parent

evalScope

protected DynamicScope evalScope
Constructor Detail

DynamicScope

protected DynamicScope(StaticScope staticScope,
                       DynamicScope parent)

DynamicScope

protected DynamicScope(StaticScope staticScope)
Method Detail

newDynamicScope

public static DynamicScope newDynamicScope(StaticScope staticScope,
                                           DynamicScope parent)

newDummyScope

public static DynamicScope newDummyScope(StaticScope staticScope,
                                         DynamicScope parent)

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)

getEvalScope

public final DynamicScope getEvalScope()

getFlipScope

public DynamicScope getFlipScope()
Find the scope to use for flip-flops. Flip-flops live either in the topmost "method scope" or in their nearest containing "eval scope".

Returns:
The scope to use for flip-flops

getNextCapturedScope

public final DynamicScope getNextCapturedScope()
Get next 'captured' scope.

Returns:
the scope captured by this scope for implementing closures

getStaticScope

public final StaticScope getStaticScope()
Get the static scope associated with this DynamicScope.

Returns:
static complement to this scope

getAllNamesInScope

public final java.lang.String[] getAllNamesInScope()
Get all variable names captured (visible) by this scope (sans $~ and $_).

Returns:
a list of variable names

getBackRef

public IRubyObject getBackRef(Ruby runtime)
Get backref


setBackRef

public IRubyObject setBackRef(IRubyObject backref)
Set backref


getLastLine

public IRubyObject getLastLine(Ruby runtime)
Get lastline


setLastLine

public IRubyObject setLastLine(IRubyObject lastline)
Set lastline


growIfNeeded

public abstract void growIfNeeded()

cloneScope

public abstract DynamicScope cloneScope()

getValues

public abstract IRubyObject[] getValues()

getValue

public abstract IRubyObject getValue(int offset,
                                     int depth)
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.

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

getValueOrNil

public abstract 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 abstract IRubyObject getValueDepthZeroOrNil(int offset,
                                                   IRubyObject nil)
getValueOrNil for depth 0


getValueZeroDepthZeroOrNil

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


getValueOneDepthZeroOrNil

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


getValueTwoDepthZeroOrNil

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


getValueThreeDepthZeroOrNil

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


setValue

public abstract 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:
offset - zero-indexed value that represents where variable lives
value - to set
depth - how many captured scopes down this variable should be set

setValueDepthZero

public abstract IRubyObject setValueDepthZero(IRubyObject value,
                                              int offset)
setValue for depth zero

Parameters:
offset - zero-indexed value that represents where variable lives
value - to set
depth - how many captured scopes down this variable should be set

setValueZeroDepthZero

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


setValueOneDepthZero

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


setValueTwoDepthZero

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


setValueThreeDepthZero

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


setArgValues

public abstract void setArgValues(IRubyObject[] values,
                                  int size)
Set all values which represent 'normal' parameters in a call list to this dynamic scope. Function calls bind to local scopes by assuming that the indexes or the arg list correspond to that of the local scope (plus 2 since $_ and $~ always take the first two slots). We pass in a second argument because we sometimes get more values than we are expecting. The rest get compacted by original caller into rest args.

Parameters:
values - up to size specified to be mapped as ordinary parm values
size - is the number of values to assign as ordinary parm values

setArgValues

public void setArgValues()

setArgValues

public void setArgValues(IRubyObject arg0)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2,
                         IRubyObject arg3)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2,
                         IRubyObject arg3,
                         IRubyObject arg4)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2,
                         IRubyObject arg3,
                         IRubyObject arg4,
                         IRubyObject arg5)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2,
                         IRubyObject arg3,
                         IRubyObject arg4,
                         IRubyObject arg5,
                         IRubyObject arg6)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2,
                         IRubyObject arg3,
                         IRubyObject arg4,
                         IRubyObject arg5,
                         IRubyObject arg6,
                         IRubyObject arg7)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2,
                         IRubyObject arg3,
                         IRubyObject arg4,
                         IRubyObject arg5,
                         IRubyObject arg6,
                         IRubyObject arg7,
                         IRubyObject arg8)

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2,
                         IRubyObject arg3,
                         IRubyObject arg4,
                         IRubyObject arg5,
                         IRubyObject arg6,
                         IRubyObject arg7,
                         IRubyObject arg8,
                         IRubyObject arg9)

setEndArgValues

public abstract void setEndArgValues(IRubyObject[] values,
                                     int index,
                                     int size)
Parameters:
values - group where last n(size) values are used
index - index in the dynamic scope to start setting these values
size - which of the last size arguments of values parameter to set

getArgValues

public abstract IRubyObject[] getArgValues()
Copy variable values back for ZSuper call.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.StringBuffer buf,
                                 java.lang.String indent)


Copyright © 2002-2009 JRuby Team. All Rights Reserved.