| java.lang.Object org.jruby.runtime.DynamicScope
DynamicScope | public class DynamicScope (Code) | | Represents the the dynamic portion of scoping information. The variableValues are the
values of assigned local or block variables. The staticScope identifies which sort of
scope this is (block or local).
Properties of Dynamic Scopes:
1. static and dynamic scopes have the same number of names to values
2. size of variables (and thus names) is determined during parsing. So those structured do
not need to change
FIXME: When creating dynamic scopes we sometimes accidentally pass in extra parents. This
is harmless (other than wasting memory), but we should not do that. We can fix this in two
ways:
1. Fix all callers
2. Check parent that is passed in and make if new instance is local, then its parent is not local
|
getAllNamesInScope | public String[] getAllNamesInScope()(Code) | | Get all variable names captured (visible) by this scope (sans $~ and $_).
a list of variable names |
getArgValues | public void getArgValues(IRubyObject[] args, int size)(Code) | | Copy variable values back for ZSuper call.
|
getNextCapturedScope | public DynamicScope getNextCapturedScope()(Code) | | Get next 'captured' scope.
the scope captured by this scope for implementing closures |
getStaticScope | public StaticScope getStaticScope()(Code) | | Get the static scope associated with this DynamicScope.
static complement to this scope |
getValue | public IRubyObject getValue(int offset, int depth)(Code) | | 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 Parameters: depth - how many captured scopes down this variable should be set the value here |
growIfNeeded | public void growIfNeeded()(Code) | | Make a larger dynamic scope if the static scope grew.
Eval's with bindings require us to possibly change the size of the dynamic scope if
things like 'eval "b = 2", binding' happens.
|
setArgValues | public void setArgValues(IRubyObject[] values, int size)(Code) | | 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 Parameters: size - is the number of values to assign as ordinary parm values |
setBlockArgValues | public void setBlockArgValues(IRubyObject[] blockArgValues, int size)(Code) | | |
setValue | public void setValue(int offset, IRubyObject value, int depth)(Code) | | Set value in current dynamic scope or one of its captured scopes.
Parameters: offset - zero-indexed value that represents where variable lives Parameters: value - to set Parameters: depth - how many captured scopes down this variable should be set |
|
|