org.jruby.runtime.scope
Class FourVarDynamicScope

java.lang.Object
  extended by org.jruby.runtime.DynamicScope
      extended by org.jruby.runtime.scope.NoVarsDynamicScope
          extended by org.jruby.runtime.scope.OneVarDynamicScope
              extended by org.jruby.runtime.scope.TwoVarDynamicScope
                  extended by org.jruby.runtime.scope.ThreeVarDynamicScope
                      extended by org.jruby.runtime.scope.FourVarDynamicScope

public class FourVarDynamicScope
extends ThreeVarDynamicScope

This is a DynamicScope that supports exactly four variables.


Field Summary
protected  IRubyObject variableValueThree
           
 
Fields inherited from class org.jruby.runtime.scope.ThreeVarDynamicScope
variableValueTwo
 
Fields inherited from class org.jruby.runtime.scope.TwoVarDynamicScope
variableValueOne
 
Fields inherited from class org.jruby.runtime.scope.OneVarDynamicScope
variableValueZero
 
Fields inherited from class org.jruby.runtime.DynamicScope
evalScope, parent, staticScope
 
Constructor Summary
FourVarDynamicScope(StaticScope staticScope)
           
FourVarDynamicScope(StaticScope staticScope, DynamicScope parent)
           
 
Method Summary
 DynamicScope cloneScope()
           
 IRubyObject[] getArgValues()
          Copy variable values back for ZSuper call.
 IRubyObject getValue(int offset, int depth)
          Get value from current scope or one of its captured scopes.
 IRubyObject getValueDepthZeroOrNil(int offset, IRubyObject nil)
          getValueOrNil for depth 0
 IRubyObject getValueOrNil(int offset, int depth, IRubyObject nil)
          Variation of getValue that checks for nulls, returning and setting the given value (presumably nil)
 IRubyObject[] getValues()
           
 IRubyObject getValueThreeDepthZeroOrNil(IRubyObject nil)
          getValueOrNil for index 3, depth 0
 void growIfNeeded()
           
 void setArgValues(IRubyObject[] values, int size)
          Set all values which represent 'normal' parameters in a call list to this dynamic scope.
 IRubyObject setValue(int offset, IRubyObject value, int depth)
          Set value in current dynamic scope or one of its captured scopes.
 IRubyObject setValueDepthZero(IRubyObject value, int offset)
          setValue for depth zero
 IRubyObject setValueThreeDepthZero(IRubyObject value)
          Set value three in this scope.
 java.lang.String toString(java.lang.StringBuffer buf, java.lang.String indent)
           
 
Methods inherited from class org.jruby.runtime.scope.ThreeVarDynamicScope
getValueTwoDepthZeroOrNil, setValueTwoDepthZero
 
Methods inherited from class org.jruby.runtime.scope.TwoVarDynamicScope
getValueOneDepthZeroOrNil, setValueOneDepthZero
 
Methods inherited from class org.jruby.runtime.scope.OneVarDynamicScope
getValueZeroDepthZeroOrNil, setValueZeroDepthZero
 
Methods inherited from class org.jruby.runtime.DynamicScope
getAllNamesInScope, getEvalScope, getFlipScope, getNextCapturedScope, getNthParentScope, getStaticScope, newDummyScope, newDynamicScope, newDynamicScope, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

variableValueThree

protected IRubyObject variableValueThree
Constructor Detail

FourVarDynamicScope

public FourVarDynamicScope(StaticScope staticScope,
                           DynamicScope parent)

FourVarDynamicScope

public FourVarDynamicScope(StaticScope staticScope)
Method Detail

growIfNeeded

public void growIfNeeded()
Overrides:
growIfNeeded in class ThreeVarDynamicScope

cloneScope

public DynamicScope cloneScope()
Overrides:
cloneScope in class ThreeVarDynamicScope

getValues

public IRubyObject[] getValues()
Overrides:
getValues in class ThreeVarDynamicScope

getValue

public 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.

Overrides:
getValue in class ThreeVarDynamicScope
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 IRubyObject getValueOrNil(int offset,
                                 int depth,
                                 IRubyObject nil)
Variation of getValue that checks for nulls, returning and setting the given value (presumably nil)

Overrides:
getValueOrNil in class ThreeVarDynamicScope

getValueDepthZeroOrNil

public IRubyObject getValueDepthZeroOrNil(int offset,
                                          IRubyObject nil)
Description copied from class: DynamicScope
getValueOrNil for depth 0

Overrides:
getValueDepthZeroOrNil in class ThreeVarDynamicScope

getValueThreeDepthZeroOrNil

public IRubyObject getValueThreeDepthZeroOrNil(IRubyObject nil)
Description copied from class: DynamicScope
getValueOrNil for index 3, depth 0

Overrides:
getValueThreeDepthZeroOrNil in class NoVarsDynamicScope

setValue

public IRubyObject setValue(int offset,
                            IRubyObject value,
                            int depth)
Set value in current dynamic scope or one of its captured scopes.

Overrides:
setValue in class ThreeVarDynamicScope
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 IRubyObject setValueDepthZero(IRubyObject value,
                                     int offset)
Description copied from class: DynamicScope
setValue for depth zero

Overrides:
setValueDepthZero in class ThreeVarDynamicScope
Parameters:
value - to set
offset - zero-indexed value that represents where variable lives

setValueThreeDepthZero

public IRubyObject setValueThreeDepthZero(IRubyObject value)
Description copied from class: DynamicScope
Set value three in this scope.

Overrides:
setValueThreeDepthZero in class NoVarsDynamicScope

setArgValues

public 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.

Overrides:
setArgValues in class ThreeVarDynamicScope
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

getArgValues

public IRubyObject[] getArgValues()
Description copied from class: DynamicScope
Copy variable values back for ZSuper call.

Overrides:
getArgValues in class ThreeVarDynamicScope

toString

public java.lang.String toString(java.lang.StringBuffer buf,
                                 java.lang.String indent)
Overrides:
toString in class ThreeVarDynamicScope


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