[e-cvs] cvs commit: e/src/jsrc/org/quasiliteral/term TermBuilder.java
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Mon, 17 Dec 2001 11:49:48 -0500
markm 01/12/17 11:49:47
Modified: src Makefile
src/jsrc/net/captp/tables CommTable.java SwissTable.java
src/jsrc/org/erights/e/elib/base ClassDesc.java
src/jsrc/org/erights/e/elib/prim StaticMaker.java
src/jsrc/org/erights/e/elib/tables Column.java
ConstList.java ConstSubclassSet.java
CycleBreaker.java EList.java EMap.java ESet.java
Equalizer.java
src/jsrc/org/erights/e/meta/java/lang ArrayGuardSugar.java
src/jsrc/org/erights/e/ui/jed EditGroup.java
src/jsrc/org/quasiliteral/syntax Indenter.java
src/jsrc/org/quasiliteral/term TermBuilder.java
Log:
some collection class housecleaning
Revision Changes Path
1.129 +2 -2 e/src/Makefile
Index: Makefile
===================================================================
RCS file: /cvs/e/src/Makefile,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -r1.128 -r1.129
--- Makefile 2001/12/13 20:24:07 1.128
+++ Makefile 2001/12/17 16:49:47 1.129
@@ -7,8 +7,8 @@
# Prefix tagging this release's attributes
PREFIX=E
-DOTVER=0.8.10delta3
-TAGVER=0_8_10delta3
+DOTVER=0.8.10delta4
+TAGVER=0_8_10delta4
RELEASE=working
TOP=..
1.9 +2 -4 e/src/jsrc/net/captp/tables/CommTable.java
Index: CommTable.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/tables/CommTable.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CommTable.java 2001/12/02 06:01:39 1.8
+++ CommTable.java 2001/12/17 16:49:47 1.9
@@ -22,6 +22,7 @@
*/
import org.erights.e.elib.eio.TextWriter;
+import org.erights.e.elib.tables.EList;
import java.io.IOException;
import java.lang.reflect.Array;
@@ -191,10 +192,7 @@
if (len >= capacity) {
return array;
}
- Class elementType = array.getClass().getComponentType();
- Object result = Array.newInstance(elementType, capacity);
- System.arraycopy(array, 0, result, 0, len);
- return result;
+ return EList.resize(array, capacity);
}
/**
1.11 +7 -5 e/src/jsrc/net/captp/tables/SwissTable.java
Index: SwissTable.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/tables/SwissTable.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SwissTable.java 2001/12/16 10:10:29 1.10
+++ SwissTable.java 2001/12/17 16:49:47 1.11
@@ -27,6 +27,7 @@
import org.erights.e.elib.tables.FlexMap;
import org.erights.e.elib.tables.WeakKeyMap;
import org.erights.e.elib.tables.WeakValueMap;
+import org.erights.e.elib.tables.FlexSet;
import org.erights.e.elib.util.OneArgFunc;
import org.erights.e.meta.java.math.BigIntegerSugar;
@@ -77,7 +78,7 @@
/**
* OneArgFuncs that handle lookup faulting.
*/
- private FlexMap mySwissDBs;
+ private FlexSet mySwissDBs;
/**
*
@@ -86,7 +87,7 @@
mySelfishToSwiss = new WeakKeyMap(Object.class, BigInteger.class);
mySwissToRef = new WeakValueMap(BigInteger.class, Object.class);
myEntropy = entropy;
- mySwissDBs = FlexMap.fromTypes(OneArgFunc.class, Void.class);
+ mySwissDBs = FlexSet.fromType(OneArgFunc.class);
}
/**
@@ -109,7 +110,8 @@
//Since we handle null ourselves, we know that a null optResult means
//a lookup miss.
BigInteger swissHash = BigIntegerSugar.cryptoHash(swissNum);
- OneArgFunc[] dbs = (OneArgFunc[])mySwissDBs.getKeys(OneArgFunc.class);
+ OneArgFunc[] dbs =
+ (OneArgFunc[])mySwissDBs.getElements(OneArgFunc.class);
for (int i = 0; i < dbs.length; i++) {
//give each fault handler a chance
dbs[i].run(swissHash);
@@ -139,7 +141,7 @@
* thrown.
*/
public void addFaultHandler(OneArgFunc swissDB) {
- mySwissDBs.put(swissDB, null, true);
+ mySwissDBs.addElement(swissDB, true);
}
/**
@@ -148,7 +150,7 @@
* If not there, this method does nothing.
*/
public void removeFaultHandler(OneArgFunc swissDB) {
- mySwissDBs.removeKey(swissDB);
+ mySwissDBs.remove(swissDB);
}
/**
1.34 +5 -3 e/src/jsrc/org/erights/e/elib/base/ClassDesc.java
Index: ClassDesc.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/base/ClassDesc.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- ClassDesc.java 2001/12/16 10:10:29 1.33
+++ ClassDesc.java 2001/12/17 16:49:47 1.34
@@ -30,6 +30,7 @@
import org.erights.e.elib.tables.EList;
import org.erights.e.elib.tables.FlexList;
import org.erights.e.elib.tables.FlexMap;
+import org.erights.e.elib.tables.FlexSet;
import org.erights.e.elib.util.ClassCache;
import org.erights.e.elib.util.OneArgFunc;
import org.erights.e.elib.slot.BothGuard;
@@ -160,17 +161,18 @@
System.arraycopy(ifaces, 0, supers, 1, ifaces.length);
supers[0] = optSuper;
}
- FlexMap superSugarSet = FlexMap.fromTypes(Class.class, Void.class);
+ FlexSet superSugarSet = FlexSet.fromType(Class.class);
for (int i = 0; i < supers.length; i++) {
Class superSugar = GetGuard(supers[i]);
if (ClassDesc.class != superSugar &&
(InterfaceGuardSugar.class != superSugar ||
clazz.isInterface())) {
//only interfaces inherit InterfaceGuardSugar
- superSugarSet.put(superSugar, null);
+ superSugarSet.addElement(superSugar);
}
}
- Class[] superSugars = (Class[])superSugarSet.getKeys(Class.class);
+ Class[] superSugars =
+ (Class[])superSugarSet.getElements(Class.class);
if (0 == superSugars.length) {
if (clazz.isInterface()) {
result = InterfaceGuardSugar.class;
1.26 +7 -5 e/src/jsrc/org/erights/e/elib/prim/StaticMaker.java
Index: StaticMaker.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/prim/StaticMaker.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- StaticMaker.java 2001/12/16 10:10:29 1.25
+++ StaticMaker.java 2001/12/17 16:49:47 1.26
@@ -34,6 +34,8 @@
import org.erights.e.elib.tables.EMap;
import org.erights.e.elib.tables.FlexList;
import org.erights.e.elib.tables.FlexMap;
+import org.erights.e.elib.tables.FlexSet;
+import org.erights.e.elib.tables.ConstSet;
import org.erights.e.elib.util.AlreadyDefinedException;
import org.erights.e.elib.util.ClassCache;
@@ -109,15 +111,15 @@
"org.capml.quasi.XMLQuasiParser",
};
- static private final ConstMap ApprovedClasses;
+ static private final ConstSet ApprovedClasses;
static {
int len = ApprovedClassList.length;
- FlexMap map = FlexMap.fromTypes(String.class, Void.class, len);
+ FlexSet set = FlexSet.fromType(String.class, len);
for (int i = 0; i < len; i++) {
- map.put(ApprovedClassList[i], null, true);
+ set.addElement(ApprovedClassList[i], true);
}
- ApprovedClasses = map.snapshot();
+ ApprovedClasses = set.snapshot();
}
/**
@@ -131,7 +133,7 @@
//Array types are safe
return true;
}
- return ApprovedClasses.maps(clazz.getName());
+ return ApprovedClasses.contains(clazz.getName());
}
/**
1.20 +1 -1 e/src/jsrc/org/erights/e/elib/tables/Column.java
Index: Column.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/Column.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Column.java 2001/12/16 10:10:29 1.19
+++ Column.java 2001/12/17 16:49:47 1.20
@@ -101,7 +101,7 @@
*/
static public Column values(Class memberType, int capacity) {
- memberType = EList.scalarize(memberType);
+ memberType = EList.typeForArray(memberType);
if (memberType == Void.class) {
return new VoidColumn(capacity);
1.22 +2 -17 e/src/jsrc/org/erights/e/elib/tables/ConstList.java
Index: ConstList.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ConstList.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ConstList.java 2001/12/12 06:35:58 1.21
+++ ConstList.java 2001/12/17 16:49:47 1.22
@@ -113,23 +113,8 @@
/**
*
*/
- static /*package*/ Object arrayClone(Object oldArray) {
-
- //is it really this much trouble just to clone an array?
- Class valType = oldArray.getClass().getComponentType();
- int len = Array.getLength(oldArray);
- //XXX The following is Array.newInstance(..) rather than
- //EList.newArray(..) since arraycopy won't work between, for example,
- //an int[23] and a Integer[23]. Bletch!
- Object result = Array.newInstance(valType, len);
- System.arraycopy(oldArray, 0, result, 0, len);
- return result;
- }
-
- /**
- *
- */
static public ConstList fromArray(Object oldArray) {
- return new ConstListImpl(arrayClone(oldArray));
+ return new ConstListImpl(resize(oldArray,
+ Array.getLength(oldArray)));
}
}
1.11 +9 -9 e/src/jsrc/org/erights/e/elib/tables/ConstSubclassSet.java
Index: ConstSubclassSet.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ConstSubclassSet.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ConstSubclassSet.java 2001/12/02 06:01:47 1.10
+++ ConstSubclassSet.java 2001/12/17 16:49:47 1.11
@@ -32,13 +32,13 @@
*/
public class ConstSubclassSet {
- private FlexMap myInnerMap;
+ private FlexSet myInnerSet;
/**
*
*/
- private ConstSubclassSet(FlexMap initialMap) {
- myInnerMap = initialMap;
+ private ConstSubclassSet(FlexSet initialSet) {
+ myInnerSet = initialSet;
}
/**
@@ -49,10 +49,10 @@
return false;
}
String fqName = clazz.getName();
- if (myInnerMap.maps(fqName)) {
+ if (myInnerSet.contains(fqName)) {
return true;
}
- if (myInnerMap.maps("java.lang.Object")) {
+ if (myInnerSet.contains("java.lang.Object")) {
return true;
}
@@ -69,7 +69,7 @@
}
}
if (result) {
- myInnerMap.put(fqName, null);
+ myInnerSet.addElement(fqName);
}
return result;
}
@@ -78,10 +78,10 @@
*
*/
static public ConstSubclassSet make(String[] fqNames) {
- FlexMap map = FlexMap.fromTypes(String.class, Void.class);
+ FlexSet set = FlexSet.fromType(String.class);
for (int i = 0; i < fqNames.length; i++) {
- map.put(fqNames[i], null);
+ set.addElement(fqNames[i]);
}
- return new ConstSubclassSet(map);
+ return new ConstSubclassSet(set);
}
}
1.6 +7 -0 e/src/jsrc/org/erights/e/elib/tables/CycleBreaker.java
Index: CycleBreaker.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/CycleBreaker.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CycleBreaker.java 2001/12/16 10:10:29 1.5
+++ CycleBreaker.java 2001/12/17 16:49:47 1.6
@@ -9,8 +9,15 @@
*/
public class CycleBreaker {
+ /**
+ * XXX We should have an IdentitySet type, and this should be of that
+ * type.
+ */
private IdentityMap myIdMap;
+ /**
+ * XXX Should be a FlexSet instead.
+ */
private FlexMap myFlexMap;
/**
1.35 +59 -26 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.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- EList.java 2001/12/16 10:10:29 1.34
+++ EList.java 2001/12/17 16:49:47 1.35
@@ -55,7 +55,7 @@
/**
*
*/
- static private final Class[][] ScalarTypes = {
+ static private final Class[][] ArrayTypes = {
{ Boolean.class, Boolean.TYPE },
{ Byte.class, Byte.TYPE },
{ Character.class, Character.TYPE },
@@ -64,7 +64,7 @@
{ Integer.class, Integer.TYPE },
{ Long.class, Long.TYPE },
{ Short.class, Short.TYPE },
- { Void.class, Void.TYPE },
+ { Void.TYPE, Void.class }, //notice reversal
};
/**
@@ -72,10 +72,10 @@
* circular init-time dependency, since our tables depend on mapping
* scalar types.
*/
- static private Hashtable initScalarMap(int from, int to) {
- Hashtable result = new Hashtable(ScalarTypes.length * 2);
- for (int i = 0; i < ScalarTypes.length; i++) {
- result.put(ScalarTypes[i][from], ScalarTypes[i][to]);
+ static private Hashtable initArrayTypeMap(int from, int to) {
+ Hashtable result = new Hashtable(ArrayTypes.length * 2);
+ for (int i = 0; i < ArrayTypes.length; i++) {
+ result.put(ArrayTypes[i][from], ArrayTypes[i][to]);
}
return result;
}
@@ -83,35 +83,62 @@
/**
*
*/
- static private Hashtable ScalarTypeMap = initScalarMap(0, 1);
+ static private Hashtable ArrayTypeMap = initArrayTypeMap(0, 1);
/**
- *
- */
- static private Hashtable ScalarClassMap = initScalarMap(1, 0);
-
- /**
- *
+ * Given a class, return a preferred class for making an array of
+ * (abstractly) the kinds of values described by the argument class.
+ * <p>
+ * It maps {@link Void}.TYPE to Void.class.<br>
+ * It maps boxed scalar types, like {@link Integer}.class, to the
+ * corresponding primitive (unboxed) scalar type, like Integer.TYPE.
+ * Otherwise, it just returns its argument.
+ * <p>
+ * XXX where should this method go?
*/
- static public Class scalarize(Class type) {
- Class result = (Class)ScalarTypeMap.get(type);
+ static public Class typeForArray(Class elType) {
+ Class result = (Class)ArrayTypeMap.get(elType);
if (null != result) {
return result;
} else {
- return type;
+ return elType;
}
}
/**
- *
+ * Like {@link Array#newInstance(Class, int)}, but the type is first
+ * converted according to {@link #typeForArray(Class)}.
+ * <p>
+ * XXX where should this method go?
*/
static public Object newArray(Class elType, int size) {
- elType = scalarize(elType);
- if (elType == Void.TYPE) {
- //god, what a kludge
- elType = Void.class;
- }
- return Array.newInstance(elType, size);
+ return Array.newInstance(typeForArray(elType), size);
+ }
+
+ /**
+ * Returns a copy of oldArray but of length newLen.
+ * <p>
+ * If newLen is larger than the original length, then the extra slots are
+ * filled with the zero element for this type. This is null for any Java
+ * reference type (and non-primitive class), and 0, '\0', 0.0, or false,
+ * as appropriate, for corresponding scalar types.
+ * <p>
+ * If newLen is smaller than the original, the extra elements are dropped.
+ * <p>
+ * XXX where should this method go?
+ */
+ static public Object resize(Object oldArray, int newLen) {
+
+ //is it really this much trouble just to clone an array?
+ Class valType = oldArray.getClass().getComponentType();
+ int oldLen = Array.getLength(oldArray);
+ //The following is Array.newInstance(..) rather than
+ //EList.newArray(..) since arraycopy won't work between, for example,
+ //an int[23] and a Integer[23]. Bletch!
+ Object result = Array.newInstance(valType, newLen);
+ System.arraycopy(oldArray, 0, result, 0,
+ Math.min(oldLen, newLen));
+ return result;
}
/**
@@ -137,10 +164,12 @@
/**
* Returns a FlexList whose initial state is a snapshot of the
* state of this list at the time of the diverge() request.
+ * <p>
* Further changes to the original and/or the new list are
- * independent -- they diverge. <p>
- *
- * The new list is constrained to only hold values of 'valueType'
+ * independent -- they diverge.
+ * <p>
+ * The new list is constrained to only hold values of 'valueType'.
+ * XXX valueType should be of type ValueGuard rather than Class.
*/
public FlexList diverge(Class valueType) {
FlexList result = FlexList.fromType(valueType, size());
@@ -196,6 +225,8 @@
/**
* Returns a divergent array of type.
+ * <p>
+ * XXX Should 'type' be of type ValueGuard rather than Class?
*/
public Object getArray(Class type) {
int len = size();
@@ -245,6 +276,8 @@
/**
* All values in this table must be of this type
+ * <p>
+ * XXX Should this return a ValueGuard rather than a Class?
*/
public abstract Class valueType();
1.34 +18 -4 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.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- EMap.java 2001/12/12 06:35:58 1.33
+++ EMap.java 2001/12/17 16:49:47 1.34
@@ -95,11 +95,15 @@
/**
* Returns a FlexMap whose initial state is a snapshot of the state of
- * this map at the time of the diverge() request. Further changes to
- * the original and/or the new map are independent -- they diverge. <p>
- *
+ * this map at the time of the diverge() request.
+ * <p>
+ * Further changes to the original and/or the new map are independent --
+ * they diverge.
+ * <p>
* The new map is constrained to only hold associations from 'keyType' to
* 'valueType'.
+ * XXX keyType and valueType should be declared as ValueGuards rather
+ * than Classes.
*/
public FlexMap diverge(Class keyType, Class valueType) {
FlexMap result = FlexMap.fromTypes(keyType, valueType, size());
@@ -281,6 +285,8 @@
/**
* Returns a divergent array-of-type of all the keys in order.
+ * <p>
+ * XXX Should 'type' be a ValueGuard rather than a Class?
*/
public abstract Object getKeys(Class type);
@@ -298,6 +304,8 @@
/**
* Returns a divergent array-of-type of all the values in order.
+ * <p>
+ * XXX Should 'type' be a ValueGuard rather than a Class?
*/
public abstract Object getValues(Class type);
@@ -320,6 +328,8 @@
* are guaranteed to correspond. The default implementation here does
* just call getKeys(keyType), and then calls getValues(valueType), as
* that is fine for everything but the WeakValuesMap.
+ * <p>
+ * XXX Should keyType and valueType be ValueGuards rather than Classes?
*/
public Object[] getPair(Class keyType, Class valueType) {
Object keys = getKeys(keyType);
@@ -452,12 +462,16 @@
}
/**
- * All keys in this map must be of this type
+ * All keys in this map must be of this type.
+ * <p>
+ * XXX Should this return a ValueGuard rather than a Class?
*/
public abstract Class keyType();
/**
* All values in this map must be of this type
+ * <p>
+ * XXX Should this return a ValueGuard rather than a Class?
*/
public abstract Class valueType();
}
1.5 +12 -5 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ESet.java 2001/12/16 10:10:29 1.4
+++ ESet.java 2001/12/17 16:49:47 1.5
@@ -37,7 +37,7 @@
public abstract class ESet implements EPrintable, Persistent, Iteratable {
/**
- *
+ * XXX Should build an ESet directly from a KeyColumn rather than an EMap.
*/
/*package*/
EMap myMap;
@@ -69,10 +69,13 @@
/**
* Returns a FlexSet whose initial state is a snapshot of the state of
- * this set at the time of the diverge() request. Further changes to
- * the original and/or the new set are independent -- they diverge. <p>
- *
+ * this set at the time of the diverge() request.
+ * <p>
+ * Further changes to the original and/or the new set are independent --
+ * they diverge.
+ * <p>
* The new set is constrained to only hold object of type 'type'.
+ * XXX 'type' should be declared as a ValueGuard rather than Class.
*/
public FlexSet diverge(Class type) {
return FlexSet.make(myMap.diverge(type, Void.class));
@@ -164,6 +167,8 @@
/**
* Returns a divergent array-of-type of all the values in order.
+ * <p>
+ * XXX Should elementType be a ValueGuard rather than a Class?
*/
public Object getElements(Class elementType) {
return myMap.getKeys(elementType);
@@ -225,7 +230,9 @@
}
/**
- * All elements of this set must be of this type
+ * All elements of this set must be of this type.
+ * <p>
+ * XXX This should return a ValueGuard rather than a Class
*/
public Class elementType() {
return myMap.keyType();
1.32 +1 -1 e/src/jsrc/org/erights/e/elib/tables/Equalizer.java
Index: Equalizer.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/Equalizer.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- Equalizer.java 2001/12/16 10:10:29 1.31
+++ Equalizer.java 2001/12/17 16:49:47 1.32
@@ -341,7 +341,7 @@
if (sofar >= myMaxSofar) {
myMaxSofar = sofar + 1;
int len = myLefts.length;
- if (sofar <= len) {
+ if (sofar >= len) {
int newLen = (len * 2) + 32;
Object[] newLefts = new Object[newLen];
System.arraycopy(myLefts, 0, newLefts, 0, len);
1.11 +4 -1 e/src/jsrc/org/erights/e/meta/java/lang/ArrayGuardSugar.java
Index: ArrayGuardSugar.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/meta/java/lang/ArrayGuardSugar.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ArrayGuardSugar.java 2001/12/12 06:35:58 1.10
+++ ArrayGuardSugar.java 2001/12/17 16:49:47 1.11
@@ -61,13 +61,16 @@
for (int i = 0; i < len; i++) {
Object el = Array.get(specimen, i);
//XXX what about array of void?
- Array.set(result, i, E.as(el, elType));
+ Array.set(result, i, E.as(el, elType, optEjector));
}
return result;
}
if (specimen instanceof ConstList) {
return ((ConstList)specimen).getArray(elType);
+ }
+ if (specimen instanceof String) {
+ return subCoerce(((String)specimen).toCharArray(), optEjector);
}
return super.subCoerce(specimen, optEjector);
}
1.26 +8 -7 e/src/jsrc/org/erights/e/ui/jed/EditGroup.java
Index: EditGroup.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/ui/jed/EditGroup.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- EditGroup.java 2001/12/16 10:10:30 1.25
+++ EditGroup.java 2001/12/17 16:49:47 1.26
@@ -20,6 +20,7 @@
*/
import org.erights.e.elib.tables.FlexMap;
+import org.erights.e.elib.tables.FlexSet;
import org.erights.e.meta.java.io.FileGetter;
import org.erights.e.meta.java.io.FileSugar;
@@ -38,7 +39,7 @@
static private boolean WasInitCalled = false;
- private FlexMap myJeds = FlexMap.fromTypes(JedMain.class, Void.class);
+ private FlexSet myJeds = FlexSet.fromType(JedMain.class);
private String myOptPattern = null;
@@ -70,7 +71,7 @@
*
*/
public boolean anyDirty() {
- JedMain[] jeds = (JedMain[])myJeds.getKeys(JedMain.class);
+ JedMain[] jeds = (JedMain[])myJeds.getElements(JedMain.class);
for (int i = 0; i < jeds.length; i++) {
if (jeds[i].isDirty()) {
return true;
@@ -84,7 +85,7 @@
*/
public boolean closeAll() {
boolean result = true;
- JedMain[] jeds = (JedMain[])myJeds.getKeys(JedMain.class);
+ JedMain[] jeds = (JedMain[])myJeds.getElements(JedMain.class);
for (int i = 0; i < jeds.length; i++) {
if (!jeds[i].menuClose(true)) {
result = false;
@@ -152,7 +153,7 @@
*/
public JedMain optToFront(File file) {
String path = FileSugar.getPath(file);
- JedMain[] jeds = (JedMain[])myJeds.getKeys(JedMain.class);
+ JedMain[] jeds = (JedMain[])myJeds.getElements(JedMain.class);
for (int i = 0; i < jeds.length; i++) {
JedMain jed = jeds[i];
File optFile = jed.optFile();
@@ -170,7 +171,7 @@
*/
/*package*/
void register(JedMain jed) {
- myJeds.put(jed, null, true);
+ myJeds.addElement(jed, true);
}
/**
@@ -178,7 +179,7 @@
*/
public boolean saveAll() {
boolean result = true;
- JedMain[] jeds = (JedMain[])myJeds.getKeys(JedMain.class);
+ JedMain[] jeds = (JedMain[])myJeds.getElements(JedMain.class);
for (int i = 0; i < jeds.length; i++) {
if (!jeds[i].menuSave()) {
result = false;
@@ -192,7 +193,7 @@
*/
/*package*/
void unregister(JedMain jed) {
- myJeds.removeKey(jed, true);
+ myJeds.remove(jed, true);
if (myJeds.size() <= 0 && myExitOnClose) {
try {
System.exit(0);
1.2 +2 -4 e/src/jsrc/org/quasiliteral/syntax/Indenter.java
Index: Indenter.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/quasiliteral/syntax/Indenter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Indenter.java 2001/12/02 18:42:02 1.1
+++ Indenter.java 2001/12/17 16:49:47 1.2
@@ -22,6 +22,7 @@
*/
import org.erights.e.elib.tables.Twine;
+import org.erights.e.elib.tables.EList;
import java.lang.reflect.Array;
@@ -101,11 +102,8 @@
*
*/
private Object grow(Object array) {
- Class memType = array.getClass().getComponentType();
int length = Array.getLength(array);
- Object result = Array.newInstance(memType, length * 2);
- System.arraycopy(array, 0, result, 0, length);
- return result;
+ return EList.resize(array, length * 2);
}
/**
1.17 +11 -4 e/src/jsrc/org/quasiliteral/term/TermBuilder.java
Index: TermBuilder.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/quasiliteral/term/TermBuilder.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- TermBuilder.java 2001/12/12 06:36:00 1.16
+++ TermBuilder.java 2001/12/17 16:49:47 1.17
@@ -4,6 +4,7 @@
import org.erights.e.elib.tables.ConstList;
import org.erights.e.elib.tables.FlexList;
import org.erights.e.elib.tables.Twine;
+import org.erights.e.elib.tables.EList;
import org.quasiliteral.astro.ASTBuilder;
import org.quasiliteral.astro.Astro;
import org.quasiliteral.astro.AstroArg;
@@ -73,7 +74,7 @@
/**
* @param func :Term with no arguments
- * @param args :(FlexList of(Term))
+ * @param args :(EList of(Term))
* @return :Term
*/
public Astro term(Astro leaf, Object args) {
@@ -81,7 +82,7 @@
E.require(func.getArgs().size() == 0,
"To use as a functor, a Term must not have args: ",
func);
- FlexList argList = (FlexList)E.as(args, FlexList.class);
+ EList argList = (EList)E.as(args, EList.class);
return new Term(func.getTag(),
func.getOptData(),
func.getSource(),
@@ -104,12 +105,18 @@
* <p>
* In fact, this simply pushes 'next' onto 'list' and returns 'list'
*
- * @param list :(FlexList of(Term))
+ * @param list :(EList of(Term))
* @param next :Term
* @return :(FlexList of(Term))
*/
public Object with(Object list, AstroArg next) {
- FlexList argList = (FlexList)E.as(list, FlexList.class);
+ EList argEList = (EList)E.as(list, EList.class);
+ FlexList argList;
+ if (argEList instanceof FlexList) {
+ argList = (FlexList)argEList;
+ } else {
+ argList = argEList.diverge(Term.class);
+ }
argList.push(next);
return argList;
}