org.jruby.runtime.scope
Class TwoVarDynamicScope

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

public class TwoVarDynamicScope
extends OneVarDynamicScope

This is a DynamicScope that supports exactly three variables.


Field Summary
protected  IRubyObject variableValueOne
           
 
Fields inherited from class org.jruby.runtime.scope.OneVarDynamicScope
variableValueZero
 
Fields inherited from class org.jruby.runtime.DynamicScope
evalScope, parent, staticScope
 
Constructor Summary
TwoVarDynamicScope(StaticScope staticScope)
           
TwoVarDynamicScope(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 getValueOneDepthZeroOrNil(IRubyObject nil)
          getValueOrNil for index 1, depth 0
 IRubyObject[] getValues()
           
 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 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 setValueOneDepthZero(IRubyObject value)
          Set value one in this scope.
 
Methods inherited from class org.jruby.runtime.scope.OneVarDynamicScope
getValueOrNil, getValueZeroDepthZeroOrNil, setValueZeroDepthZero
 
Methods inherited from class org.jruby.runtime.scope.NoVarsDynamicScope
getValueThreeDepthZeroOrNil, getValueTwoDepthZeroOrNil, growIfNeeded, setArgValues, setValueThreeDepthZero, setValueTwoDepthZero
 
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

variableValueOne

protected IRubyObject variableValueOne
Constructor Detail

TwoVarDynamicScope

public TwoVarDynamicScope(StaticScope staticScope,
                          DynamicScope parent)

TwoVarDynamicScope

public TwoVarDynamicScope(StaticScope staticScope)
Method Detail

growIfNeeded

public void growIfNeeded()
Overrides:
growIfNeeded in class OneVarDynamicScope

cloneScope

public DynamicScope cloneScope()
Overrides:
cloneScope in class OneVarDynamicScope

getValues

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

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

getValueDepthZeroOrNil

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

Overrides:
getValueDepthZeroOrNil in class OneVarDynamicScope

getValueOneDepthZeroOrNil

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

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

setValueOneDepthZero

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

Overrides:
setValueOneDepthZero 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 OneVarDynamicScope
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 OneVarDynamicScope
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 OneVarDynamicScope

setArgValues

public void setArgValues(IRubyObject arg0,
                         IRubyObject arg1)
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 OneVarDynamicScope


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