org.jruby.runtime.scope
Class ThreeVarDynamicScope

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
Direct Known Subclasses:
FourVarDynamicScope

public class ThreeVarDynamicScope
extends TwoVarDynamicScope

This is a DynamicScope that supports exactly three variables.


Field Summary
protected  IRubyObject 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
ThreeVarDynamicScope(StaticScope staticScope)
           
ThreeVarDynamicScope(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 getValueTwoDepthZeroOrNil(IRubyObject nil)
          getValueOrNil for index 2, depth 0
 void growIfNeeded()
           
 void setArgValues(IRubyObject arg0)
           
 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 setEndArgValues(IRubyObject[] values, int index, int size)
           
 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 setValueTwoDepthZero(IRubyObject value)
          Set value two in this scope.
 
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.scope.NoVarsDynamicScope
getValueThreeDepthZeroOrNil, growIfNeeded, setValueThreeDepthZero
 
Methods inherited from class org.jruby.runtime.DynamicScope
getAllNamesInScope, getBackRef, getEvalScope, getFlipScope, getLastLine, getNextCapturedScope, getNthParentScope, getStaticScope, newDummyScope, newDynamicScope, newDynamicScope, setArgValues, setArgValues, setArgValues, setArgValues, setArgValues, setArgValues, setArgValues, setArgValues, setBackRef, setLastLine, setValue, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

variableValueTwo

protected IRubyObject variableValueTwo
Constructor Detail

ThreeVarDynamicScope

public ThreeVarDynamicScope(StaticScope staticScope,
                            DynamicScope parent)

ThreeVarDynamicScope

public ThreeVarDynamicScope(StaticScope staticScope)
Method Detail

growIfNeeded

public void growIfNeeded()
Overrides:
growIfNeeded in class TwoVarDynamicScope

cloneScope

public DynamicScope cloneScope()
Overrides:
cloneScope in class TwoVarDynamicScope

getValues

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

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 TwoVarDynamicScope
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 OneVarDynamicScope

getValueDepthZeroOrNil

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

Overrides:
getValueDepthZeroOrNil in class TwoVarDynamicScope

getValueTwoDepthZeroOrNil

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

Overrides:
getValueTwoDepthZeroOrNil 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 TwoVarDynamicScope
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 TwoVarDynamicScope
Parameters:
value - to set
offset - zero-indexed value that represents where variable lives

setValueTwoDepthZero

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

Overrides:
setValueTwoDepthZero 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 TwoVarDynamicScope
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

setEndArgValues

public void setEndArgValues(IRubyObject[] values,
                            int index,
                            int size)
Overrides:
setEndArgValues in class TwoVarDynamicScope
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

setArgValues

public void setArgValues(IRubyObject arg0)
Overrides:
setArgValues in class TwoVarDynamicScope

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1)
Overrides:
setArgValues in class TwoVarDynamicScope

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1,
                         IRubyObject arg2)
Overrides:
setArgValues in class NoVarsDynamicScope

getArgValues

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

Overrides:
getArgValues in class TwoVarDynamicScope


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