[e-cvs] cvs commit: e/src/jsrc/org/erights/e/meta/java/io ReadOnlyFile.java
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Mon, 12 Nov 2001 13:23:18 -0500
markm 01/11/12 13:23:18
Modified: src/jsrc/org/capml/dom Node.java
src/jsrc/org/erights/e/elang/evm EExpr.java EImpl.java
EImplByProxy.java EMethodNode.java
FrameFinalNounExpr.java FrameSlotNounExpr.java
LiteralNounExpr.java LiteralSlotNounExpr.java
LocalFinalNounExpr.java LocalSlotNounExpr.java
NounExpr.java OuterNounExpr.java ScopeExpr.java
SlotExpr.java
src/jsrc/org/erights/e/elang/interp Loader.java
LoaderScope.java ScopeSetup.java
UnsafeLoaderScope.java
src/jsrc/org/erights/e/elang/scope EvalContext.java
InnerScope.java OuterScope.java Scope.java
ScopeMap.java UndefinedVariableException.java
src/jsrc/org/erights/e/elang/visitors
AlphaRenameVisitor.java BindFramesVisitor.java
src/jsrc/org/erights/e/elib/quasi Identifiers.java
src/jsrc/org/erights/e/elib/tables ConstMap.java
ConstMapImpl.java EList.java EMap.java ESet.java
FlexMapImpl.java FlexSet.java IdentityMap.java
ROMap.java
src/jsrc/org/erights/e/meta/java/io ReadOnlyFile.java
Removed: src/jsrc/org/erights/e/elang/evm EImplByRelay.java
Log:
ScopeMaps now know that they are immutable. Introduced Iteratable.
Revision Changes Path
1.6 +2 -1 e/src/jsrc/org/capml/dom/Node.java
Index: Node.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/capml/dom/Node.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Node.java 2001/09/07 05:49:20 1.5
+++ Node.java 2001/11/12 18:23:15 1.6
@@ -22,6 +22,7 @@
import org.erights.e.elib.tables.AssocFunc;
import org.erights.e.elib.tables.ConstList;
import org.erights.e.elib.tables.Selfless;
+import org.erights.e.elib.tables.Iteratable;
import java.io.IOException;
@@ -53,7 +54,7 @@
* </blockquote>
*/
public abstract class Node
-implements PassByConstruction, Persistent, Selfless {
+implements PassByConstruction, Persistent, Selfless, Iteratable {
// NodeType
static public final short ELEMENT_NODE = 1;
1.31 +1 -0 e/src/jsrc/org/erights/e/elang/evm/EExpr.java
Index: EExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/EExpr.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- EExpr.java 2001/11/11 05:54:36 1.30
+++ EExpr.java 2001/11/12 18:23:15 1.31
@@ -35,6 +35,7 @@
* expressions evaluated by the E Virtual Machine.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public abstract class EExpr extends ENode {
1.26 +1 -0 e/src/jsrc/org/erights/e/elang/evm/EImpl.java
Index: EImpl.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/EImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- EImpl.java 2001/11/10 19:40:39 1.25
+++ EImpl.java 2001/11/12 18:23:15 1.26
@@ -38,6 +38,7 @@
* What an object expression evaluates to.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public abstract class EImpl implements Callable {
1.11 +1 -0 e/src/jsrc/org/erights/e/elang/evm/EImplByProxy.java
Index: EImplByProxy.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/EImplByProxy.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- EImplByProxy.java 2001/11/10 19:40:39 1.10
+++ EImplByProxy.java 2001/11/12 18:23:15 1.11
@@ -27,6 +27,7 @@
* An EImpl that's PassByProxy
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class EImplByProxy extends EImpl implements PassByProxy {
1.25 +1 -0 e/src/jsrc/org/erights/e/elang/evm/EMethodNode.java
Index: EMethodNode.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/EMethodNode.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- EMethodNode.java 2001/11/10 19:40:39 1.24
+++ EMethodNode.java 2001/11/12 18:23:15 1.25
@@ -31,6 +31,7 @@
*
* @see org.erights.e.elib.prim.VTable
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class EMethodNode extends MethodNode {
1.3 +1 -1 e/src/jsrc/org/erights/e/elang/evm/FrameFinalNounExpr.java
Index: FrameFinalNounExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/FrameFinalNounExpr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FrameFinalNounExpr.java 2001/11/10 19:40:39 1.2
+++ FrameFinalNounExpr.java 2001/11/12 18:23:15 1.3
@@ -29,7 +29,7 @@
/**
* What an object expression evaluates to.
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class FrameFinalNounExpr extends NounExpr {
1.3 +1 -1 e/src/jsrc/org/erights/e/elang/evm/FrameSlotNounExpr.java
Index: FrameSlotNounExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/FrameSlotNounExpr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FrameSlotNounExpr.java 2001/11/10 19:40:39 1.2
+++ FrameSlotNounExpr.java 2001/11/12 18:23:15 1.3
@@ -28,7 +28,7 @@
/**
* What an object expression evaluates to.
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class FrameSlotNounExpr extends NounExpr {
1.3 +1 -1 e/src/jsrc/org/erights/e/elang/evm/LiteralNounExpr.java
Index: LiteralNounExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/LiteralNounExpr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LiteralNounExpr.java 2001/11/10 19:40:39 1.2
+++ LiteralNounExpr.java 2001/11/12 18:23:15 1.3
@@ -27,7 +27,7 @@
/**
* A noun-expr for compile-time literals, particularly universal constants.
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class LiteralNounExpr extends NounExpr {
1.3 +2 -2 e/src/jsrc/org/erights/e/elang/evm/LiteralSlotNounExpr.java
Index: LiteralSlotNounExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/LiteralSlotNounExpr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LiteralSlotNounExpr.java 2001/11/10 19:40:39 1.2
+++ LiteralSlotNounExpr.java 2001/11/12 18:23:15 1.3
@@ -24,9 +24,9 @@
import org.erights.e.elib.util.AlreadyDefinedException;
/**
- * What an object expression evaluates to.
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ *
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class LiteralSlotNounExpr extends NounExpr {
1.3 +2 -2 e/src/jsrc/org/erights/e/elang/evm/LocalFinalNounExpr.java
Index: LocalFinalNounExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/LocalFinalNounExpr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LocalFinalNounExpr.java 2001/11/10 19:40:39 1.2
+++ LocalFinalNounExpr.java 2001/11/12 18:23:15 1.3
@@ -27,9 +27,9 @@
import java.io.IOException;
/**
- * What an object expression evaluates to.
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ *
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class LocalFinalNounExpr extends NounExpr {
1.3 +2 -2 e/src/jsrc/org/erights/e/elang/evm/LocalSlotNounExpr.java
Index: LocalSlotNounExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/LocalSlotNounExpr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LocalSlotNounExpr.java 2001/11/10 19:40:39 1.2
+++ LocalSlotNounExpr.java 2001/11/12 18:23:15 1.3
@@ -26,9 +26,9 @@
import java.io.IOException;
/**
- * What an object expression evaluates to.
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ *
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class LocalSlotNounExpr extends NounExpr {
1.27 +1 -0 e/src/jsrc/org/erights/e/elang/evm/NounExpr.java
Index: NounExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/NounExpr.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- NounExpr.java 2001/11/10 19:40:39 1.26
+++ NounExpr.java 2001/11/12 18:23:15 1.27
@@ -36,6 +36,7 @@
* Returns the value of the variable of this name in the current scope.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class NounExpr extends EExpr {
1.3 +2 -2 e/src/jsrc/org/erights/e/elang/evm/OuterNounExpr.java
Index: OuterNounExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/OuterNounExpr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OuterNounExpr.java 2001/11/10 19:40:39 1.2
+++ OuterNounExpr.java 2001/11/12 18:23:16 1.3
@@ -26,9 +26,9 @@
import java.io.IOException;
/**
- * What an object expression evaluates to.
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ *
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class OuterNounExpr extends NounExpr {
1.23 +1 -1 e/src/jsrc/org/erights/e/elang/evm/ScopeExpr.java
Index: ScopeExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/ScopeExpr.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ScopeExpr.java 2001/11/10 19:40:39 1.22
+++ ScopeExpr.java 2001/11/12 18:23:16 1.23
@@ -30,7 +30,7 @@
/**
- * BNF: "meta scope" <p>
+ * BNF: "meta scope()" <p>
*
* @see org.erights.e.elang.scope.Scope
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
1.26 +1 -0 e/src/jsrc/org/erights/e/elang/evm/SlotExpr.java
Index: SlotExpr.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/SlotExpr.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- SlotExpr.java 2001/11/10 19:40:39 1.25
+++ SlotExpr.java 2001/11/12 18:23:16 1.26
@@ -35,6 +35,7 @@
* Returns the slot holding the noun's value
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class SlotExpr extends EExpr {
1.5 +1 -1 e/src/jsrc/org/erights/e/elang/interp/Loader.java
Index: Loader.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/Loader.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Loader.java 2001/11/11 23:32:16 1.4
+++ Loader.java 2001/11/12 18:23:16 1.5
@@ -27,7 +27,7 @@
/**
* Provides access to the java fully-qualified class namespace
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public abstract class Loader implements EPrintable {
1.39 +1 -0 e/src/jsrc/org/erights/e/elang/interp/LoaderScope.java
Index: LoaderScope.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/LoaderScope.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- LoaderScope.java 2001/11/11 23:32:16 1.38
+++ LoaderScope.java 2001/11/12 18:23:16 1.39
@@ -42,6 +42,7 @@
* The Loader bound to import__uriGetter.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
/*package*/ class LoaderScope extends Loader {
1.71 +8 -2 e/src/jsrc/org/erights/e/elang/interp/ScopeSetup.java
Index: ScopeSetup.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/ScopeSetup.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- ScopeSetup.java 2001/11/11 05:54:36 1.70
+++ ScopeSetup.java 2001/11/12 18:23:16 1.71
@@ -60,6 +60,7 @@
* The initial namespace as seen by the E language programmer.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public abstract class ScopeSetup {
@@ -314,6 +315,10 @@
return priv;
}
+ /**
+ *
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
+ */
static private class ScopeMaker {
static private final int DEFAULT_SIZE = 50;
@@ -345,14 +350,15 @@
}
public Scope scope(boolean isMutable) {
- ScopeMap outerNouns = ScopeMap.make(myBindings);
+ ScopeMap outerNouns = ScopeMap.make(myBindings.snapshot());
int outerCount = myOuters.size();
int outerSpace = outerCount + OUTER_SPACE;
Slot[] outers = (Slot[])myOuters.getArray(Slot.class);
return OuterScope.make(outerNouns, outers, outerCount, isMutable);
}
- // generate a bindings for a noun that will be compiled into transformed code
+ // generate a bindings for a noun that will be compiled into
+ // transformed code
public void comp(String name, Object value) {
myBindings.put(name, new LiteralNounExpr(name, value));
}
1.12 +1 -0 e/src/jsrc/org/erights/e/elang/interp/UnsafeLoaderScope.java
Index: UnsafeLoaderScope.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/UnsafeLoaderScope.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- UnsafeLoaderScope.java 2001/11/11 23:32:16 1.11
+++ UnsafeLoaderScope.java 2001/11/12 18:23:16 1.12
@@ -35,6 +35,7 @@
* The Loader bound to unsafe__uriGetter.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
/*package*/ class UnsafeLoaderScope extends Loader {
1.4 +1 -1 e/src/jsrc/org/erights/e/elang/scope/EvalContext.java
Index: EvalContext.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/scope/EvalContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EvalContext.java 2001/11/11 17:51:13 1.3
+++ EvalContext.java 2001/11/12 18:23:16 1.4
@@ -27,7 +27,7 @@
*
* Three groups of variables comprise the execution state of the
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class EvalContext {
1.4 +1 -1 e/src/jsrc/org/erights/e/elang/scope/InnerScope.java
Index: InnerScope.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/scope/InnerScope.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InnerScope.java 2001/11/11 17:51:13 1.3
+++ InnerScope.java 2001/11/12 18:23:16 1.4
@@ -29,7 +29,7 @@
* Made after the fact from a ScopeMap (static info) and an EvalContext
* (runtime info).
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class InnerScope extends Scope {
1.4 +1 -1 e/src/jsrc/org/erights/e/elang/scope/OuterScope.java
Index: OuterScope.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/scope/OuterScope.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OuterScope.java 2001/11/11 17:51:13 1.3
+++ OuterScope.java 2001/11/12 18:23:16 1.4
@@ -28,7 +28,7 @@
/**
* The normal implementation of an outermost E lexical scope.
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class OuterScope extends Scope {
1.50 +1 -0 e/src/jsrc/org/erights/e/elang/scope/Scope.java
Index: Scope.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/scope/Scope.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- Scope.java 2001/11/11 17:51:13 1.49
+++ Scope.java 2001/11/12 18:23:16 1.50
@@ -39,6 +39,7 @@
* be used to model nesting lexical environments. The associations in
* the most leafward part of a Scope are called "locals". <p>
*
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
public abstract class Scope {
1.5 +47 -132 e/src/jsrc/org/erights/e/elang/scope/ScopeMap.java
Index: ScopeMap.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/scope/ScopeMap.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ScopeMap.java 2001/11/11 05:54:37 1.4
+++ ScopeMap.java 2001/11/12 18:23:16 1.5
@@ -30,24 +30,52 @@
import org.erights.e.elib.tables.ESet;
/**
+ * Static information about the runtime representation of a {@link Scope}.
+ * <p>
+ * A ScopeMap and an {@link EvalContext} together form a Scope. The ScopeMap
+ * maps from names to {@link NounExpr}s which will retrieve the corresponding
+ * {@link Slot} or value from a corresponding EvalContext. Each EvalContext
+ * can be seen as an instantiation of the corresponding ScopeMap.
*
- *
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
+ * @author some mods by <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
public abstract class ScopeMap {
+ /**
+ * The empty ScopeMap
+ */
static public final ScopeMap EMPTY =
new ScopeMapBase(ConstMap.EmptyMap);
- static public ScopeMap make(EMap initial) {
- return new ScopeMapBase(initial);
+ /**
+ * @param bindings must be a mapping from names (Strings) to NounExprs.
+ * @return The ScopeMap representing exactly this mapping as a single
+ * contour
+ */
+ static public ScopeMap make(ConstMap bindings) {
+ return new ScopeMapBase(bindings);
}
- public abstract NounExpr getNoun(String name);
-
- public abstract boolean contains(String name);
+ /**
+ * Gets the NounExpr which will retrieve the Slot/value of the variable
+ * named 'varName' from a corresponding EvalContext.
+ */
+ public abstract NounExpr getNoun(String varName);
- public abstract int count();
+ /**
+ * Is 'varName' in scope?
+ */
+ public abstract boolean contains(String varName);
+ /**
+ * Returns a ScopeMap just like this one, but with a new
+ * varName => NounExpr mapping added to the last contour.
+ * <p>
+ * This does not create a new contour, so this operation is rejected if
+ * varName is already defined in the last contour. The operation is also
+ * rejected if varName is reserved.
+ */
public ScopeMap with(String varName, NounExpr noun) {
assertShadowable(varName);
return new ScopeMapLink(varName, noun, this);
@@ -56,10 +84,20 @@
/*
* Return the set of all names mapped by the receiver.
*/
- public abstract ESet namesSet();
+ public ConstSet namesSet() {
+ FlexSet result = FlexSet.fromType(String.class);
+ addNamesTo(result);
+ return result.snapshot();
+ }
+ /**
+ * Adds all the names mapped by the receiver to 'names'
+ */
+ /*package*/ abstract void addNamesTo(FlexSet names);
+
/*
- * Make a new contour within the receiver.
+ * Makes a new ScopeMap just like this one, but with a new empty last
+ * contour added.
*/
public ScopeMap nested() {
return new ContourBoundary(this);
@@ -71,127 +109,4 @@
* in the innermost contour.
*/
public abstract void assertShadowable(String varName);
-}
-
-/**
- *
- */
-class ContourBoundary extends ScopeMap {
-
- private ScopeMap myNext;
-
- public ContourBoundary(ScopeMap outer) {
- myNext = outer;
- }
-
- public int count() {
- return myNext.count();
- }
-
- public NounExpr getNoun(String name) {
- return myNext.getNoun(name);
- }
-
- public boolean contains(String name) {
- return myNext.contains(name);
- }
-
- public ESet namesSet() {
- return myNext.namesSet();
- }
-
- public void assertShadowable(String varName) {
- // Do nothing; we are at the end of the contour
- }
-
- /*
- * There is no need for two contiguous boundaries, so just return self.
- */
- public ScopeMap nested() {
- return this;
- }
-
-
-}
-
-/**
- *
- *
- */
-class ScopeMapLink extends ScopeMap {
-
- private ScopeMap myNext;
-
- private final String myName;
-
- private final NounExpr myNoun;
-
- public ScopeMapLink(String name, NounExpr noun, ScopeMap others) {
- myNext = others;
- myName = name;
- myNoun = noun;
- }
-
- public int count() {
- return myNext.count() + 1;
- }
-
- public NounExpr getNoun(String name) {
- // TODO markm are we guaranteed that the names are canonical?
- return myName.equals(name) ? myNoun : myNext.getNoun(name);
- }
-
- public boolean contains(String name) {
- // TODO markm are we guaranteed that the names are canonical?
- return myName.equals(name) || myNext.contains(name);
- }
-
- public ESet namesSet() {
- FlexSet res = myNext.namesSet().diverge();
- res.add(myName);
- return res;
- }
-
- public void assertShadowable(String name) {
- // TODO markm are we guaranteed that the names are canonical?
- if (myName.equals(name)) {
- throw new AlreadyDefinedException(name + " already in scope");
- }
- myNext.assertShadowable(name);
- }
-}
-
-class ScopeMapBase extends ScopeMap {
-
- private final EMap myBindings;
-
- public ScopeMapBase(EMap bindings) {
- myBindings = bindings;
- }
-
- public int count() {
- return myBindings.size();
- }
-
- public NounExpr getNoun(String name) {
- NounExpr optRes = (NounExpr)myBindings.get(name);
- if (optRes == null) {
- throw new UndefinedVariableException(name + " not in scope");
- }
- return optRes;
- }
-
- public boolean contains(String name) {
- return myBindings.maps(name);
- }
-
- public ESet namesSet() {
- return myBindings.domain();
- }
-
- public void assertShadowable(String name) {
- if (contains(name)) {
- throw new AlreadyDefinedException(name + " already in scope");
- }
- }
}
1.7 +2 -3 e/src/jsrc/org/erights/e/elang/scope/UndefinedVariableException.java
Index: UndefinedVariableException.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/scope/UndefinedVariableException.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- UndefinedVariableException.java 2001/11/10 19:40:41 1.6
+++ UndefinedVariableException.java 2001/11/12 18:23:16 1.7
@@ -21,12 +21,11 @@
/**
* Thrown when a variable cannot be found in a given scope
*
- * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public class UndefinedVariableException extends IndexOutOfBoundsException {
- public UndefinedVariableException() {
- }
+ public UndefinedVariableException() {}
public UndefinedVariableException(String varName) {
super(varName);
1.14 +3 -1 e/src/jsrc/org/erights/e/elang/visitors/AlphaRenameVisitor.java
Index: AlphaRenameVisitor.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/visitors/AlphaRenameVisitor.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- AlphaRenameVisitor.java 2001/11/10 19:40:43 1.13
+++ AlphaRenameVisitor.java 2001/11/12 18:23:16 1.14
@@ -31,7 +31,9 @@
/**
- * Like RenameVisitor, but does an 'alpha-renaming'. An alpha renaming gives
+ * Like RenameVisitor, but does an 'alpha-renaming'.
+ * <p>
+ * An alpha renaming gives
* each distinct variable a unique name. Since we are not in control of
* top-level names, we rename exactly variables defined in nested scope
* boxes. We use a HilbertHotel to generate new names and to transform old
1.5 +10 -1 e/src/jsrc/org/erights/e/elang/visitors/BindFramesVisitor.java
Index: BindFramesVisitor.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/visitors/BindFramesVisitor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BindFramesVisitor.java 2001/11/11 05:54:37 1.4
+++ BindFramesVisitor.java 2001/11/12 18:23:17 1.5
@@ -43,6 +43,7 @@
/**
*
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
*/
public abstract class BindFramesVisitor extends CopyVisitor {
@@ -153,7 +154,7 @@
newBindings.put(newNoun.name(), newNoun);
}
}
- ScopeMap inner = ScopeMap.make(newBindings);
+ ScopeMap inner = ScopeMap.make(newBindings.snapshot());
CopyVisitor nested = nestObject(inner);
return new ObjectExpr(docComment,
optFQN,
@@ -223,6 +224,10 @@
/**************************** Internal ************************/
}
+/**
+ *
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
+ */
class BindNestedVisitor extends BindFramesVisitor {
protected int myNextLocal;
@@ -258,6 +263,10 @@
}
+/**
+ *
+ * @author <a href="mailto:tribble@e-dean.com">E. Dean Tribble</a>
+ */
class BindOuterVisitor extends BindFramesVisitor {
private Scope myScope;
1.9 +26 -16 e/src/jsrc/org/erights/e/elib/quasi/Identifiers.java
Index: Identifiers.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/quasi/Identifiers.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Identifiers.java 2001/11/10 19:40:46 1.8
+++ Identifiers.java 2001/11/12 18:23:17 1.9
@@ -20,6 +20,8 @@
*/
import org.erights.e.elib.tables.AssocFunc;
+import org.erights.e.elib.tables.Iteratable;
+import org.erights.e.develop.exception.ExceptionMgr;
import java.io.File;
import java.io.FileNotFoundException;
@@ -32,7 +34,7 @@
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
-public class Identifiers {
+public class Identifiers implements Iteratable {
Reader myReader;
@@ -53,22 +55,30 @@
/**
*
*/
- public void iterate(AssocFunc func) throws IOException, Throwable {
- int ch = myReader.read();
- StringBuffer delim = new StringBuffer();
- StringBuffer ident = new StringBuffer();
- while (ch != -1) {
- delim.setLength(0);
- ident.setLength(0);
- while (ch != -1 && !Character.isJavaIdentifierPart((char)ch)) {
- delim.append((char)ch);
- ch = myReader.read();
+ public void iterate(AssocFunc func) {
+ try {
+ int ch = myReader.read();
+ StringBuffer delim = new StringBuffer();
+ StringBuffer ident = new StringBuffer();
+ while (ch != -1) {
+ delim.setLength(0);
+ ident.setLength(0);
+ while (ch != -1 &&
+ !Character.isJavaIdentifierPart((char)ch))
+ {
+ delim.append((char)ch);
+ ch = myReader.read();
+ }
+ while (ch != -1 &&
+ Character.isJavaIdentifierPart((char)ch))
+ {
+ ident.append((char)ch);
+ ch = myReader.read();
+ }
+ func.run(delim.toString(), ident.toString());
}
- while (ch != -1 && Character.isJavaIdentifierPart((char)ch)) {
- ident.append((char)ch);
- ch = myReader.read();
- }
- func.run(delim.toString(), ident.toString());
+ } catch (IOException ioe) {
+ throw ExceptionMgr.asSafe(ioe);
}
}
}
1.28 +3 -1 e/src/jsrc/org/erights/e/elib/tables/ConstMap.java
Index: ConstMap.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ConstMap.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- ConstMap.java 2001/11/11 05:54:37 1.27
+++ ConstMap.java 2001/11/12 18:23:17 1.28
@@ -100,7 +100,9 @@
}
/**
- *
+ * The domain of a ConstMap is always a {@link ConstSet}, but is declared
+ * as an ESet because Java's type system doesn't allow covariant return
+ * types.
*/
public ESet domain() {
return ConstSet.make(this);
1.21 +1 -1 e/src/jsrc/org/erights/e/elib/tables/ConstMapImpl.java
Index: ConstMapImpl.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ConstMapImpl.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ConstMapImpl.java 2001/11/11 00:15:31 1.20
+++ ConstMapImpl.java 2001/11/12 18:23:17 1.21
@@ -70,7 +70,7 @@
/**
*
*/
- public void iterate(AssocFunc func) throws Throwable {
+ public void iterate(AssocFunc func) {
myTable.iterate(func);
}
1.32 +1 -1 e/src/jsrc/org/erights/e/elib/tables/EList.java
Index: EList.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/EList.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- EList.java 2001/11/11 05:54:37 1.31
+++ EList.java 2001/11/12 18:23:17 1.32
@@ -48,7 +48,7 @@
* @see org.erights.e.elib.tables.FlexList
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
-public abstract class EList implements EPrintable, Persistent {
+public abstract class EList implements EPrintable, Persistent, Iteratable {
static private final long serialVersionUID = 4755060696966322025L;
1.31 +2 -2 e/src/jsrc/org/erights/e/elib/tables/EMap.java
Index: EMap.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/EMap.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- EMap.java 2001/11/11 05:54:37 1.30
+++ EMap.java 2001/11/12 18:23:17 1.31
@@ -62,7 +62,7 @@
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
-public abstract class EMap implements EPrintable, Persistent {
+public abstract class EMap implements EPrintable, Persistent, Iteratable {
static private final long serialVersionUID = -7066420784218105992L;
@@ -159,7 +159,7 @@
/**
* Call 'func' with each key-value pair in the table, in order.
*/
- public void iterate(AssocFunc func) throws Throwable {
+ public void iterate(AssocFunc func) {
Object[] pair = getPair();
Object keys = pair[0];
Object vals = pair[1];
1.2 +2 -2 e/src/jsrc/org/erights/e/elib/tables/ESet.java
Index: ESet.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ESet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ESet.java 2001/11/11 05:54:37 1.1
+++ ESet.java 2001/11/12 18:23:17 1.2
@@ -37,7 +37,7 @@
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
-public abstract class ESet implements EPrintable, Persistent {
+public abstract class ESet implements EPrintable, Persistent, Iteratable {
/**
*
@@ -110,7 +110,7 @@
/**
* Call 'func' with each index-value pair in the set, in order.
*/
- public void iterate(AssocFunc func) throws Throwable {
+ public void iterate(AssocFunc func) {
ConstList.fromArray(getElements()).iterate(func);
}
1.24 +1 -1 e/src/jsrc/org/erights/e/elib/tables/FlexMapImpl.java
Index: FlexMapImpl.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/FlexMapImpl.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- FlexMapImpl.java 2001/11/11 00:15:31 1.23
+++ FlexMapImpl.java 2001/11/12 18:23:17 1.24
@@ -258,7 +258,7 @@
/**
*
*/
- public void iterate(AssocFunc func) throws Throwable {
+ public void iterate(AssocFunc func) {
FlexMapImpl snapshot = (FlexMapImpl)clone();
try {
KeyColumn keys = snapshot.myKeys;
1.2 +53 -3 e/src/jsrc/org/erights/e/elib/tables/FlexSet.java
Index: FlexSet.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/FlexSet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FlexSet.java 2001/11/11 05:54:37 1.1
+++ FlexSet.java 2001/11/12 18:23:17 1.2
@@ -28,6 +28,20 @@
/**
*
*/
+ static public FlexSet fromType(Class type) {
+ return new FlexSet(FlexMap.fromTypes(type, Void.TYPE));
+ }
+
+ /**
+ *
+ */
+ static public FlexSet fromType(Class type, int capacity) {
+ return new FlexSet(FlexMap.fromTypes(type, Void.TYPE, capacity));
+ }
+
+ /**
+ *
+ */
private FlexMap getMap() {
return (FlexMap)myMap;
}
@@ -42,8 +56,8 @@
/**
* 'strict' defaults to false
*/
- public void add(Object newElement) {
- add(newElement, false);
+ public void addElement(Object newElement) {
+ addElement(newElement, false);
}
/**
@@ -51,13 +65,31 @@
* <p>
* If it's already there, then if strict, throw an exception.
*/
- public void add(Object newElement, boolean strict) {
+ public void addElement(Object newElement, boolean strict) {
getMap().put(newElement, null, strict);
}
/**
* 'strict' defaults to false
*/
+ public void addAll(Iteratable other) {
+ addAll(other, false);
+ }
+
+ /**
+ *
+ */
+ public void addAll(Iteratable other, final boolean strict) {
+ other.iterate(new AssocFunc() {
+ public void run(Object ignored, Object element) {
+ addElement(element, strict);
+ }
+ });
+ }
+
+ /**
+ * 'strict' defaults to false
+ */
public void remove(Object element) {
remove(element, false);
}
@@ -69,5 +101,23 @@
*/
public void remove(Object element, boolean strict) {
getMap().removeKey(element, strict);
+ }
+
+ /**
+ * 'strict' defaults to false
+ */
+ public void removeAll(Iteratable other) {
+ removeAll(other, false);
+ }
+
+ /**
+ *
+ */
+ public void removeAll(Iteratable other, final boolean strict) {
+ other.iterate(new AssocFunc() {
+ public void run(Object ignored, Object element) {
+ remove(element, strict);
+ }
+ });
}
}
1.11 +10 -3 e/src/jsrc/org/erights/e/elib/tables/IdentityMap.java
Index: IdentityMap.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/IdentityMap.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- IdentityMap.java 2001/11/11 00:15:31 1.10
+++ IdentityMap.java 2001/11/12 18:23:17 1.11
@@ -1,12 +1,14 @@
package org.erights.e.elib.tables;
+import org.erights.e.develop.exception.ExceptionMgr;
+
/**
* Like a FlexMap, but based on identity, and not as fancy. Not for general
* purpose use.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
-/*package*/ class IdentityMap {
+/*package*/ class IdentityMap implements Iteratable {
/**
*
@@ -197,8 +199,13 @@
/**
*
*/
- public void iterate(AssocFunc func) throws Throwable {
- IdentityMap snapshot = (IdentityMap)clone();
+ public void iterate(AssocFunc func) {
+ IdentityMap snapshot = null;
+ try {
+ snapshot = (IdentityMap)clone();
+ } catch (CloneNotSupportedException cnse) {
+ throw ExceptionMgr.asSafe(cnse);
+ }
try {
KeyColumn keys = snapshot.myKeys;
int[] rank2Pos = keys.rank2Pos();
1.20 +1 -1 e/src/jsrc/org/erights/e/elib/tables/ROMap.java
Index: ROMap.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ROMap.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ROMap.java 2001/11/11 05:54:37 1.19
+++ ROMap.java 2001/11/12 18:23:17 1.20
@@ -79,7 +79,7 @@
/**
*
*/
- public void iterate(AssocFunc func) throws Throwable {
+ public void iterate(AssocFunc func) {
myPrecious.iterate(func);
}
1.15 +12 -6 e/src/jsrc/org/erights/e/meta/java/io/ReadOnlyFile.java
Index: ReadOnlyFile.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/meta/java/io/ReadOnlyFile.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ReadOnlyFile.java 2001/11/10 19:40:50 1.14
+++ ReadOnlyFile.java 2001/11/12 18:23:18 1.15
@@ -5,6 +5,8 @@
import org.erights.e.elib.serial.Persistent;
import org.erights.e.elib.tables.AssocFunc;
import org.erights.e.elib.tables.Twine;
+import org.erights.e.elib.tables.Iteratable;
+import org.erights.e.develop.exception.ExceptionMgr;
import java.io.BufferedReader;
import java.io.File;
@@ -21,7 +23,7 @@
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
-public class ReadOnlyFile implements PassByProxy, Persistent {
+public class ReadOnlyFile implements PassByProxy, Persistent, Iteratable {
private File myPrecious;
@@ -234,7 +236,7 @@
* lineNumber => text line associations. Like Perl, each text
* line ends with a "\n".
*/
- public void iterate(AssocFunc func) throws Throwable {
+ public void iterate(AssocFunc func) {
if (myPrecious.isDirectory()) {
String[] names = myPrecious.list();
for (int i = 0; i < names.length; i++) {
@@ -248,11 +250,15 @@
func.run(names[i], value);
}
} else {
- Reader reader = new FileReader(myPrecious);
try {
- ReaderSugar.iterate(reader, func);
- } finally {
- reader.close();
+ Reader reader = new FileReader(myPrecious);
+ try {
+ ReaderSugar.iterate(reader, func);
+ } finally {
+ reader.close();
+ }
+ } catch (IOException ioe) {
+ throw ExceptionMgr.asSafe(ioe);
}
}
}