org.erights.e.elang.scope
Class OuterScope

java.lang.Object
  |
  +--org.erights.e.elang.scope.Scope
        |
        +--org.erights.e.elang.scope.OuterScope
All Implemented Interfaces:
Iteratable

public class OuterScope
extends Scope

Untamed:


Field Summary
private  boolean myIsMutable
           
private  int myNextOuter
           
private  String myOptFQNPrefix
           
private  Slot[] myOuters
           
 
Fields inherited from class org.erights.e.elang.scope.Scope
myScopeMap
 
Constructor Summary
private OuterScope(ScopeMap map, Slot[] outers, int nextOuter, boolean isMutable, String optFQNPrefix)
           
 
Method Summary
 void bindOuter(String name, Slot slot)
          Enabled:
 void cleanup()
          Enabled: If a top-level definition is aborted, it can leave behind a slot that was reserved but never bound to anything.
 Scope diverge(String fqnPrefix)
          Enabled: Return a new non-mutable OuterScope that does not share outers data structures with the receiver.
(package private)  Slot getCurrentAtIndex(int index)
           
 Slot getIndex(int index)
          Enabled:
 String getOptFQNPrefix()
          Enabled:
 Slot getSlot(String name)
          Enabled:
(package private)  void initIndex(int index, Slot value)
           
static OuterScope make(ScopeMap map, Slot[] outers, int nextOuter, boolean isMutable, String optFQNPrefix)
          Enabled:
 EvalContext newContext(int numLocals)
          Enabled:
private  int nextIndex()
           
 void put(String name, Object newValue)
          Enabled: Override to avoid overhead of ForwardingSlot
 NounExpr reserveOuterNoun(String name)
          Enabled: TODO make this less exposed
 String toString()
          Suppressed:
 
Methods inherited from class org.erights.e.elang.scope.Scope
asMap, bindFinal, bindings, bindings, get, get, getScopeMap, in, iterate, maps
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myOuters

private Slot[] myOuters

myNextOuter

private int myNextOuter

myIsMutable

private final boolean myIsMutable

myOptFQNPrefix

private final String myOptFQNPrefix
Constructor Detail

OuterScope

private OuterScope(ScopeMap map,
                   Slot[] outers,
                   int nextOuter,
                   boolean isMutable,
                   String optFQNPrefix)
Method Detail

make

public static OuterScope make(ScopeMap map,
                              Slot[] outers,
                              int nextOuter,
                              boolean isMutable,
                              String optFQNPrefix)
Enabled:


getOptFQNPrefix

public String getOptFQNPrefix()
Enabled:

Specified by:
getOptFQNPrefix in class Scope

getCurrentAtIndex

Slot getCurrentAtIndex(int index)

getIndex

public Slot getIndex(int index)
Enabled:


initIndex

void initIndex(int index,
               Slot value)

reserveOuterNoun

public NounExpr reserveOuterNoun(String name)
Enabled: TODO make this less exposed

Specified by:
reserveOuterNoun in class Scope

nextIndex

private int nextIndex()

diverge

public Scope diverge(String fqnPrefix)
Enabled: Return a new non-mutable OuterScope that does not share outers data structures with the receiver.

ImportLoader is potentially used from multiple vats, and so must be thread-safe. An ImportLoader holds an OuterScope only for the purpose of diverging new OuterScopes per emaker eval. Therefore, the state that can be shared between diverged scopes needs to be thread-safe. That state is myScopeMap, and ScopeMaps are indeed thread-safe.

Specified by:
diverge in class Scope

getSlot

public Slot getSlot(String name)
Enabled:

Specified by:
getSlot in class Scope

put

public void put(String name,
                Object newValue)
Enabled: Override to avoid overhead of ForwardingSlot

Overrides:
put in class Scope

bindOuter

public void bindOuter(String name,
                      Slot slot)
               throws AlreadyDefinedException
Enabled:

Specified by:
bindOuter in class Scope
AlreadyDefinedException

newContext

public EvalContext newContext(int numLocals)
Enabled:

Specified by:
newContext in class Scope

cleanup

public void cleanup()
Enabled: If a top-level definition is aborted, it can leave behind a slot that was reserved but never bound to anything.

To prevent inconsistencies, fill in these holes with ruined slots

Overrides:
cleanup in class Scope

toString

public String toString()
Suppressed:

Overrides:
toString in class Object
Returns:
a string representation of the object.


comments?