org.jruby.runtime.scope
Class OneVarDynamicScope

java.lang.Object
  extended by org.jruby.runtime.DynamicScope
      extended by org.jruby.runtime.scope.NoVarsDynamicScope
          extended by org.jruby.runtime.scope.OneVarDynamicScope
Direct Known Subclasses:
TwoVarDynamicScope

public class OneVarDynamicScope
extends NoVarsDynamicScope

This is a DynamicScope that supports exactly three variables.


Field Summary
protected  IRubyObject variableValueZero
           
 
Fields inherited from class org.jruby.runtime.DynamicScope
evalScope, parent, staticScope
 
Constructor Summary
OneVarDynamicScope(StaticScope staticScope)
           
OneVarDynamicScope(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 getValueZeroDepthZeroOrNil(IRubyObject nil)
          getValueOrNil for index 0, 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 setValueZeroDepthZero(IRubyObject value)
          Set value zero in this scope;
 java.lang.String toString(java.lang.StringBuffer buf, java.lang.String indent)
           
 
Methods inherited from class org.jruby.runtime.scope.NoVarsDynamicScope
getValueOneDepthZeroOrNil, getValueThreeDepthZeroOrNil, getValueTwoDepthZeroOrNil, setValueOneDepthZero, setValueThreeDepthZero, setValueTwoDepthZero
 
Methods inherited from class org.jruby.runtime.DynamicScope
getAllNamesInScope, getEvalScope, getFlipScope, getNextCapturedScope, getNthParentScope, getStaticScope, newDummyScope, newDynamicScope, newDynamicScope, setValue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

variableValueZero

protected IRubyObject variableValueZero
Constructor Detail

OneVarDynamicScope

public OneVarDynamicScope(StaticScope staticScope,
                          DynamicScope parent)

OneVarDynamicScope

public OneVarDynamicScope(StaticScope staticScope)
Method Detail

growIfNeeded

public void growIfNeeded()
Overrides:
growIfNeeded in class NoVarsDynamicScope

cloneScope

public DynamicScope cloneScope()
Overrides:
cloneScope in class NoVarsDynamicScope

getValues

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

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

getValueDepthZeroOrNil

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

Overrides:
getValueDepthZeroOrNil in class NoVarsDynamicScope

getValueZeroDepthZeroOrNil

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

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

setValueZeroDepthZero

public IRubyObject setValueZeroDepthZero(IRubyObject value)
Description copied from class: DynamicScope
Set value zero in this scope;

Overrides:
setValueZeroDepthZero 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 NoVarsDynamicScope
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(IRubyObject arg0)
Overrides:
setArgValues in class NoVarsDynamicScope

setArgValues

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

setArgValues

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

setEndArgValues

public void setEndArgValues(IRubyObject[] values,
                            int index,
                            int size)
Overrides:
setEndArgValues in class NoVarsDynamicScope
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 IRubyObject[] getArgValues()
Description copied from class: DynamicScope
Copy variable values back for ZSuper call.

Overrides:
getArgValues in class NoVarsDynamicScope

toString

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


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