|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.erights.e.elang.scope.ScopeMap
Untamed: Static information about the runtime representation of a Scope
.
A ScopeMap and an EvalContext
together form a Scope. The
ScopeMap maps from names to NounExpr
s which will retrieve the
corresponding org.erights.e.elib.slot.Slot
or value from a
corresponding EvalContext. Each EvalContext can be seen as an instantiation
of a ScopeMap.
A ScopeMap is built out of layered scopes, with the layers separated
by ScopeMapContour
s. At the lowest layer is a
ScopeMapBase
that may contain many bindings; each additional
binding is added in a ScopeMapLink
.
For example, if a, b, and c are extant in the outermost scope, and
declarations are added like this:
def d := ... { def e := ... def f := ... { def g := ... } }then the resulting structure would look like this:
____________________________________________ | _______________ | | | | | Base <- Link <- Contour <- Link <- Link <- Contour <- Link | | a, b, c d | e f | g | | | |_______________| | |____________________________________________|ScopeMaps are DeepFrozen (though not currently DeepPassByCopy). They are therefore thread-safe, and can be shared between vats. This is necessary for
OuterScope.diverge(java.lang.String)
to be thread-safe.
Field Summary | |
static ScopeMap |
EMPTY
Enabled: The empty ScopeMap |
Constructor Summary | |
ScopeMap()
Enabled: |
Method Summary | |
(package private) abstract void |
addNamesTo(FlexSet names)
Adds all the names mapped by this ScopeMap to 'names' |
abstract void |
assertShadowable(String varName)
Enabled: Throw an exception is the varName may not be shadowed because it is already defined in the current (i.e. |
abstract boolean |
contains(String varName)
Enabled: Is 'varName' in scope? |
abstract NounExpr |
getNoun(String varName)
Enabled: Gets the NounExpr which will retrieve the Slot/value of the variable named 'varName' from a corresponding EvalContext. |
static ScopeMap |
make(ConstMap bindings)
Enabled: @param bindings must be a mapping from names (Strings) to NounExprs. |
ConstSet |
namesSet()
Enabled: Return the set of all names mapped by this ScopeMap. |
ScopeMap |
nested()
Enabled: Makes a new ScopeMap just like this one, but with a new empty innermost contour added. |
ScopeMap |
with(String varName,
NounExpr noun)
Enabled: Returns a ScopeMap just like this one, but with a new varName => NounExpr mapping added to the innermost contour. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final ScopeMap EMPTY
Constructor Detail |
public ScopeMap()
Method Detail |
public static ScopeMap make(ConstMap bindings)
public abstract NounExpr getNoun(String varName)
public abstract boolean contains(String varName)
public ScopeMap with(String varName, NounExpr noun)
This does not create a new contour, so this operation is rejected if varName is already defined in the innermost contour.
public ConstSet namesSet()
abstract void addNamesTo(FlexSet names)
public ScopeMap nested()
public abstract void assertShadowable(String varName)
If varName may not be shadowed because it is reserved, this is caught
in org.erights.e.elang.evm.NounPattern
rather than here.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |