cons = c.getConstructor(FoamContext.class);
+ FoamClass fc = cons.newInstance(FoamContext.this);
+ fc.run();
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ return null;
+ }
+ };
+ Clos clos = new Clos(null, loader);
+ loadFns.put(name, clos);
+ return clos;
+ }
}
diff --git a/aldor/aldor/lib/java/src/foamj/FoamException.java b/aldor/aldor/lib/java/src/foamj/FoamException.java
index ed354caa8..d5f8e2cd2 100644
--- a/aldor/aldor/lib/java/src/foamj/FoamException.java
+++ b/aldor/aldor/lib/java/src/foamj/FoamException.java
@@ -2,13 +2,13 @@
@SuppressWarnings("serial")
public class FoamException extends RuntimeException {
- private int status;
-
- public FoamException(int status) {
- this.status = status;
- }
+ private int status;
- public int getStatus() {
- return status;
- }
+ public FoamException(int status) {
+ this.status = status;
+ }
+
+ public int getStatus() {
+ return status;
+ }
}
diff --git a/aldor/aldor/lib/java/src/foamj/FoamJ.java b/aldor/aldor/lib/java/src/foamj/FoamJ.java
index a3412fe8b..a6a9bfcdc 100644
--- a/aldor/aldor/lib/java/src/foamj/FoamJ.java
+++ b/aldor/aldor/lib/java/src/foamj/FoamJ.java
@@ -4,212 +4,255 @@
public class FoamJ {
- /**
- * Array type - rely on casting to retract to base type
- * @author pab
- *
- */
- static class Array extends AbstractValue implements Value, Word {
- private Object arr;
- Array(Object arr) {
- this.arr = arr;
- }
-
- public Object toArray() {
- return arr;
- }
-
- @Override
- public Value toValue() { return this; }
- public Word asWord() {
- return this;
- }
-
- public String toString() {
- return "A"+arr.toString() + "]";
- }
-
- }
-
- /**
- * a.
- * T1 = (Add (Cast SInt x) 1)
- * -->
- * t1 = x.toInteger() + 1;
- * ..
- * T2 = (Cast Word (Add (Cast SInt x) 1))
- * -->
- * t1 = Word.U.fromSInt(x.toSInt() + 1);
- */
- static public class SInt extends AbstractValue implements Value, Word {
- private int value;
-
- public SInt(int x) {
- this.value = x;
- }
-
- public int toSInt() { return value; }
-
- @Override
- public Value toValue() {
- return this;
- }
-
- public Word asWord() {
- return this;
- }
- public String toString() { return ""+value; }
- }
-
- static public class HInt extends AbstractValue implements Value, Word {
- private short value;
-
- public HInt(short x) {
- this.value = x;
- }
-
- public short toHInt() { return value; }
-
- @Override
- public Value toValue() {
- return this;
- }
-
- public Word asWord() {
- return this;
- }
- public String toString() { return ""+value; }
- }
-
- static public class SFlo extends AbstractValue implements Value, Word {
- private float value;
-
- public SFlo(float x) {
- this.value = x;
- }
-
- public float toSFlo() { return value; }
-
- @Override
- public Value toValue() {
- return this;
- }
-
- public Word asWord() {
- return this;
- }
- public String toString() { return ""+value; }
- }
-
- static public class DFlo extends AbstractValue implements Value, Word {
- private double value;
-
- public DFlo(double x) {
- this.value = x;
- }
-
- public double toDFlo() { return value; }
-
- @Override
- public Value toValue() {
- return this;
- }
-
- public Word asWord() {
- return this;
- }
- public String toString() { return ""+value; }
- }
-
- static public class BInt extends AbstractValue implements Value, Word {
- private BigInteger value;
-
- public BInt(BigInteger x) {
- this.value = x;
- }
-
- public BigInteger toBInt() { return value; }
-
- public Word asWord() {return this;}
- @Override
- public Value toValue() {
- return this;
- }
- }
-
- static public class Bool extends AbstractValue implements Value, Word {
- private boolean value;
-
- public Bool(boolean b) {
- this.value = b;
- }
-
- public boolean toBool() { return value; }
-
- @Override
- public Value toValue() {
- return this;
- }
- public Word asWord() {
- return this;
- }
-
- public String toString() { return ""+value; }
- }
-
- static public class Char extends AbstractValue implements Value, Word {
- private char value;
-
- public Char(char b) {
- this.value = b;
- }
-
- public char toChar() { return value; }
-
- @Override
- public Value toValue() {
- return this;
- }
- public Word asWord() {
- return this;
- }
- }
-
-
- static public class Ptr extends AbstractValue implements Value, Word {
- private Object value;
-
- public Ptr(Object b) {
- this.value = b;
- }
-
- public Object toPtr() { return value; }
-
- @Override
- public Value toValue() {
- return this;
- }
- public Word asWord() {
- return this;
- }
- }
-
- static public class Byte extends AbstractValue implements Value, Word {
- private byte value;
-
- public Byte(byte b) {
- this.value = b;
- }
-
- public byte toByte() { return value; }
-
- @Override
- public Value toValue() {
- return this;
- }
- public Word asWord() {
- return this;
- }
- }
+ /**
+ * Array type - rely on casting to retract to base type
+ *
+ * @author pab
+ */
+ static class Array extends AbstractValue implements Value, Word {
+ private Object arr;
+
+ Array(Object arr) {
+ this.arr = arr;
+ }
+
+ public Object toArray() {
+ return arr;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ public String toString() {
+ return "A" + arr.toString() + "]";
+ }
+
+ }
+
+ /**
+ * a.
+ * T1 = (Add (Cast SInt x) 1)
+ * -->
+ * t1 = x.toInteger() + 1;
+ * ..
+ * T2 = (Cast Word (Add (Cast SInt x) 1))
+ * -->
+ * t1 = Word.U.fromSInt(x.toSInt() + 1);
+ */
+ static public class SInt extends AbstractValue implements Value, Word {
+ private int value;
+
+ public SInt(int x) {
+ this.value = x;
+ }
+
+ public int toSInt() {
+ return value;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+ }
+
+ static public class HInt extends AbstractValue implements Value, Word {
+ private short value;
+
+ public HInt(short x) {
+ this.value = x;
+ }
+
+ public short toHInt() {
+ return value;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+ }
+
+ static public class SFlo extends AbstractValue implements Value, Word {
+ private float value;
+
+ public SFlo(float x) {
+ this.value = x;
+ }
+
+ public float toSFlo() {
+ return value;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+ }
+
+ static public class DFlo extends AbstractValue implements Value, Word {
+ private double value;
+
+ public DFlo(double x) {
+ this.value = x;
+ }
+
+ public double toDFlo() {
+ return value;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+ }
+
+ static public class BInt extends AbstractValue implements Value, Word {
+ private BigInteger value;
+
+ public BInt(BigInteger x) {
+ this.value = x;
+ }
+
+ public BigInteger toBInt() {
+ return value;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+ }
+
+ static public class Bool extends AbstractValue implements Value, Word {
+ private boolean value;
+
+ public Bool(boolean b) {
+ this.value = b;
+ }
+
+ public boolean toBool() {
+ return value;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+ }
+
+ static public class Char extends AbstractValue implements Value, Word {
+ private char value;
+
+ public Char(char b) {
+ this.value = b;
+ }
+
+ public char toChar() {
+ return value;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+ }
+
+
+ static public class Ptr extends AbstractValue implements Value, Word {
+ private Object value;
+
+ public Ptr(Object b) {
+ this.value = b;
+ }
+
+ public Object toPtr() {
+ return value;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+ }
+
+ static public class Byte extends AbstractValue implements Value, Word {
+ private byte value;
+
+ public Byte(byte b) {
+ this.value = b;
+ }
+
+ public byte toByte() {
+ return value;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+ }
}
diff --git a/aldor/aldor/lib/java/src/foamj/Format.java b/aldor/aldor/lib/java/src/foamj/Format.java
index e77a9f85b..8387d292c 100644
--- a/aldor/aldor/lib/java/src/foamj/Format.java
+++ b/aldor/aldor/lib/java/src/foamj/Format.java
@@ -2,16 +2,20 @@
/**
* Represents a Foam DDecl.
- *
+ *
* Should really have some type information, but
* at the moment is just a size.
- * @author pab
*
+ * @author pab
*/
public class Format {
- private int size;
- public Format(int sz) {
- this.size = sz;
- }
- int size() { return size; }
+ private int size;
+
+ public Format(int sz) {
+ this.size = sz;
+ }
+
+ int size() {
+ return size;
+ }
}
\ No newline at end of file
diff --git a/aldor/aldor/lib/java/src/foamj/Globals.java b/aldor/aldor/lib/java/src/foamj/Globals.java
index db03ea15f..87c63f400 100644
--- a/aldor/aldor/lib/java/src/foamj/Globals.java
+++ b/aldor/aldor/lib/java/src/foamj/Globals.java
@@ -5,17 +5,17 @@
public class Globals {
- /*
- * :: Globals
- */
- static private final Map globals = new ConcurrentHashMap();
-
- static public Value getGlobal(String s) {
- return globals.get(s);
- }
+ /*
+ * :: Globals
+ */
+ static private final Map globals = new ConcurrentHashMap();
- static public void setGlobal(String s, Value v) {
- globals.put(s, v);
- }
+ static public Value getGlobal(String s) {
+ return globals.get(s);
+ }
+
+ static public void setGlobal(String s, Value v) {
+ globals.put(s, v);
+ }
}
diff --git a/aldor/aldor/lib/java/src/foamj/HaltException.java b/aldor/aldor/lib/java/src/foamj/HaltException.java
index 45fbd3f98..874c21c3c 100644
--- a/aldor/aldor/lib/java/src/foamj/HaltException.java
+++ b/aldor/aldor/lib/java/src/foamj/HaltException.java
@@ -3,8 +3,8 @@
@SuppressWarnings("serial")
public class HaltException extends FoamException {
- public HaltException(int status) {
- super(status);
- }
+ public HaltException(int status) {
+ super(status);
+ }
}
diff --git a/aldor/aldor/lib/java/src/foamj/Math.java b/aldor/aldor/lib/java/src/foamj/Math.java
index c609e54d9..a924d0c64 100644
--- a/aldor/aldor/lib/java/src/foamj/Math.java
+++ b/aldor/aldor/lib/java/src/foamj/Math.java
@@ -12,306 +12,331 @@ public class Math {
public static final int ROUND_DOWN = 3;
public static final int ROUND_DONTCARE = 4;
- public static boolean bit(int n, int idx) {
- return (n & (1<> 32);
- return tmp & 0x3FFFFFFF;
-
- }
-
- public static boolean isZero(BigInteger b) {
- return b.compareTo(BigInteger.ZERO) == 0;
- }
- public static boolean isNeg(BigInteger b) {
- return b.compareTo(BigInteger.ZERO) < 0;
- }
- public static boolean isPos(BigInteger b) {
- return b.compareTo(BigInteger.ZERO) > 0;
- }
- public static boolean isEven(BigInteger b) {
- return !b.testBit(0);
- }
- public static boolean isOdd(BigInteger b) {
- return b.testBit(0);
- }
-
- public static boolean isSingle(BigInteger b) {
- return b.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) <= 0
- && b.compareTo(BigInteger.valueOf(Integer.MIN_VALUE)) >= 0;
- }
-
- public static boolean eq(BigInteger b1, BigInteger b2) {
- return b1.compareTo(b2) == 0;
- }
-
- public static boolean ne(BigInteger b1, BigInteger b2) {
- return b1.compareTo(b2) != 0;
- }
-
- public static boolean lt(BigInteger b1, BigInteger b2) {
- return b1.compareTo(b2) < 0;
- }
- public static boolean le(BigInteger b1, BigInteger b2) {
- return b1.compareTo(b2) <= 0;
- }
-
- public static BigInteger prev(BigInteger b) {
- return b.subtract(BigInteger.ONE);
- }
- public static BigInteger next(BigInteger b) {
- return b.add(BigInteger.ONE);
- }
- public static BigInteger plus(BigInteger b1, BigInteger b2) {
- return b1.add(b2);
- }
- public static BigInteger minus(BigInteger b1, BigInteger b2) {
- return b1.subtract(b2);
- }
- public static BigInteger times(BigInteger b1, BigInteger b2) {
- return b1.multiply(b2);
- }
- public static BigInteger timesPlus(BigInteger b1, BigInteger b2, BigInteger b3) {
- return b1.multiply(b2).add(b3);
- }
- public static BigInteger mod(BigInteger b1, BigInteger b2) {
- return b1.mod(b2);
- }
- public static BigInteger quo(BigInteger b1, BigInteger b2) {
- return b1.divide(b2);
- }
- public static BigInteger rem(BigInteger b1, BigInteger b2) {
- return b1.remainder(b2);
- }
- public static MultiRecord divide(BigInteger b1, BigInteger b2) {
- BigInteger[] qr = b1.divideAndRemainder(b2);
- MultiRecord result = new MultiRecord(divideFormat);
- result.setField(0, "quo", Value.U.fromBInt(qr[0]));
- result.setField(1, "rem", Value.U.fromBInt(qr[1]));
- return result;
- }
-
-
- public static int formatSInt(int v, Object dest, int c) {
- String s = "" + v;
- char[] arr = (char[]) dest;
- for (int i=0; i> 32);
+ return tmp & 0x3FFFFFFF;
+
+ }
+
+ public static boolean isZero(BigInteger b) {
+ return b.compareTo(BigInteger.ZERO) == 0;
+ }
+
+ public static boolean isNeg(BigInteger b) {
+ return b.compareTo(BigInteger.ZERO) < 0;
+ }
+
+ public static boolean isPos(BigInteger b) {
+ return b.compareTo(BigInteger.ZERO) > 0;
+ }
+
+ public static boolean isEven(BigInteger b) {
+ return !b.testBit(0);
+ }
+
+ public static boolean isOdd(BigInteger b) {
+ return b.testBit(0);
+ }
+
+ public static boolean isSingle(BigInteger b) {
+ return b.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) <= 0
+ && b.compareTo(BigInteger.valueOf(Integer.MIN_VALUE)) >= 0;
+ }
+
+ public static boolean eq(BigInteger b1, BigInteger b2) {
+ return b1.compareTo(b2) == 0;
+ }
+
+ public static boolean ne(BigInteger b1, BigInteger b2) {
+ return b1.compareTo(b2) != 0;
+ }
+
+ public static boolean lt(BigInteger b1, BigInteger b2) {
+ return b1.compareTo(b2) < 0;
+ }
+
+ public static boolean le(BigInteger b1, BigInteger b2) {
+ return b1.compareTo(b2) <= 0;
+ }
+
+ public static BigInteger prev(BigInteger b) {
+ return b.subtract(BigInteger.ONE);
+ }
+
+ public static BigInteger next(BigInteger b) {
+ return b.add(BigInteger.ONE);
+ }
+
+ public static BigInteger plus(BigInteger b1, BigInteger b2) {
+ return b1.add(b2);
+ }
+
+ public static BigInteger minus(BigInteger b1, BigInteger b2) {
+ return b1.subtract(b2);
+ }
+
+ public static BigInteger times(BigInteger b1, BigInteger b2) {
+ return b1.multiply(b2);
+ }
+
+ public static BigInteger timesPlus(BigInteger b1, BigInteger b2, BigInteger b3) {
+ return b1.multiply(b2).add(b3);
+ }
+
+ public static BigInteger mod(BigInteger b1, BigInteger b2) {
+ return b1.mod(b2);
+ }
+
+ public static BigInteger quo(BigInteger b1, BigInteger b2) {
+ return b1.divide(b2);
+ }
+
+ public static BigInteger rem(BigInteger b1, BigInteger b2) {
+ return b1.remainder(b2);
+ }
+
+ public static MultiRecord divide(BigInteger b1, BigInteger b2) {
+ BigInteger[] qr = b1.divideAndRemainder(b2);
+ MultiRecord result = new MultiRecord(divideFormat);
+ result.setField(0, "quo", Value.U.fromBInt(qr[0]));
+ result.setField(1, "rem", Value.U.fromBInt(qr[1]));
+ return result;
+ }
+
+
+ public static int formatSInt(int v, Object dest, int c) {
+ String s = "" + v;
+ char[] arr = (char[]) dest;
+ for (int i = 0; i < c; i++) {
+ arr[c + i] = s.charAt(i);
+ }
+ return c + s.length();
+ }
+
+ public static BigInteger sIPower(BigInteger b1, int b2) {
+ throw new RuntimeException();
+ }
+
+ public static BigInteger bIPower(BigInteger b1, BigInteger b2) {
+ throw new RuntimeException();
+ }
+
public static BigInteger powerMod(BigInteger b1, BigInteger b2, BigInteger b3) {
- throw new RuntimeException();
- }
+ throw new RuntimeException();
+ }
- public static BigInteger shiftUp(BigInteger b1, int n) {
- return b1.shiftLeft(n);
- }
+ public static BigInteger shiftUp(BigInteger b1, int n) {
+ return b1.shiftLeft(n);
+ }
- public static BigInteger shiftDn(BigInteger b1, int n) {
- return b1.shiftRight(n);
- }
+ public static BigInteger shiftDn(BigInteger b1, int n) {
+ return b1.shiftRight(n);
+ }
- public static BigInteger shiftRem(BigInteger b1, int n) {
- BigInteger allOnes = BigInteger.ONE.shiftLeft(n).subtract(BigInteger.ONE);
+ public static BigInteger shiftRem(BigInteger b1, int n) {
+ BigInteger allOnes = BigInteger.ONE.shiftLeft(n).subtract(BigInteger.ONE);
- return b1.and(allOnes);
- }
+ return b1.and(allOnes);
+ }
public static int timesModInv(int a, int b, int c, double d) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static MultiRecord wordTimesDouble(Word w1, Word w2) {
- int i1 = w1.toSInt();
- int i2 = w2.toSInt();
- long lprod = (long) i1 * (long) i2;
- MultiRecord pair = new MultiRecord(wordTimesFormat);
- pair.setField(0, "hi", Value.U.fromSInt((int) (lprod >> 32)));
- pair.setField(1, "lo", Value.U.fromSInt((int) (lprod & ((1L<<32)-1))));
+ int i1 = w1.toSInt();
+ int i2 = w2.toSInt();
+ long lprod = (long) i1 * (long) i2;
+ MultiRecord pair = new MultiRecord(wordTimesFormat);
+ pair.setField(0, "hi", Value.U.fromSInt((int) (lprod >> 32)));
+ pair.setField(1, "lo", Value.U.fromSInt((int) (lprod & ((1L << 32) - 1))));
- return pair;
+ return pair;
}
public static MultiRecord wordDivideDouble(Word w1, Word w2, Word w3) {
- long h = (long) w1.toSInt();
- long l = (long) w2.toSInt();
- long d = (long) w3.toSInt();
- long full = (h << 32) + l;
- long lquo = full/d;
- long rem = full % d;
- MultiRecord result = new MultiRecord(wordDivideFormat);
- result.setField(0, "hi", Value.U.fromSInt((int) (lquo >> 32)));
- result.setField(1, "lo", Value.U.fromSInt((int) (lquo & ((1L<<32)-1))));
- result.setField(2, "rem", Value.U.fromSInt((int) rem));
+ long h = (long) w1.toSInt();
+ long l = (long) w2.toSInt();
+ long d = (long) w3.toSInt();
+ long full = (h << 32) + l;
+ long lquo = full / d;
+ long rem = full % d;
+ MultiRecord result = new MultiRecord(wordDivideFormat);
+ result.setField(0, "hi", Value.U.fromSInt((int) (lquo >> 32)));
+ result.setField(1, "lo", Value.U.fromSInt((int) (lquo & ((1L << 32) - 1))));
+ result.setField(2, "rem", Value.U.fromSInt((int) rem));
- return result;
+ return result;
}
public static MultiRecord wordPlusStep(Word w1, Word w2, Word w3) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static MultiRecord wordTimesStep(Word w1, Word w2, Word w3, Word w4) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float sfloAssemble(boolean sign, int i, Word w) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static MultiRecord sfloDissemble(float f) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float sfloNext(float f) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float sfloPrev(float f) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float sfloRTimes(float a, float b, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float sfloRMinus(float a, float b, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float sfloRPlus(float a, float b, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float sfloRDivide(float a, float b, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float sfloRTimesPlus(float a, float b, float c, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static BigInteger sfloTruncate(float a) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static float sfloFraction(float a) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static BigInteger sfloRound(float a, int b) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
-
public static double dfloAssemble(boolean sign, int i, Word w1, Word w2) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static MultiRecord dfloDissemble(double f) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static float dfloNext(double f) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static float dfloPrev(double f) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static double dfloRTimes(double a, double b, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static double dfloRMinus(double a, double b, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static double dfloRPlus(double a, double b, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static double dfloRDivide(double a, double b, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static double dfloRTimesPlus(double a, double b, double c, int r) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static BigInteger dfloTruncate(double a) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static double dfloFraction(double a) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static BigInteger dfloRound(double a, int b) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static int formatBInt(BigInteger i, Object o, int n) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static int formatSFlo(float i, Object o, int n) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static int formatDFlo(double i, Object o, int n) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
public static MultiRecord scanSFlo(Object o, int n) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static MultiRecord scanDFlo(Object o, int n) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static MultiRecord scanSInt(Object o, int n) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
+
public static MultiRecord scanBInt(Object o, int n) {
- throw new RuntimeException();
+ throw new RuntimeException();
}
}
diff --git a/aldor/aldor/lib/java/src/foamj/MultiRecord.java b/aldor/aldor/lib/java/src/foamj/MultiRecord.java
index 607bd0bd8..960821bfe 100644
--- a/aldor/aldor/lib/java/src/foamj/MultiRecord.java
+++ b/aldor/aldor/lib/java/src/foamj/MultiRecord.java
@@ -2,10 +2,12 @@
public class MultiRecord extends Record {
- public MultiRecord(Format fmt) {
- super(fmt);
- }
+ public MultiRecord(Format fmt) {
+ super(fmt);
+ }
- public MultiRecord toMulti() { return this; }
+ public MultiRecord toMulti() {
+ return this;
+ }
}
\ No newline at end of file
diff --git a/aldor/aldor/lib/java/src/foamj/Record.java b/aldor/aldor/lib/java/src/foamj/Record.java
index 489a06c7c..f49b4c5d8 100644
--- a/aldor/aldor/lib/java/src/foamj/Record.java
+++ b/aldor/aldor/lib/java/src/foamj/Record.java
@@ -2,46 +2,46 @@
public class Record extends AbstractValue implements Value, Word {
- private Value[] arr;
- private int id;
- private static int count;
-
- public Record(Format fmt) {
- arr = new Value[fmt.size()];
- id = count++;
- }
-
- public Value getField(int idx, String name) {
- return arr[idx];
- }
-
- public Word getWord(int idx, String name) {
- return arr[idx].asWord();
- }
-
- public int getSInt(int idx, String name) {
- return arr[idx].toSInt();
- }
-
- public void setField(int idx, String name, Value val) {
- arr[idx] = val;
- }
-
- @Override
- public Value toValue() {
- return this;
- }
-
- @Override
- public Record toRecord() {
- return this;
- }
-
- public Word asWord() {
- return this;
- }
-
- public String toString() {
- return "[R: "+id + "]";
- }
+ private Value[] arr;
+ private int id;
+ private static int count;
+
+ public Record(Format fmt) {
+ arr = new Value[fmt.size()];
+ id = count++;
+ }
+
+ public Value getField(int idx, String name) {
+ return arr[idx];
+ }
+
+ public Word getWord(int idx, String name) {
+ return arr[idx].asWord();
+ }
+
+ public int getSInt(int idx, String name) {
+ return arr[idx].toSInt();
+ }
+
+ public void setField(int idx, String name, Value val) {
+ arr[idx] = val;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ @Override
+ public Record toRecord() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ public String toString() {
+ return "[R: " + id + "]";
+ }
}
diff --git a/aldor/aldor/lib/java/src/foamj/Value.java b/aldor/aldor/lib/java/src/foamj/Value.java
index 13cda0e42..b7dfa52a5 100644
--- a/aldor/aldor/lib/java/src/foamj/Value.java
+++ b/aldor/aldor/lib/java/src/foamj/Value.java
@@ -1,56 +1,92 @@
package foamj;
-import java.math.BigInteger;
-import foamj.FoamJ.Array;
-import foamj.FoamJ.BInt;
-import foamj.FoamJ.SInt;
-import foamj.FoamJ.HInt;
-import foamj.FoamJ.Bool;
-import foamj.FoamJ.Ptr;
-import foamj.FoamJ.SFlo;
-import foamj.FoamJ.DFlo;
-import foamj.FoamJ.Char;
+import foamj.FoamJ.*;
import foamj.FoamJ.Byte;
+import java.math.BigInteger;
+
/**
* Generic type used where we have to pass random objects around
*/
public interface Value {
- Word asWord();
- int toSInt();
- BigInteger toBInt();
- short toHInt();
- byte toByte();
- double toDFlo();
+ Word asWord();
+
+ int toSInt();
+
+ BigInteger toBInt();
+
+ short toHInt();
+
+ byte toByte();
+
+ double toDFlo();
+
float toSFlo();
- Object toArray();
- Record toRecord();
- Clos toClos();
- MultiRecord toMulti();
- boolean toBool();
+
+ Object toArray();
+
+ Record toRecord();
+
+ Clos toClos();
+
+ MultiRecord toMulti();
+
+ boolean toBool();
+
char toChar();
+
Object toPtr();
+
Env toEnv();
- public class U {
- static public Record toRecord(Value value) {
- if (value == null)
- return null;
- else
- return value.toRecord();
- }
-
- public static Value fromBool(boolean b) { return new Bool(b); }
- public static Value fromSInt(int x) { return new SInt(x); }
- public static Value fromArray(Object x) { return new Array(x); }
- public static Value fromBInt(BigInteger x) { return new BInt(x); }
- public static Value fromPtr(Object o) { return new Ptr(o); }
- public static Value fromSFlo(float o) { return new SFlo(o); }
- public static Value fromDFlo(double o) { return new DFlo(o); }
- public static Value fromChar(char o) { return new Char(o); }
- public static Value fromByte(byte o) { return new Byte(o); }
- public static Value fromHInt(short o) { return new HInt(o); }
- }
+ public class U {
+ static public Record toRecord(Value value) {
+ if (value == null)
+ return null;
+ else
+ return value.toRecord();
+ }
+
+ public static Value fromBool(boolean b) {
+ return new Bool(b);
+ }
+
+ public static Value fromSInt(int x) {
+ return new SInt(x);
+ }
+
+ public static Value fromArray(Object x) {
+ return new Array(x);
+ }
+
+ public static Value fromBInt(BigInteger x) {
+ return new BInt(x);
+ }
+
+ public static Value fromPtr(Object o) {
+ return new Ptr(o);
+ }
+
+ public static Value fromSFlo(float o) {
+ return new SFlo(o);
+ }
+
+ public static Value fromDFlo(double o) {
+ return new DFlo(o);
+ }
+
+ public static Value fromChar(char o) {
+ return new Char(o);
+ }
+
+ public static Value fromByte(byte o) {
+ return new Byte(o);
+ }
+
+ public static Value fromHInt(short o) {
+ return new HInt(o);
+ }
+ }
}
diff --git a/aldor/aldor/lib/java/src/foamj/Word.java b/aldor/aldor/lib/java/src/foamj/Word.java
index 496ae83ba..f905a1b5b 100644
--- a/aldor/aldor/lib/java/src/foamj/Word.java
+++ b/aldor/aldor/lib/java/src/foamj/Word.java
@@ -1,56 +1,92 @@
package foamj;
-import java.math.BigInteger;
-
-import foamj.FoamJ.Array;
-import foamj.FoamJ.SInt;
-import foamj.FoamJ.Bool;
-import foamj.FoamJ.Char;
+import foamj.FoamJ.*;
import foamj.FoamJ.Byte;
-import foamj.FoamJ.SFlo;
-import foamj.FoamJ.DFlo;
-import foamj.FoamJ.HInt;
-import foamj.FoamJ.BInt;
+
+import java.math.BigInteger;
/**
* Implementation of Foam Word type.
*/
public interface Word {
- Word asWord();
+ Word asWord();
+
Value toValue();
- int toSInt();
+
+ int toSInt();
+
boolean toBool();
+
Object toArray();
+
char toChar();
+
float toSFlo();
+
double toDFlo();
+
short toHInt();
+
BigInteger toBInt();
+
byte toByte();
-
+
public class U {
- static public Object toArray(Word word) {
- if (word == null)
- return null;
- else
- return word.toArray();
- }
-
- public static Word fromSInt(int x) { return new SInt(x); }
- public static Word fromBInt(BigInteger x) { return new BInt(x); }
- public static Word fromHInt(short x) { return new HInt(x); }
- public static Word fromArray(Object x) { return new Array(x); }
- public static Word fromBool(boolean b) { return new Bool(b); }
- public static Word fromChar(char c) { return new Char(c); }
- public static Word fromByte(byte b) { return new Byte(b); }
- public static Word fromSFlo(float f) { return new SFlo(f); }
- public static Word fromDFlo(double d) { return new DFlo(d); }
- public static Word fromRec(Record r) { return r; }
- public static Word fromClos(Clos r) { return r; }
- public static Word fromValue(Value v) {
- if (v == null) return null;
- else return v.asWord();
- }
+ static public Object toArray(Word word) {
+ if (word == null)
+ return null;
+ else
+ return word.toArray();
+ }
+
+ public static Word fromSInt(int x) {
+ return new SInt(x);
+ }
+
+ public static Word fromBInt(BigInteger x) {
+ return new BInt(x);
+ }
+
+ public static Word fromHInt(short x) {
+ return new HInt(x);
+ }
+
+ public static Word fromArray(Object x) {
+ return new Array(x);
+ }
+
+ public static Word fromBool(boolean b) {
+ return new Bool(b);
+ }
+
+ public static Word fromChar(char c) {
+ return new Char(c);
+ }
+
+ public static Word fromByte(byte b) {
+ return new Byte(b);
+ }
+
+ public static Word fromSFlo(float f) {
+ return new SFlo(f);
+ }
+
+ public static Word fromDFlo(double d) {
+ return new DFlo(d);
+ }
+
+ public static Word fromRec(Record r) {
+ return r;
+ }
+
+ public static Word fromClos(Clos r) {
+ return r;
+ }
+
+ public static Word fromValue(Value v) {
+ if (v == null) return null;
+ else return v.asWord();
+ }
}
}
From 35d0764b81960cb037e7c3eb2b8135eccfb0ad21 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 28 Mar 2017 23:20:06 +0100
Subject: [PATCH 146/352] configure.ac: Always generate .git version instead of
date
---
aldor/configure.ac | 21 +--------------------
aldor/m4/git.m4 | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 20 deletions(-)
create mode 100644 aldor/m4/git.m4
diff --git a/aldor/configure.ac b/aldor/configure.ac
index 29967c4eb..9917ce186 100644
--- a/aldor/configure.ac
+++ b/aldor/configure.ac
@@ -58,26 +58,7 @@ AC_SUBST([LIBTOOL_DEPS])
# Enable extra warnings and -Werror if supported.
ALDOR_ERROR_ON_WARN
-# Force git build id.
-git_build_id=0
-AC_ARG_ENABLE([git-build-id],
- [AS_HELP_STRING([--enable-git-build-id],
- [Force git sha1 hash as build id])],
- [git_build_id=],
- [git_build_id=`cd $srcdir; git status --porcelain 2>&1`])
-
-# Git SHA1 hash as ld build-id.
-AC_MSG_CHECKING([build id])
-if test -z "$git_build_id"; then
- VCSVERSION=`cd $srcdir; git rev-parse HEAD`
- build_id="-Wl,--build-id=0x$VCSVERSION"
- AC_MSG_RESULT([git: $VCSVERSION])
-else
- VCSVERSION=`date +%Y%m%d`
- AC_MSG_RESULT([date: $VCSVERSION])
-fi
-AC_SUBST([VCSVERSION])
-AC_SUBST([build_id])
+ALDOR_GIT_BUILD_ID
# Generate Makefiles
AC_CONFIG_FILES(
diff --git a/aldor/m4/git.m4 b/aldor/m4/git.m4
new file mode 100644
index 000000000..cd080bf0f
--- /dev/null
+++ b/aldor/m4/git.m4
@@ -0,0 +1,29 @@
+# Force git build id.
+
+AC_DEFUN([ALDOR_GIT_BUILD_ID],
+[git_build_id=""
+AC_ARG_ENABLE([git-build-id],
+ [AS_HELP_STRING([--enable-git-build-id],
+ [Force git sha1 hash as build id])],
+ [case "${enableval}" in
+ yes) gitid=true;;
+ no) gitid=false;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-git-build-id]) ;;
+ esac],
+ [if test -f $srcdir/../.git/config ; then gitid=true; else gitid=false; fi]
+ [if test $gitid = true; then git_build_id=1; fi])
+
+# Git SHA1 hash as ld build-id.
+AC_MSG_CHECKING([build id])
+if test 1 = "$git_build_id"; then
+ VCSVERSION=`cd $srcdir; git rev-parse HEAD`
+ build_id="-Wl,--build-id=0x$VCSVERSION"
+ AC_MSG_RESULT([git: $VCSVERSION])
+else
+ VCSVERSION=`date +%Y%m%d`
+ AC_MSG_RESULT([date: $VCSVERSION])
+fi
+AC_SUBST([VCSVERSION])
+AC_SUBST([build_id])
+])
+
From 37c7c90c865602a805b7ebb5f4fa6bd2e32ffebc Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 28 Mar 2017 23:22:33 +0100
Subject: [PATCH 147/352] Build: Copy source library to $prefix/share/lib -
Will be handy for UI stuff
---
aldor/aldor/lib/libfoam/al/Makefile.in | 1 +
aldor/aldor/lib/libfoamlib/al/Makefile.in | 1 +
aldor/lib/aldor/src/common.mk | 1 +
aldor/lib/algebra/src/common.mk | 1 +
aldor/lib/algebra/src/extree/Makefile.in | 8 ++++++++
aldor/lib/ax0/src/al/Makefile.in | 1 +
aldor/lib/axldem/src/al/Makefile.in | 1 +
aldor/lib/axllib/src/al/Makefile.in | 1 +
aldor/lib/buildlib.mk | 19 ++++++++++++++++++-
aldor/lib/config.mk.in | 6 ++++++
10 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/aldor/aldor/lib/libfoam/al/Makefile.in b/aldor/aldor/lib/libfoam/al/Makefile.in
index 0f7f671c4..67e4478aa 100644
--- a/aldor/aldor/lib/libfoam/al/Makefile.in
+++ b/aldor/aldor/lib/libfoam/al/Makefile.in
@@ -12,6 +12,7 @@ srcdir := @srcdir@
abs_srcdir := @abs_srcdir@
top_srcdir := @top_srcdir@
abs_top_srcdir := @abs_top_srcdir@
+abs_libdir := @abs_builddir@
subdir := $(subst $(abs_top_builddir)/,,$(abs_builddir))
# Build starts here
diff --git a/aldor/aldor/lib/libfoamlib/al/Makefile.in b/aldor/aldor/lib/libfoamlib/al/Makefile.in
index 6f73393e8..af2de16cd 100644
--- a/aldor/aldor/lib/libfoamlib/al/Makefile.in
+++ b/aldor/aldor/lib/libfoamlib/al/Makefile.in
@@ -12,6 +12,7 @@ srcdir := @srcdir@
abs_srcdir := @abs_srcdir@
top_srcdir := @top_srcdir@
abs_top_srcdir := @abs_top_srcdir@
+abs_libdir := $(abs_builddir)
subdir := $(subst $(abs_top_builddir)/,,$(abs_builddir))
# Build starts here
diff --git a/aldor/lib/aldor/src/common.mk b/aldor/lib/aldor/src/common.mk
index d600792db..963ebcc0e 100644
--- a/aldor/lib/aldor/src/common.mk
+++ b/aldor/lib/aldor/src/common.mk
@@ -1,5 +1,6 @@
aldorincdir := $(top_srcdir)/lib/aldor/include
aldorlibdir := $(top_builddir)/lib/aldor/src
+abs_libdir := $(abs_top_builddir)/lib/aldor/src
libraryname := aldor
librarydeps :=
diff --git a/aldor/lib/algebra/src/common.mk b/aldor/lib/algebra/src/common.mk
index 054e6b279..37c9f004a 100644
--- a/aldor/lib/algebra/src/common.mk
+++ b/aldor/lib/algebra/src/common.mk
@@ -1,5 +1,6 @@
aldorincdir := $(top_srcdir)/lib/aldor/include
aldorlibdir := $(top_builddir)/lib/aldor/src
+abs_libdir := $(abs_top_builddir)/lib/algebra/src
libraryname := algebra
librarydeps := aldor
diff --git a/aldor/lib/algebra/src/extree/Makefile.in b/aldor/lib/algebra/src/extree/Makefile.in
index 8dbc528b9..71bbcde71 100644
--- a/aldor/lib/algebra/src/extree/Makefile.in
+++ b/aldor/lib/algebra/src/extree/Makefile.in
@@ -19,3 +19,11 @@ library := sit_extree sit_optools
otherfiles := alg_leaf alg_op
include $(abs_top_srcdir)/lib/algebra/src/common.mk
+
+install-data:
+ $(MKDIR_P) $(DESTDIR)$(datarootdir)/aldor/lib/$(libraryname)/$(libsubdir)
+ for i in $(otherfiles); do \
+ if test -f $(abs_srcdir)/$$i.as; then \
+ $(INSTALL_DATA) $(abs_srcdir)/$$i.as $(DESTDIR)$(datarootdir)/aldor/lib/$(libraryname)/$(libsubdir)/$$i.as; \
+ fi; \
+ done
diff --git a/aldor/lib/ax0/src/al/Makefile.in b/aldor/lib/ax0/src/al/Makefile.in
index d9eac9dcf..40ada2d9c 100644
--- a/aldor/lib/ax0/src/al/Makefile.in
+++ b/aldor/lib/ax0/src/al/Makefile.in
@@ -12,6 +12,7 @@ srcdir := @srcdir@
abs_srcdir := @abs_srcdir@
top_srcdir := @top_srcdir@
abs_top_srcdir := @abs_top_srcdir@
+abs_libdir := $(abs_top_builddir)/lib/ax0/src/al
subdir := $(subst $(abs_top_builddir)/,,$(abs_builddir))
VPATH := $(VPATH):$(top_srcdir)/lib/axllib/src/al
diff --git a/aldor/lib/axldem/src/al/Makefile.in b/aldor/lib/axldem/src/al/Makefile.in
index a2a5f4ee5..440256e49 100644
--- a/aldor/lib/axldem/src/al/Makefile.in
+++ b/aldor/lib/axldem/src/al/Makefile.in
@@ -12,6 +12,7 @@ srcdir := @srcdir@
abs_srcdir := @abs_srcdir@
top_srcdir := @top_srcdir@
abs_top_srcdir := @abs_top_srcdir@
+abs_libdir := $(abs_top_builddir)/lib/axldem/src/al
subdir := $(subst $(abs_top_builddir)/,,$(abs_builddir))
# Build starts here
diff --git a/aldor/lib/axllib/src/al/Makefile.in b/aldor/lib/axllib/src/al/Makefile.in
index 02a00037b..b910d1c64 100644
--- a/aldor/lib/axllib/src/al/Makefile.in
+++ b/aldor/lib/axllib/src/al/Makefile.in
@@ -12,6 +12,7 @@ srcdir := @srcdir@
abs_srcdir := @abs_srcdir@
top_srcdir := @top_srcdir@
abs_top_srcdir := @abs_top_srcdir@
+abs_libdir := $(abs_top_builddir)/lib/axllib/src/al
subdir := $(subst $(abs_top_builddir)/,,$(abs_builddir))
# Build starts here
diff --git a/aldor/lib/buildlib.mk b/aldor/lib/buildlib.mk
index 7241ce125..81ee1f02a 100644
--- a/aldor/lib/buildlib.mk
+++ b/aldor/lib/buildlib.mk
@@ -15,6 +15,8 @@ asdomains := $(internal) $(library) $(tests)
axdomains := $(axlibrary)
alldomains := $(asdomains) $(axdomains)
+libsubdir := $(subst $(abs_libdir)/,,$(abs_builddir)/.)
+
include $(top_builddir)/lib/config.mk
# Aldor
@@ -336,9 +338,24 @@ distclean: clean
rm Makefile
maintainer-clean: distclean
+install-data:
+ $(MKDIR_P) $(DESTDIR)$(datarootdir)/aldor/lib/$(libraryname)/$(libsubdir)
+ for i in $(library); do \
+ if test -f $(abs_srcdir)/$$i.as; then \
+ $(INSTALL_DATA) $(abs_srcdir)/$$i.as $(DESTDIR)$(datarootdir)/aldor/lib/$(libraryname)/$(libsubdir)/$$i.as; \
+ fi; \
+ if test -f $$i.abn; then \
+ $(INSTALL_DATA) $$i.abn $(DESTDIR)$(datarootdir)/aldor/lib/$(libraryname)/$(libsubdir)/$$i.abn; \
+ fi; \
+ done
+
+uninstall:
+ rm -rf $(datarootdir)/lib/$(libraryname)/$(libsubdir)
+
+install: install-data install-exec
EMPTY_AUTOMAKE_TARGETS = dvi pdf ps info html tags ctags
-EMPTY_AUTOMAKE_TARGETS += install install-data install-exec uninstall
+EMPTY_AUTOMAKE_TARGETS += install-exec uninstall
EMPTY_AUTOMAKE_TARGETS += install-dvi install-html install-info install-ps install-pdf
EMPTY_AUTOMAKE_TARGETS += installdirs
EMPTY_AUTOMAKE_TARGETS += check installcheck
diff --git a/aldor/lib/config.mk.in b/aldor/lib/config.mk.in
index 040d79efd..a5049b06f 100644
--- a/aldor/lib/config.mk.in
+++ b/aldor/lib/config.mk.in
@@ -1,2 +1,8 @@
@BUILD_JAVA_TRUE@BUILD_JAVA=1
@BUILD_JAVA_FALSE@BUILD_JAVA=
+
+prefix := @prefix@
+datarootdir := @datarootdir@
+MKDIR_P := @MKDIR_P@
+INSTALL := @INSTALL@
+INSTALL_DATA := @INSTALL_DATA@
From 9cfed387c50e20842abc013f04792d30fa22c722 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Fri, 1 Dec 2017 21:53:32 +0000
Subject: [PATCH 148/352] build: Add implicit-fallthrough for gcc-7.2
---
aldor/m4/strict_compile.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/m4/strict_compile.m4 b/aldor/m4/strict_compile.m4
index 0227f0d86..84655efca 100644
--- a/aldor/m4/strict_compile.m4
+++ b/aldor/m4/strict_compile.m4
@@ -18,7 +18,7 @@ AC_DEFUN([ALDOR_STRICT_COMPILE],
$cfg_no_sign_compare $cfg_no_shift_negative_value"
case "${CC}" in
gcc*)
- cfgSTRICTCFLAGS="${cfgSTRICTCFLAGS} -Wno-error=clobbered"
+ cfgSTRICTCFLAGS="${cfgSTRICTCFLAGS} -Wno-error=clobbered -Wno-implicit-fallthrough"
;;
clang*)
cfgSTRICTCFLAGS="${cfgSTRICTCFLAGS} -fcolor-diagnostics -Wno-error=enum-conversion \
From 37fb1c2d5645fc85bd7e79de76a454270b89f90e Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:29:12 +0000
Subject: [PATCH 149/352] src: Fallthrough warnings - abpretty.c
---
aldor/aldor/src/abpretty.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/abpretty.c b/aldor/aldor/src/abpretty.c
index 06cea772d..775ca56d0 100644
--- a/aldor/aldor/src/abpretty.c
+++ b/aldor/aldor/src/abpretty.c
@@ -606,7 +606,7 @@ abPPClipped0(Buffer buf, AbSyn ab, long *pmaxchars)
case AB_Default:
if (abIsNothing(abArgv(ab)[0]))
break;
-
+ /* Fall through */
default:
{
TokenTag tTag = abInfo(abTag(ab)).tokenTag;
From 898af0589a1d5b10c3d1675f82c08860613643a8 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:29:35 +0000
Subject: [PATCH 150/352] src: Fallthrough warnings - linear.c
---
aldor/aldor/src/linear.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/aldor/aldor/src/linear.c b/aldor/aldor/src/linear.c
index 809c079de..1177496f1 100644
--- a/aldor/aldor/src/linear.c
+++ b/aldor/aldor/src/linear.c
@@ -22,6 +22,7 @@
#include "store.h"
#include "fint.h"
#include "comsg.h"
+#include "util.h"
Bool linDebug = false;
#define linDEBUG DEBUG_IF(lin) afprintf
@@ -579,6 +580,7 @@ lntFrTL_DoLine(TokenList *ptl)
else if (depthDontPileNo)
break;
#endif
+ /* Fall through */
default:
lnt = lntFrTL_1Tok(&tl0);
ll = listCons(LNodeTree)(lnt, ll);
From d4510e7c87aeaae614486069d021ea72deb59094 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:30:12 +0000
Subject: [PATCH 151/352] src: Fallthrough warnings - tform.c
---
aldor/aldor/src/tform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/tform.c b/aldor/aldor/src/tform.c
index 0dcec4671..8a5b94112 100644
--- a/aldor/aldor/src/tform.c
+++ b/aldor/aldor/src/tform.c
@@ -5691,7 +5691,7 @@ tfDefineeSymbol(TForm tf)
tf = tfMultiArgN(tf, int0);
break;
}
- /* else fall through to default case. */
+ /* fall through */
default:
return NULL;
}
From 97d748a2a3e2a9a72d7bb9ef900df72938825b8f Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:37:05 +0000
Subject: [PATCH 152/352] sexpr.c: Add no-return annotation to error function
---
aldor/aldor/src/sexpr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/sexpr.c b/aldor/aldor/src/sexpr.c
index d9b02aea0..0bd964f8a 100644
--- a/aldor/aldor/src/sexpr.c
+++ b/aldor/aldor/src/sexpr.c
@@ -84,7 +84,7 @@ Bool sexprDebug = false;
local int sxiIoIsNeedingEscape(String);
-local void sxiRdError(int errnum, ...);
+local void sxiRdError(int errnum, ...) chk_noreturn;
local SExpr sxiUseError(int errnum, ...);
local SExpr sxiDefaultHandler(SrcPos, int errnum, va_list argp);
From c59cf4290f5f7d012b1b64be27c424fde783cdb5 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:37:43 +0000
Subject: [PATCH 153/352] comsgdb.c: Add no return to "fatal" functions
---
aldor/aldor/src/comsg.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/src/comsg.h b/aldor/aldor/src/comsg.h
index 3f2901521..6365c6a65 100644
--- a/aldor/aldor/src/comsg.h
+++ b/aldor/aldor/src/comsg.h
@@ -80,7 +80,7 @@ extern int comsgErrorCount (void);
/*
* Add messages.
*/
-extern void comsgFatal (AbSyn, Msg fmt, ...);
+extern void comsgFatal (AbSyn, Msg fmt, ...) chk_noreturn;
extern void comsgError (AbSyn, Msg fmt, ...);
extern void comsgWarning (AbSyn, Msg fmt, ...);
extern void comsgRemark (AbSyn, Msg fmt, ...);
@@ -88,7 +88,7 @@ extern void comsgWarnPos (SrcPos, Msg fmt, ...);
/*
* Varargs versions
*/
-extern void comsgVFatal (AbSyn, Msg fmt, va_list);
+extern void comsgVFatal (AbSyn, Msg fmt, va_list) chk_noreturn;
extern CoMsg comsgVError (AbSyn, Msg fmt, va_list);
extern CoMsg comsgVWarning (AbSyn, Msg fmt, va_list);
extern CoMsg comsgVRemark (AbSyn, Msg fmt, va_list);
From 38298c511bae881980da1e48d2cfdf5592cc483e Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:38:23 +0000
Subject: [PATCH 154/352] ccode.c: Fix fallthrough comment.
gcc is a bit fussy
---
aldor/aldor/src/ccode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/ccode.c b/aldor/aldor/src/ccode.c
index 262af12c5..1ed13be3f 100644
--- a/aldor/aldor/src/ccode.c
+++ b/aldor/aldor/src/ccode.c
@@ -1143,7 +1143,7 @@ ccoIsWantingElse(CCode cco)
switch (ccoTag(cco)) {
case CCO_If:
if (!ccoArgv(cco)[2]) return true;
- /* Seep through. */
+ /* fall through. */
case CCO_Switch:
case CCO_While:
case CCO_For:
From 4c6d75f7578422aaa08be3e6bb98288c59a0ba18 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:41:39 +0000
Subject: [PATCH 155/352] features.h: Always define chk_noreturn and
chk_fallthrough
---
aldor/aldor/src/features.h0 | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/aldor/aldor/src/features.h0 b/aldor/aldor/src/features.h0
index 4409ec7e0..b2fd637f5 100644
--- a/aldor/aldor/src/features.h0
+++ b/aldor/aldor/src/features.h0
@@ -4,15 +4,13 @@
#if defined(__GNUC__)
# define chk_fmt(a, b) __attribute__((format(printf, a, b)))
# define chk_nonnull(x) __attribute__((nonnull x))
-# if defined(_ANALYSING)
-# define chk_noreturn __attribute__((noreturn))
-# else
-# define chk_noreturn
-# endif
+# define chk_noreturn __attribute__((noreturn))
+# define chk_fallthrough __attribute__((fallthrough))
#else
# define chk_fmt(a, b)
# define chk_noreturn
# define chk_nonnull(x)
+# define chk_fallthrough
#endif
#endif /* FEATURES_H0 */
From 3bad0ec08e226d7598e9cbcbfb91d1b62560f259 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 18:46:54 +0000
Subject: [PATCH 156/352] axlcomp.c: Simplify fallthrough thing
(spent too long trying to fix..)
---
aldor/aldor/src/axlcomp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/aldor/aldor/src/axlcomp.c b/aldor/aldor/src/axlcomp.c
index eed70ba06..f0980576c 100644
--- a/aldor/aldor/src/axlcomp.c
+++ b/aldor/aldor/src/axlcomp.c
@@ -542,7 +542,9 @@ compFilesLoop(int argc, char **argv)
comsgFatal(NULL, ALDOR_F_BadFType, argv[i],
fnameType(fn), FTYPE_SRC);
}
- /* Fall through. */
+ if (!isSolo) fprintf(osStdout, "\n%s:\n", argv[i]);
+ nErrors = compSourceFile(compFinfov[i]);
+ break;
case FTYPENO_NONE:
case FTYPENO_SRC:
case FTYPENO_INCLUDED:
From fcec09c669389d437bc400af90dd8057b213e415 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 18:50:14 +0000
Subject: [PATCH 157/352] fixup: Re-introduce -Mno-implicit-fallthrough in
build
---
aldor/m4/strict_compile.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/m4/strict_compile.m4 b/aldor/m4/strict_compile.m4
index 84655efca..0227f0d86 100644
--- a/aldor/m4/strict_compile.m4
+++ b/aldor/m4/strict_compile.m4
@@ -18,7 +18,7 @@ AC_DEFUN([ALDOR_STRICT_COMPILE],
$cfg_no_sign_compare $cfg_no_shift_negative_value"
case "${CC}" in
gcc*)
- cfgSTRICTCFLAGS="${cfgSTRICTCFLAGS} -Wno-error=clobbered -Wno-implicit-fallthrough"
+ cfgSTRICTCFLAGS="${cfgSTRICTCFLAGS} -Wno-error=clobbered"
;;
clang*)
cfgSTRICTCFLAGS="${cfgSTRICTCFLAGS} -fcolor-diagnostics -Wno-error=enum-conversion \
From 30712dce518e8540338696bbb89e0975ce0e8cf7 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 29 May 2018 09:30:20 +0100
Subject: [PATCH 158/352] syme.c: avoid compiler warnings from symeModBit
(nb: This should really change symeModBit)
---
aldor/aldor/src/syme.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/syme.h b/aldor/aldor/src/syme.h
index a541f320c..2a61951a7 100644
--- a/aldor/aldor/src/syme.h
+++ b/aldor/aldor/src/syme.h
@@ -266,7 +266,7 @@ extern AInt symeSetFieldVal;
(symeLocalFieldv(s)[symeIndex(s,f)] = (v))
#define symeGetField(s,f) \
- (symeModBit(f) && !symeHasField(s,f) ? symeFieldDefault(f) : \
+ (f < bitsizeof(int) && !symeHasField(s,f) ? symeFieldDefault(f) : \
symeHasLocal(s,f) ? symeGetLocal(s,f) : symeGetFieldFn(s,f))
#define symeSetField(s,f,v) \
From e1b4e0e4cfc5858b412f47a0984fa785b76fa436 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 29 May 2018 09:28:19 +0100
Subject: [PATCH 159/352] fint.c: fallthrough & missing break statement
---
aldor/aldor/src/fint.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/aldor/aldor/src/fint.c b/aldor/aldor/src/fint.c
index 62a13951d..95edfb49b 100644
--- a/aldor/aldor/src/fint.c
+++ b/aldor/aldor/src/fint.c
@@ -1556,6 +1556,7 @@ fintStmt(DataObj retDataObj)
fintSet(type, loc, expr);
}
+ /* fall through */
case FOAM_Free:
(void)fintEval(&expr);
fintFree0(expr.fiPtr);
@@ -4198,6 +4199,7 @@ fintEval_(DataObj retDataObj)
break;
case FOAM_SInt:
retDataObj->fiArr = (Ptr) fiArrNew_SInt(argc+1);
+ break;
case FOAM_SFlo:
retDataObj->fiArr = (Ptr) fiArrNew_SFlo(argc+1);
break;
From 3035464b626d776769e214efc052a3644986f5e5 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 29 May 2018 09:29:16 +0100
Subject: [PATCH 160/352] genc.c: Missing break statements.
---
aldor/aldor/src/genc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/aldor/aldor/src/genc.c b/aldor/aldor/src/genc.c
index b1eb19728..d25430c85 100644
--- a/aldor/aldor/src/genc.c
+++ b/aldor/aldor/src/genc.c
@@ -3795,9 +3795,11 @@ gccMFmt(Foam foam)
/* Only allowed (Set (Values ...) (MFmt f (Catch ...))) */
bug("gccMFmt: Catch in MFmt missed by gc0Set");
NotReached(cc = 0);
+ break;
default:
bugBadCase(foamTag(expr));
NotReached(cc = 0);
+ break;
}
return cc;
}
From d4ad2548acd641667d96a47f7de072a62935b8ff Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Wed, 25 Apr 2018 21:57:22 +0100
Subject: [PATCH 161/352] assert.h0: abort_if_fatal can return
---
aldor/aldor/src/assert.h0 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/src/assert.h0 b/aldor/aldor/src/assert.h0
index 0700da058..6db04b88b 100644
--- a/aldor/aldor/src/assert.h0
+++ b/aldor/aldor/src/assert.h0
@@ -18,8 +18,8 @@
#ifndef DO_ASSERT_IS_DECLARED
#define DO_ASSERT_IS_DECLARED
-void _abort_if_fatal_assert(void) chk_noreturn;
-void _do_assert(char *str, char *file, int line) chk_noreturn;
+void _abort_if_fatal_assert(void);
+void _do_assert(char *str, char *file, int line);
#endif
#if defined(QASSERT)
From e5cda55b1e4a4cb7694e3795483e4a7661f9388b Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:34:45 +0000
Subject: [PATCH 162/352] sefo.c: sefo hash check on equality won't work.
Remove.
SefoEqual includes defineValues - which are not used in hash
---
aldor/aldor/src/sefo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/aldor/aldor/src/sefo.c b/aldor/aldor/src/sefo.c
index 6da5785bc..6b0fc1d30 100644
--- a/aldor/aldor/src/sefo.c
+++ b/aldor/aldor/src/sefo.c
@@ -106,6 +106,7 @@ local Bool tformEqual0 (SymeList, TForm, TForm);
local Bool sefoListEqual0 (SymeList, SefoList, SefoList);
local Bool symeListEqual0 (SymeList, SymeList, SymeList);
local Bool tformListEqual0 (SymeList,TFormList,TFormList);
+local Bool sefoIsDefinedType (Sefo);
local Bool symeTypeEqual0 (SymeList, Syme, Syme);
local Bool symeExtendEqual0 (SymeList, Syme, Syme);
@@ -1436,7 +1437,7 @@ sefoEqual(Sefo sefo1, Sefo sefo2)
eq = sefoEqual0(NULL, sefo1, sefo2);
sstDoneSefo(sefo1);
- if (eq)
+ if (eq && !sefoIsDefinedType(sefo1) && !sefoIsDefinedType(sefo2))
assert(abHashSefo(sefo1) == abHashSefo(sefo2));
return eq;
From 0fbdc1f1a94a8b1a13f077a46ff4dc0efd45ddbc Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:40:46 +0000
Subject: [PATCH 163/352] axllib/test: 1248 won't work.
It uses lambda which returns a category; I think we're not set up to
handle this case.
---
aldor/lib/axllib/test/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/aldor/lib/axllib/test/Makefile.am b/aldor/lib/axllib/test/Makefile.am
index 985947f30..2b3d7a8a5 100644
--- a/aldor/lib/axllib/test/Makefile.am
+++ b/aldor/lib/axllib/test/Makefile.am
@@ -161,7 +161,6 @@ AXLTESTS = \
bug1235 \
bug1237 \
bug1242 \
- bug1248 \
bug1250 \
bug1252 \
bug1253 \
@@ -474,6 +473,7 @@ AXLTESTS = \
BROKEN = \
bug1125 \
bug1190 \
+ bug1248 \
fix1 \
opt1 \
pack1 \
@@ -497,6 +497,7 @@ XFAIL_TESTS = \
bug1114/bug1114 \
bug1176/bug1176 \
bug1220/bug1220 \
+ bug1248/bug1248 \
bug1252/bug1252 \
bug1290/bug1290 \
depend8/depend8 \
From 91db7c783150f1bf94e156467b254bb5e2ab73b2 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 18:48:13 +0000
Subject: [PATCH 164/352] axllib/test: No need for -Wno-fatal
Papering over cracks..
---
aldor/lib/ax0/src/al/Makefile.in | 2 +-
aldor/lib/axllib/test/Tests.am | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/aldor/lib/ax0/src/al/Makefile.in b/aldor/lib/ax0/src/al/Makefile.in
index 40ada2d9c..c3e3ee096 100644
--- a/aldor/lib/ax0/src/al/Makefile.in
+++ b/aldor/lib/ax0/src/al/Makefile.in
@@ -71,7 +71,7 @@ axllibincdir := $(top_srcdir)/lib/axllib/include
libraryname := ax0
Libraryname := Axiom
-AXLFLAGS := -Q8 -Wcheck -Wno-fatal
+AXLFLAGS := -Q8 -Wcheck
AXLFLAGS += -I $(axllibincdir)
bytecode_only := true
diff --git a/aldor/lib/axllib/test/Tests.am b/aldor/lib/axllib/test/Tests.am
index 1b6f54542..70f95bd19 100644
--- a/aldor/lib/axllib/test/Tests.am
+++ b/aldor/lib/axllib/test/Tests.am
@@ -479,9 +479,6 @@ CLEANFILES += bug1237/bug1237-aldormain.c bug1237/bug1237.c bug1237/bug1237.ao
check_PROGRAMS += bug1242/bug1242
bug1242_bug1242_SOURCES = bug1242/bug1242-aldormain.c bug1242/bug1242.c
CLEANFILES += bug1242/bug1242-aldormain.c bug1242/bug1242.c bug1242/bug1242.ao
-check_PROGRAMS += bug1248/bug1248
-bug1248_bug1248_SOURCES = bug1248/bug1248-aldormain.c bug1248/bug1248.c
-CLEANFILES += bug1248/bug1248-aldormain.c bug1248/bug1248.c bug1248/bug1248.ao
check_PROGRAMS += bug1250/bug1250
bug1250_bug1250_SOURCES = bug1250/bug1250-aldormain.c bug1250/bug1250.c
CLEANFILES += bug1250/bug1250-aldormain.c bug1250/bug1250.c bug1250/bug1250.ao
From d07b7202da85ddca08b76078ba29b9615cf6183d Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 3 Dec 2017 17:36:25 +0000
Subject: [PATCH 165/352] bugfix: genfoam.c: gen0NilValue should ignore
exceptions.
---
aldor/aldor/src/genfoam.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/aldor/aldor/src/genfoam.c b/aldor/aldor/src/genfoam.c
index 5cd10c905..590c63987 100644
--- a/aldor/aldor/src/genfoam.c
+++ b/aldor/aldor/src/genfoam.c
@@ -681,6 +681,7 @@ gen0EmbedExit(Foam foam, AbSyn ab, TForm tf)
local Foam
gen0NilValue(TForm tf)
{
+ tf = tfIgnoreExceptions(tf);
if (!tfIsMulti(tf)) {
return foamNewNil();
}
From 0f1227da53b6a645cc645de0459e0843143681df Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Wed, 4 Jul 2018 23:17:59 +0100
Subject: [PATCH 166/352] assert.h: All failed assertions are fatal
---
aldor/aldor/src/assert.h0 | 2 --
aldor/aldor/src/cmdline.c | 2 --
aldor/aldor/src/stdc.c | 10 +---------
aldor/aldor/src/util.c | 2 +-
aldor/lib/algebra/src/test/Makefile.in | 2 +-
aldor/lib/testprog.am | 2 +-
6 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/aldor/aldor/src/assert.h0 b/aldor/aldor/src/assert.h0
index 6db04b88b..d47bcb7b7 100644
--- a/aldor/aldor/src/assert.h0
+++ b/aldor/aldor/src/assert.h0
@@ -18,7 +18,6 @@
#ifndef DO_ASSERT_IS_DECLARED
#define DO_ASSERT_IS_DECLARED
-void _abort_if_fatal_assert(void);
void _do_assert(char *str, char *file, int line);
#endif
@@ -29,7 +28,6 @@ void _do_assert(char *str, char *file, int line);
#endif
extern int _dont_assert;
-extern int _fatal_assert;
#if defined(NDEBUG)
# define assert(c)
diff --git a/aldor/aldor/src/cmdline.c b/aldor/aldor/src/cmdline.c
index f6600e801..b120786df 100644
--- a/aldor/aldor/src/cmdline.c
+++ b/aldor/aldor/src/cmdline.c
@@ -877,8 +877,6 @@ cmdDoOptDeveloper(String arg)
_dont_assert = false; /* Test assertions. */
stoCtl(StoCtl_Wash, true); /* Initialize of store. */
}
- else if (strAEqual("no-fatal", arg))
- _fatal_assert = false; /* Make assertions non-fatal. */
else if (strAEqual("runtime", arg))
genSetRuntime();
else if (strEqual("debug", arg))
diff --git a/aldor/aldor/src/stdc.c b/aldor/aldor/src/stdc.c
index a02d6a64f..29447d396 100644
--- a/aldor/aldor/src/stdc.c
+++ b/aldor/aldor/src/stdc.c
@@ -9,14 +9,6 @@
#include "stdc.h"
int _dont_assert = 0;
-int _fatal_assert = 1;
-
-void
-_abort_if_fatal_assert(void)
-{
- if (_fatal_assert)
- abort();
-}
void
_do_assert(char *str, char *file, int line)
@@ -29,7 +21,7 @@ _do_assert(char *str, char *file, int line)
fprintf(stderr,
"Assertion failed, file \"%s\" line %d: %s\n",
file, line, str);
- _abort_if_fatal_assert();
+ abort();
}
diff --git a/aldor/aldor/src/util.c b/aldor/aldor/src/util.c
index 0474d0e51..1a47bc0e5 100644
--- a/aldor/aldor/src/util.c
+++ b/aldor/aldor/src/util.c
@@ -85,7 +85,7 @@ bug(String fmt, ...)
va_start(argp, fmt); vprintf(fmt, argp); va_end(argp);
printf("\n");
- _abort_if_fatal_assert();
+ abort();
}
/*****************************************************************************
diff --git a/aldor/lib/algebra/src/test/Makefile.in b/aldor/lib/algebra/src/test/Makefile.in
index 4b43ed820..f3685c2b6 100644
--- a/aldor/lib/algebra/src/test/Makefile.in
+++ b/aldor/lib/algebra/src/test/Makefile.in
@@ -27,7 +27,7 @@ check: $(addsuffix .test,$(tests))
$(addsuffix .test,$(tests)): %.test: %.ao
cp $(SUBLIB_DEPEND).al lib$(libraryname)_$*.al; \
ar r lib$(libraryname)_$*.al $(addsuffix .ao, $(shell $(UNIQ) $*.dep)); \
- $(DBG) $(aldorexedir)/aldor -Wcheck \
+ $(DBG) $(aldorexedir)/aldor \
-Nfile=$(aldorsrcdir)/aldor.conf \
-Y. \
-Y$(aldorlibdir)/libfoam/al \
diff --git a/aldor/lib/testprog.am b/aldor/lib/testprog.am
index 3b0846d7e..8f561e035 100644
--- a/aldor/lib/testprog.am
+++ b/aldor/lib/testprog.am
@@ -24,7 +24,7 @@ ALDORFLAGS := \
-Nfile=$(aldorsrcdir)/aldor.conf \
$(addprefix -I,$(libraryincdirs)) \
$(addprefix -Y,$(librarylibdirs)) \
- -Waudit -Wcheck -Wno-fatal \
+ -Waudit -Wcheck \
$(ALFLAGS)
# Aldor silent-rules
From 96e12ed8379eac7a44acd012d3ffe8dbfba94360 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Mon, 8 May 2017 09:06:03 +0100
Subject: [PATCH 167/352] travis: Build requires fakeroot & debhelper
So add them
---
.travis.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index fbb4cdaf3..500a86c46 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,6 +3,8 @@ script: dpkg-buildpackage -b -us -uc
install:
- sudo apt-get install libgmp-dev
+ - sudo apt-get install fakeroot
+ - sudo apt-get install debhelper
# whitelist
branches:
From c57f7055b60b13038e0d1839824ab587d741035c Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 28 Mar 2017 23:23:10 +0100
Subject: [PATCH 168/352] version.c: Bump version number.
---
aldor/aldor/src/version.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/version.c b/aldor/aldor/src/version.c
index 34afa00bd..ac1f989b7 100644
--- a/aldor/aldor/src/version.c
+++ b/aldor/aldor/src/version.c
@@ -23,6 +23,6 @@
CString verName = "Aldor";
int verMajorVersion = 1;
-int verMinorVersion = 2;
+int verMinorVersion = 3;
int verMinorFreeze = 0;
CString verPatchLevel = VCSVERSION;
From 1ccfb481230bb63948a40ad4177504c7a8a368ff Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 24 Jun 2017 20:41:43 +0100
Subject: [PATCH 169/352] gf_imps.c: Don't bother creating a FOAM_Cast when not
required
---
aldor/aldor/src/gf_imps.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/src/gf_imps.c b/aldor/aldor/src/gf_imps.c
index 1210c463f..86eb593e2 100644
--- a/aldor/aldor/src/gf_imps.c
+++ b/aldor/aldor/src/gf_imps.c
@@ -349,7 +349,9 @@ gen0GetDomImport(Syme syme, Foam dom)
else if (tfSatType(tf)) {
/* Don't use lazy gets for imported types. */
call = gen0MakeGetExport(dom, name, type);
- call = foamNewCast(fmType, call);
+ if (fmType != FOAM_Word) {
+ foamNewCast(fmType, call);
+ }
}
else
call = gen0LazyConstGet(syme, dom, name, type);
@@ -471,7 +473,7 @@ gen0LazyValue(Foam var, Syme syme)
"runtime", 1, var);
foamSyme(var) = syme;
foamPure(foam) = true;
- return foamNewCast(type, foam);
+ return type == FOAM_Word ? foam : foamNewCast(type, foam);
}
local Foam
From 6df76403ed4c0e46bc095c257eac18850bd99df5 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Wed, 13 Jun 2018 20:46:23 +0100
Subject: [PATCH 170/352] lib: Ignore "comp" library - not used anywhere
---
aldor/lib/.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/aldor/lib/.gitignore b/aldor/lib/.gitignore
index 5b89b3cb1..0a1c1e847 100644
--- a/aldor/lib/.gitignore
+++ b/aldor/lib/.gitignore
@@ -4,3 +4,5 @@
*_test.as
# Generated by the build (java test files)
*_jtest.as
+# Test library
+comp
From 6c3626e364a7f9748e5106f950642a9dfe9df199 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 24 Jun 2017 20:43:04 +0100
Subject: [PATCH 171/352] int.c: Add absorbing sum function
Handy for avoiding integer wrap errors
---
aldor/aldor/src/int.c | 7 +++++++
aldor/aldor/src/int.h | 1 +
aldor/aldor/src/test/test_int.c | 13 +++++++++++++
3 files changed, 21 insertions(+)
diff --git a/aldor/aldor/src/int.c b/aldor/aldor/src/int.c
index 94da839cf..f14cf2d8b 100644
--- a/aldor/aldor/src/int.c
+++ b/aldor/aldor/src/int.c
@@ -28,3 +28,10 @@ aintHash(AInt n)
return n;
}
+AInt
+aintAbsorbingSum(AInt max, AInt i1, AInt i2)
+{
+ assert(i1 >= 0);
+ assert(i2 >= 0);
+ return max - i2 > i1 ? i1 + i2: max;
+}
diff --git a/aldor/aldor/src/int.h b/aldor/aldor/src/int.h
index 0b11eea72..3b3f1cc0a 100644
--- a/aldor/aldor/src/int.h
+++ b/aldor/aldor/src/int.h
@@ -5,6 +5,7 @@ extern Bool longIsInt32(long n);
extern Bool aintEqual(AInt i1, AInt i2);
extern Hash aintHash(AInt i1);
+extern AInt aintAbsorbingSum(AInt, AInt, AInt);
#ifdef CC_long_not_int32
#define IF_LongOver32Bits(x) Statement(x)
diff --git a/aldor/aldor/src/test/test_int.c b/aldor/aldor/src/test/test_int.c
index a0ec7d035..e2b6747b6 100644
--- a/aldor/aldor/src/test/test_int.c
+++ b/aldor/aldor/src/test/test_int.c
@@ -5,6 +5,7 @@
local void testLongIs32(void);
local void verifyAIntEqual(void);
+local void verifyAIntAbsorbingSum(void);
void
intTestSuite()
@@ -13,6 +14,7 @@ intTestSuite()
dbInit();
TEST(testLongIs32);
TEST(verifyAIntEqual);
+ TEST(verifyAIntAbsorbingSum);
dbFini();
}
@@ -41,3 +43,14 @@ verifyAIntEqual()
testFalse("t1", aintEqual(0, 1));
testTrue("t1", aintEqual(0, 0));
}
+
+
+local void
+verifyAIntAbsorbingSum()
+{
+ testTrue("t1", aintAbsorbingSum(100, 99, 1) == 100);
+ testTrue("t2", aintAbsorbingSum(100, 99, 0) == 99);
+ testTrue("t3", aintAbsorbingSum(100, 99, 10) == 100);
+
+ testTrue("t4", aintAbsorbingSum(1<<30, (1<<30) - 10, 20) == 1<<30);
+}
From c11e5138490bba36410684e7f7d3aba3b4cf2543 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 24 Jun 2017 21:16:38 +0100
Subject: [PATCH 172/352] inlutil.c: Avoid overflow when calculating function
cost
---
aldor/aldor/src/inlutil.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/src/inlutil.c b/aldor/aldor/src/inlutil.c
index b22fe812e..097758817 100644
--- a/aldor/aldor/src/inlutil.c
+++ b/aldor/aldor/src/inlutil.c
@@ -14,6 +14,7 @@
#include "loops.h"
#include "optfoam.h"
#include "strops.h"
+#include "int.h"
Bool inuProgDebug = false;
@@ -434,10 +435,11 @@ inuAnalyseProg(Foam foam, int constNum)
InlUnknownCallsMagicNumber;
flogIter(optInfo->flog, bb, {
- timeCost += (1 << (bb->iextra * InlLoopMagicNumber));
+ int loops = bb->iextra > 5 ? 5 : bb->iextra;
+ timeCost = aintAbsorbingSum(TIME_MAX, timeCost, (1 << (loops * InlLoopMagicNumber)));
});
- foam->foamProg.time = timeCost > TIME_MAX ? TIME_MAX : timeCost;
+ foam->foamProg.time = timeCost;
foamProgSetHasInlineInfo(foam);
}
From 63150354c76e7ad35990dcdd432357c5b8410466 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 24 Jun 2017 21:20:09 +0100
Subject: [PATCH 173/352] absyn.c: New abNewDefineLhs -- creates a lhs of a
define from parsed form
eg. Foo(X: Y)(A: I), sym=foo, params = (X: Y, A: I)
---
aldor/aldor/src/absyn.c | 16 ++++++++++++++++
aldor/aldor/src/absyn.h | 5 ++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/aldor/aldor/src/absyn.c b/aldor/aldor/src/absyn.c
index aef1cfbba..92c9d228a 100644
--- a/aldor/aldor/src/absyn.c
+++ b/aldor/aldor/src/absyn.c
@@ -1095,6 +1095,22 @@ abCopyApplyArg(AbSyn ab)
return ab;
}
+AbSyn
+abNewDefineLhs(Symbol sym, AbSynList params)
+{
+ AbSynList pl, revParams;
+ AbSyn abd;
+
+ abd = abNewId(sposNone, sym);
+ revParams = listReverse(AbSyn)(params);
+ for (pl = revParams; pl; pl = cdr(pl))
+ abd = abNewApplyOfComma(abd, car(pl));
+ listFree(AbSyn)(revParams);
+
+ return abd;
+}
+
+
/*
* Return a singleton, otherwise alloc node and fill.
*/
diff --git a/aldor/aldor/src/absyn.h b/aldor/aldor/src/absyn.h
index 66ab7f65b..9c566df94 100644
--- a/aldor/aldor/src/absyn.h
+++ b/aldor/aldor/src/absyn.h
@@ -1123,7 +1123,10 @@ extern AbSyn abOneOrNewOfList (AbSynTag t, AbSynList args);
/*
* Return a singleton or make a node from a list of many parts.
*/
-
+extern AbSyn abNewDefineLhs (Symbol sym, AbSynList params);
+ /*
+ * Return a new form for the define lhs (eg Foo(X: I)(Y: I))
+ */
extern AbSyn abNewDocTextOfList (TokenList);
/*
* Construct a document text node from a list of doc tokens.
From e9ba41d3106a7b782a53ba492b3eafe31769716b Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 24 Jun 2017 21:20:54 +0100
Subject: [PATCH 174/352] tinfer.c: Use abNewDefineLHS
- no other changes, just a cleanup
---
aldor/aldor/src/tinfer.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/aldor/aldor/src/tinfer.c b/aldor/aldor/src/tinfer.c
index 987a3e603..9372200d7 100644
--- a/aldor/aldor/src/tinfer.c
+++ b/aldor/aldor/src/tinfer.c
@@ -1614,11 +1614,7 @@ tiTfThird1(Stab stab, TFormUses tfu, TForm tf, AbSynList params)
AbSynList pl;
Stab nstab = (abStab(abw) ? abStab(abw) : stab);
- abd = abNewId(sposNone, sym);
- params = listNReverse(AbSyn)(params);
- for (pl = params; pl; pl = cdr(pl))
- abd = abNewApplyOfComma(abd, car(pl));
- params = listNReverse(AbSyn)(params);
+ abd = abNewDefineLhs(sym, params);
tfd = tiGetTForm(stab, abd);
pp = symeNewExport(ssymSelfSelf, tfd, car(nstab));
symeSetDefault(pp);
@@ -1735,11 +1731,7 @@ tiTfCategory1(Stab stab, TFormUses tfu, TForm tf, AbSynList params)
if (asyme) {
Stab istab = (params ? stab : nstab);
- abd = abNewId(sposNone, sym);
- params = listNReverse(AbSyn)(params);
- for (pl = params; pl; pl = cdr(pl))
- abd = abNewApplyOfComma(abd, car(pl));
- params = listNReverse(AbSyn)(params);
+ abd = abNewDefineLhs(sym, params);
tfd = tfSyntaxFrAbSyn(istab, abd);
tfd = tfDefineOfType(tfd);
xsyme = stabDefExtend(nstab, ssymSelf, tfd);
From 3b43b7611d86a369da010a34afc827ea7b935ea8 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 31 Dec 2017 15:51:16 +0000
Subject: [PATCH 175/352] stab.c: clean formatting of some comments
---
aldor/aldor/src/stab.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/aldor/aldor/src/stab.h b/aldor/aldor/src/stab.h
index 07bae5afa..e43d8acbe 100644
--- a/aldor/aldor/src/stab.h
+++ b/aldor/aldor/src/stab.h
@@ -78,9 +78,9 @@ struct stabLevel {
Table table; /* used for large lvls */
} tformsUsed;
- TFormList tformsUnused; /* registered but unused */
- SymeList boundSymes; /* List of bound symes */
- SymeList extendSymes; /* List of extend symes */
+ TFormList tformsUnused; /* registered but unused */
+ SymeList boundSymes; /* List of bound symes */
+ SymeList extendSymes; /* List of extend symes */
};
/******************************************************************************
From 39dd7b45ee0564fe36b7e9567f5e6120b1b9cb10 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Mon, 14 Aug 2017 20:22:51 +0100
Subject: [PATCH 176/352] sefo.c: Need to check free vars on substitution
tforms
---
aldor/aldor/src/sefo.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/aldor/aldor/src/sefo.c b/aldor/aldor/src/sefo.c
index 6b0fc1d30..d2d02070c 100644
--- a/aldor/aldor/src/sefo.c
+++ b/aldor/aldor/src/sefo.c
@@ -2588,11 +2588,13 @@ tformFreeVars0(TForm *pa, TForm parent, TForm tf)
if (tfIsSubst(tf) && tfFVars(tf) == NULL) {
TForm arg = tfSubstArg(tf);
+
if (sstTFormIsMarked(arg)) {
*pa = sfvCommonAncestor(*pa, arg);
return;
}
tformFreeVars(arg);
+ abSubFreeVars(tfSubstSigma(tf));
tfSetFVars(tf, freeVarSubst0(tfSubstSigma(tf), tfFVars(arg)));
sefoFreeDEBUG(dbOut, "FV(subst) %pTForm = %pFreeVar\n",
tf, tf->fv);
From 304a5cc3ad3eca7820667215cf78a1dd3228a8c8 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Mon, 14 Aug 2017 20:23:24 +0100
Subject: [PATCH 177/352] terror.c: Remove a blank line to make error output
more parsable.
---
aldor/aldor/src/terror.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/terror.c b/aldor/aldor/src/terror.c
index 360065bd7..c9b094c36 100644
--- a/aldor/aldor/src/terror.c
+++ b/aldor/aldor/src/terror.c
@@ -1612,7 +1612,7 @@ bputBadArgType0(TRejectInfo trInfo, Stab stab, Buffer obuf, AbSyn ab, AbSyn op,
}
else
bufPrintf(obuf, fmt, argN+1, fmtOp);
- bufPrintf(obuf, "\n");
+ /*bufPrintf(obuf, "\n");*/
if (comsgOkDetails()) {
abArgi = argf(ab, trArgN(trFirst(trInfo)));
From 054ab0e37a4712bbec9a59bba69ec4bce6c979f8 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Mon, 14 Aug 2017 20:23:48 +0100
Subject: [PATCH 178/352] tform.c: Note a few things - this is really a todo
list before the next release
---
aldor/aldor/src/tform.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/aldor/aldor/src/tform.c b/aldor/aldor/src/tform.c
index 8a5b94112..348d5e7b4 100644
--- a/aldor/aldor/src/tform.c
+++ b/aldor/aldor/src/tform.c
@@ -1,3 +1,21 @@
+/* Some issues:
+1. Rep == Record(c: Cross(T: TFormSubType, T))
+
+ import from Rep
+ anyTForm(T: TFormSubType, t: T): % == per [pair(T, t)]
+
+ local unwrap(atf: %): (T: TFormSubType, t: T) ==
+ pp: Cross(T: TFormSubType, t: T) == rep(atf).c
+ pp
+
+ local pair(T: TFormSubType, t: T): (T1: TFormSubType, t: T1) == (T, t)
+
+ -- local functions aren't needed
+
+2. Rep == Foo -> Bar
+ maps are not equal to defined constants
+*/
+
/*****************************************************************************
*
* tform.c: Type forms.
From a8bb9e957a6938f4c83c73ee53f5b134a8fa79e5 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 17:21:50 +0100
Subject: [PATCH 179/352] javaobj.c: Consistent variable names
---
aldor/aldor/src/java/javaobj.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/aldor/aldor/src/java/javaobj.c b/aldor/aldor/src/java/javaobj.c
index abcce3214..7a2a6eb85 100644
--- a/aldor/aldor/src/java/javaobj.c
+++ b/aldor/aldor/src/java/javaobj.c
@@ -10,16 +10,16 @@ local void jco0Indent(JavaCodePContext ctxt);
JavaCode
jcoNewNode(JavaCodeClass clss, int argc)
{
- JavaCode jc = (JavaCode) (stoAlloc( (int) OB_JCode,
+ JavaCode jco = (JavaCode) (stoAlloc( (int) OB_JCode,
fullsizeof(struct jcoNode, argc, JavaCode)));
assert(clss);
- jcoTag(jc) = JCO_JAVA;
- jcoClass(jc) = clss;
- jcoPos(jc) = sposNone;
- jc->node.argc = argc;
+ jcoTag(jco) = JCO_JAVA;
+ jcoClass(jco) = clss;
+ jcoPos(jco) = sposNone;
+ jco->node.argc = argc;
- return jc;
+ return jco;
}
JavaCode
From 5f4e834f6728189c89c754cf07a384c6296e7b62 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 17:22:04 +0100
Subject: [PATCH 180/352] javaobj.c: Whitespace fix.
---
aldor/aldor/src/java/javaobj.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/java/javaobj.c b/aldor/aldor/src/java/javaobj.c
index 7a2a6eb85..3b18bb496 100644
--- a/aldor/aldor/src/java/javaobj.c
+++ b/aldor/aldor/src/java/javaobj.c
@@ -54,7 +54,7 @@ jcoNewLiteral(JavaCodeClass clss, String txt)
}
-JavaCode
+JavaCode
jcoNewImport(JavaCodeClass clss, String pkg, String name, Bool isImported)
{
JavaCode jco;
From c30a7acd94c2fc9b3ca4309d1db98e9c0c530eb1 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 17:23:55 +0100
Subject: [PATCH 181/352] javacode.c: Add jcPackage, jcImport
---
aldor/aldor/src/java/javacode.c | 16 ++++++++++++++++
aldor/aldor/src/java/javacode.h | 3 +++
2 files changed, 19 insertions(+)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index 1d0e168a2..ac9e7e919 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -1330,6 +1330,22 @@ jcCasePrint(JavaCodePContext ctxt, JavaCode code)
jcoPContextWrite(ctxt, ": ");
}
+/*
+ * :: Import, Package
+ */
+
+JavaCode
+jcImport(JavaCode arg)
+{
+ return jcSpaceSeqV(2, jcKeyword(symInternConst("import")), arg);
+}
+
+JavaCode
+jcPackage(JavaCode arg)
+{
+ return jcSpaceSeqV(2, jcKeyword(symInternConst("package")), arg);
+}
+
/*
* :: Throw, catch
*/
diff --git a/aldor/aldor/src/java/javacode.h b/aldor/aldor/src/java/javacode.h
index a0007305c..e4e570055 100644
--- a/aldor/aldor/src/java/javacode.h
+++ b/aldor/aldor/src/java/javacode.h
@@ -99,6 +99,9 @@ extern JavaCode jcReturnVoid();
extern JavaCode jcBreak(JavaCode label);
extern JavaCode jcContinue(JavaCode label);
+extern JavaCode jcPackage(JavaCode pkgName);
+extern JavaCode jcImport(JavaCode type);
+
extern JavaCode jcBlock(JavaCode l);
extern JavaCode jcBlockNoNL(JavaCode body);
extern JavaCode jcIf(JavaCode test, JavaCode stmt);
From 9abde177733b8a46cfe188ccc992f7034f36fbb8 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 17:25:36 +0100
Subject: [PATCH 182/352] genjava.c: Use jcImport
---
aldor/aldor/src/java/genjava.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/java/genjava.c b/aldor/aldor/src/java/genjava.c
index c8c201065..45a0d65ed 100644
--- a/aldor/aldor/src/java/genjava.c
+++ b/aldor/aldor/src/java/genjava.c
@@ -291,7 +291,7 @@ gj0CollectImports(JavaCode clss)
JavaCodeList tmp = imps;
while (tmp) {
JavaCode id = car(tmp);
- JavaCode stmt = jcStatement(jcSpaceSeqV(2, jcId(strCopy("import")), id));
+ JavaCode stmt = jcStatement(jcImport(id));;
ids = listCons(JavaCode)(stmt, ids);
tmp = cdr(tmp);
}
From 5d412005478b7b6cbc369ee094f43ba7e574ca02 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 17:26:31 +0100
Subject: [PATCH 183/352] genjava.c: Remove ';;'
---
aldor/aldor/src/java/genjava.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/src/java/genjava.c b/aldor/aldor/src/java/genjava.c
index 45a0d65ed..553bb8e1d 100644
--- a/aldor/aldor/src/java/genjava.c
+++ b/aldor/aldor/src/java/genjava.c
@@ -2572,7 +2572,7 @@ local JavaCode
gj0EInfo(Foam foam)
{
JavaCode stmt;
- Foam env = foam->foamEInfo.env;;
+ Foam env = foam->foamEInfo.env;
stmt = jcApplyMethodV(gj0Gen(env),
jcId(strCopy("getInfo")),
@@ -2584,7 +2584,7 @@ local JavaCode
gj0EInfoSet(Foam foam, Foam rhs)
{
JavaCode stmt;
- Foam env = foam->foamEInfo.env;;
+ Foam env = foam->foamEInfo.env;
stmt = jcApplyMethodV(gj0Gen(env),
jcId(strCopy("setInfo")),
From 6e77575b803c2e3a857a090ef50258e4430e40a6 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 30 Sep 2017 17:15:51 +0100
Subject: [PATCH 184/352] gf_fortran.c: Remove ';;'
---
aldor/aldor/src/gf_fortran.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/src/gf_fortran.c b/aldor/aldor/src/gf_fortran.c
index b4168b161..420510f12 100644
--- a/aldor/aldor/src/gf_fortran.c
+++ b/aldor/aldor/src/gf_fortran.c
@@ -1248,7 +1248,7 @@ gen0ReadPointerTo(FoamTag tag, Foam foam)
case FOAM_SFlo:
return gen0ReadFloatRecValue(tmpfoam);
case FOAM_DFlo:
- return gen0DoubleValue(tmpfoam);;
+ return gen0DoubleValue(tmpfoam);
default:
return tmpfoam;
}
@@ -1273,7 +1273,7 @@ gen0WritePointerTo(FoamTag tag, Foam dst, Foam foam)
case FOAM_SFlo:
return gen0WriteFloatRecValue(dst, tmpfoam);
case FOAM_DFlo:
- return gen0WriteDoubleValue(dst, tmpfoam);;
+ return gen0WriteDoubleValue(dst, tmpfoam);
default:
return dst;
}
From 8a376c6c568c57de6b4c1e9f087f067bcab98b34 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 30 Sep 2017 17:16:05 +0100
Subject: [PATCH 185/352] store.c: Remove ';;'
---
aldor/aldor/src/store.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/store.c b/aldor/aldor/src/store.c
index 23883b243..6c65341f4 100644
--- a/aldor/aldor/src/store.c
+++ b/aldor/aldor/src/store.c
@@ -830,7 +830,7 @@ pgmapExtend(Length count, PgKind kind)
PgInfo *oend;
Length i;
- if (!pgmapNeed(pgMapSize + count)) return 0;;
+ if (!pgmapNeed(pgMapSize + count)) return 0;
oend = pgMap + pgMapSize;
From 5fddda43f60da5dd1722ad03c60beca42704a789 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 17:33:26 +0100
Subject: [PATCH 186/352] javacode.c: Reformat javadoc comment
/*
* Text
*/
Seems reasonable.
---
aldor/aldor/src/java/javacode.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index ac9e7e919..a8c65f5e3 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -622,10 +622,10 @@ jcComment(String comment)
local void
jcJavaDocPrint(JavaCodePContext ctxt, JavaCode code)
{
- String s = strReplace(jcoLiteral(code), "\n", "\n *");
- jcoPContextWrite(ctxt, "/** ");
+ String s = strReplace(jcoLiteral(code), "\n", "\n * ");
+ jcoPContextWrite(ctxt, "/**\n * ");
jcoPContextWrite(ctxt, s);
- jcoPContextWrite(ctxt, "*/");
+ jcoPContextWrite(ctxt, "\n */");
strFree(s);
}
From af09717e7fe5908765564bd6f29b41ba4a27e374 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 18:29:51 +0100
Subject: [PATCH 187/352] javacode.c: Add functions to convert ids to strings
---
aldor/aldor/src/java/javacode.c | 19 +++++++++++++++++++
aldor/aldor/src/java/javacode.h | 4 ++++
2 files changed, 23 insertions(+)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index a8c65f5e3..419582e0d 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -666,6 +666,19 @@ jcImportedStaticId(String pkg, String name)
return jcoNewImport(jc0ClassObj(JCO_CLSS_ImportedStatic), pkg, name, false);
}
+String
+jcImportedIdName(JavaCode id)
+{
+ return jcoImportId(id);
+}
+
+String
+jcImportedIdPkg(JavaCode id)
+{
+ return jcoImportPkg(id);
+}
+
+
local void
jcImportPrint(JavaCodePContext ctxt, JavaCode code)
{
@@ -853,6 +866,12 @@ jcId(String name)
return jcoNewLiteral(jc0ClassObj(JCO_CLSS_Id), name);
}
+String
+jcIdName(JavaCode id)
+{
+ return jcoLiteral(id);
+}
+
local SExpr
jcIdSExpr(JavaCode code)
{
diff --git a/aldor/aldor/src/java/javacode.h b/aldor/aldor/src/java/javacode.h
index e4e570055..43a622d5a 100644
--- a/aldor/aldor/src/java/javacode.h
+++ b/aldor/aldor/src/java/javacode.h
@@ -157,5 +157,9 @@ extern SExpr jcNodeSExpr(JavaCode code);
extern void jcNodePrint(JavaCodePContext ctxt, JavaCode code);
extern Bool jcIsLegalClassName(String word);
+extern String jcImportedIdName(JavaCode);
+extern String jcImportedIdPkg(JavaCode);
+
+extern String jcIdName(JavaCode);
#endif
From 0d0f788c3ffeffd65c2b6f0ba48726747bca6248 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 20:13:45 +0100
Subject: [PATCH 188/352] gf_java: Rename java conversion functions
- to/fromJava seem better
---
aldor/aldor/lib/libfoamlib/al/bool.as | 8 ++++----
aldor/aldor/lib/libfoamlib/al/sinteger.as | 8 ++++----
aldor/aldor/src/gf_java.c | 8 ++++----
aldor/aldor/src/spesym.c | 8 ++++----
aldor/aldor/src/spesym.h | 4 ++--
aldor/aldor/src/tform.c | 8 ++++----
6 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/aldor/aldor/lib/libfoamlib/al/bool.as b/aldor/aldor/lib/libfoamlib/al/bool.as
index 506871d69..75e0e6fa4 100644
--- a/aldor/aldor/lib/libfoamlib/al/bool.as
+++ b/aldor/aldor/lib/libfoamlib/al/bool.as
@@ -23,8 +23,8 @@ extend Boolean: Join(
false: %; ++ false is the constant representing logical falsity.
true: %; ++ true is the constant representing logical truth.
- java: % -> BBool;
- avaj: BBool -> %;
+ toJava: % -> BBool;
+ fromJava: BBool -> %;
}
== add {
@@ -54,8 +54,8 @@ extend Boolean: Join(
max(a: %, b: %): % == a \/ b;
min(a: %, b: %): % == a /\ b;
- java(i: %): BBool == rep i;
- avaj(i: BBool): % == per i;
+ toJava(i: %): BBool == rep i;
+ fromJava(i: BBool): % == per i;
test(b: %): Boolean == b;
diff --git a/aldor/aldor/lib/libfoamlib/al/sinteger.as b/aldor/aldor/lib/libfoamlib/al/sinteger.as
index 96f8df6c4..de77c04e9 100644
--- a/aldor/aldor/lib/libfoamlib/al/sinteger.as
+++ b/aldor/aldor/lib/libfoamlib/al/sinteger.as
@@ -27,8 +27,8 @@ extend SingleInteger: Join(
mod_/: (%,%,%)-> %;
mod_^: (%,%,%)-> %;
- java: % -> BSInt;
- avaj: BSInt -> %;
+ toJava: % -> BSInt;
+ fromJava: BSInt -> %;
coerce: % -> String;
export from Segment %;
@@ -48,8 +48,8 @@ extend SingleInteger: Join(
#: Integer == (convert rep max - convert rep min + 1)::Integer;
- java(i: %): BSInt == rep i;
- avaj(i: BSInt): % == per i;
+ toJava(i: %): BSInt == rep i;
+ fromJava(i: BSInt): % == per i;
integer (l:Literal): % == per convert (l pretend BArr);
zero? (i: %): Boolean == zero? (rep i)::Boolean;
diff --git a/aldor/aldor/src/gf_java.c b/aldor/aldor/src/gf_java.c
index be7db670c..baf3a2f8d 100644
--- a/aldor/aldor/src/gf_java.c
+++ b/aldor/aldor/src/gf_java.c
@@ -262,7 +262,7 @@ gfjProgAddParams(TForm tf)
* :: Java representation
*
* Java objects are represented as Foam Arrays - these become Object in java.
- * Aldor types used in Java imports are assumed to have java and ajav methods
+ * Aldor types used in Java imports are assumed to have toJava and fromJava methods
* which convert to and from java respectively.
*/
local FoamTag
@@ -272,7 +272,7 @@ gfjPCallFoamType(TForm tf)
return FOAM_Arr;
}
else {
- Syme javaToSelf = tfGetDomImport(tf, symString(ssymTheJavaDecoder),
+ Syme javaToSelf = tfGetDomImport(tf, symString(ssymTheFromJava),
tfIsJavaDecoder);
TForm convTf = symeType(javaToSelf);
tfFollow(convTf);
@@ -289,7 +289,7 @@ gfjPCallFoamToJava(TForm tf, Foam foam)
}
else {
Syme selfToJava = tfGetDomImport(tf,
- symString(ssymTheJava),
+ symString(ssymTheToJava),
tfIsJavaEncoder);
FoamTag type = gen0Type(tfMapRetN(symeType(selfToJava), 0), NULL);
Foam call;
@@ -308,7 +308,7 @@ gfjPCallJavaToFoam(TForm tf, Foam foam)
}
else {
Syme javaToSelf = tfGetDomImport(tf,
- symString(ssymTheJavaDecoder),
+ symString(ssymTheFromJava),
tfIsJavaDecoder);
Foam call;
call = gen0ExtendSyme(javaToSelf);
diff --git a/aldor/aldor/src/spesym.c b/aldor/aldor/src/spesym.c
index 9fa408691..552f657ea 100644
--- a/aldor/aldor/src/spesym.c
+++ b/aldor/aldor/src/spesym.c
@@ -74,8 +74,8 @@ Symbol ssymArrow,
ssymTheExplode,
ssymTheFloat,
ssymTheInteger,
- ssymTheJava,
- ssymTheJavaDecoder,
+ ssymTheToJava,
+ ssymTheFromJava,
ssymTheGenerator,
ssymTheStdout,
ssymTheNew,
@@ -214,8 +214,8 @@ ssymInit(void)
ssymTheExplode = symIntern("explode");
ssymTheFloat = symIntern("float");
ssymTheInteger = symIntern("integer");
- ssymTheJava = symIntern("java");
- ssymTheJavaDecoder= symIntern("avaj");
+ ssymTheToJava = symIntern("toJava");
+ ssymTheFromJava = symIntern("fromJava");
ssymTheGenerator = symIntern("generator");
ssymTheNew = symIntern("new");
ssymTheRawRecord = symIntern("rawrecord");
diff --git a/aldor/aldor/src/spesym.h b/aldor/aldor/src/spesym.h
index d9717f284..13d2c27f7 100644
--- a/aldor/aldor/src/spesym.h
+++ b/aldor/aldor/src/spesym.h
@@ -82,8 +82,8 @@ extern Symbol ssymArrow,
ssymTheFloat,
ssymTheGenerator,
ssymTheInteger,
- ssymTheJava,
- ssymTheJavaDecoder,
+ ssymTheToJava,
+ ssymTheFromJava,
ssymTheNew,
ssymTheRawRecord,
ssymTheRecord,
diff --git a/aldor/aldor/src/tform.c b/aldor/aldor/src/tform.c
index 348d5e7b4..66f94d811 100644
--- a/aldor/aldor/src/tform.c
+++ b/aldor/aldor/src/tform.c
@@ -8136,11 +8136,11 @@ tfJavaCheckArg(ErrorSet errors, TForm arg)
if (tfIsJavaImport(arg))
return;
- enc = tfGetDomExport(arg, symString(ssymTheJava), tfIsJavaEncoder);
- dec = tfGetDomExport(arg, symString(ssymTheJavaDecoder), tfIsJavaDecoder);
- errorSetPrintf(errors, dec != NULL, "The domain %s must export java: %% -> ?",
+ enc = tfGetDomExport(arg, symString(ssymTheToJava), tfIsJavaEncoder);
+ dec = tfGetDomExport(arg, symString(ssymTheFromJava), tfIsJavaDecoder);
+ errorSetPrintf(errors, dec != NULL, "The domain %s must export toJava: %% -> ?",
abPretty(tfExpr(arg)));
- errorSetPrintf(errors, enc != NULL, "The domain %s must export avaj: ? -> %%",
+ errorSetPrintf(errors, enc != NULL, "The domain %s must export fromJava: ? -> %%",
abPretty(tfExpr(arg)));
}
From 60fe27724f912ac1717c23990f9d4c239063a7f9 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 26 Aug 2017 20:17:37 +0100
Subject: [PATCH 189/352] foam.c: Add DDecl tag for java classes
---
aldor/aldor/src/foam.c | 1 +
aldor/aldor/src/foam.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/aldor/aldor/src/foam.c b/aldor/aldor/src/foam.c
index e46a191da..14db6a694 100644
--- a/aldor/aldor/src/foam.c
+++ b/aldor/aldor/src/foam.c
@@ -3662,6 +3662,7 @@ struct foamDDecl_info foamDDeclInfoTable[] = {
{ FOAM_DDecl_FortranSig, 0, "FortranSig" },
{ FOAM_DDecl_CSig, 0, "CSig" },
{ FOAM_DDecl_JavaSig, 0, "JavaSig" },
+ { FOAM_DDecl_JavaClass, 0, "JavaClass" },
};
/*****************************************************************************
diff --git a/aldor/aldor/src/foam.h b/aldor/aldor/src/foam.h
index 833537da3..ea845cb46 100644
--- a/aldor/aldor/src/foam.h
+++ b/aldor/aldor/src/foam.h
@@ -467,6 +467,7 @@ enum foamDDeclTag {
FOAM_DDecl_FortranSig,
FOAM_DDecl_CSig,
FOAM_DDecl_JavaSig,
+ FOAM_DDecl_JavaClass,
FOAM_DDECL_LIMIT
};
From 77becfa0ba66a75fdba54facbc0900849341a04a Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 5 Sep 2017 19:55:27 +0100
Subject: [PATCH 190/352] java: Whitespace, comments cleanup
---
aldor/aldor/lib/java/src/foamj/AbstractValue.java | 2 +-
aldor/aldor/lib/java/src/foamj/FoamJ.java | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/aldor/aldor/lib/java/src/foamj/AbstractValue.java b/aldor/aldor/lib/java/src/foamj/AbstractValue.java
index 236dd6512..11845a069 100644
--- a/aldor/aldor/lib/java/src/foamj/AbstractValue.java
+++ b/aldor/aldor/lib/java/src/foamj/AbstractValue.java
@@ -62,4 +62,4 @@ public Env toEnv() {
public byte toByte() {
throw new CastException(this);
}
-}
\ No newline at end of file
+}
diff --git a/aldor/aldor/lib/java/src/foamj/FoamJ.java b/aldor/aldor/lib/java/src/foamj/FoamJ.java
index a6a9bfcdc..df5486ac2 100644
--- a/aldor/aldor/lib/java/src/foamj/FoamJ.java
+++ b/aldor/aldor/lib/java/src/foamj/FoamJ.java
@@ -6,8 +6,6 @@ public class FoamJ {
/**
* Array type - rely on casting to retract to base type
- *
- * @author pab
*/
static class Array extends AbstractValue implements Value, Word {
private Object arr;
From 100a79cdf0fa3b42488ecd111ec96200fd38de77 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 5 Sep 2017 20:00:25 +0100
Subject: [PATCH 191/352] aldor/test: Makefile verbose rules incorrect.
Off by an underscore..
---
aldor/aldor/test/Makefile.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/test/Makefile.in b/aldor/aldor/test/Makefile.in
index 9906de123..327a68c7e 100644
--- a/aldor/aldor/test/Makefile.in
+++ b/aldor/aldor/test/Makefile.in
@@ -48,8 +48,8 @@ AM_V_JAVAC = $(am__v_JAVAC_$(V))
am__v_JAVAC_ = $(am__v_JAVAC_$(AM_DEFAULT_VERBOSITY))
am__v_JAVAC_0 = @echo " JAVAC " $@;
-AM_V_ALDOR_JAVATEST = $(am__v_ALDOR_JAVATEST_$(V))
-am__v_ALDOR_JAVATEST = $(am__v_ALDOR_JAVATEST_$(AM_DEFAULT_VERBOSITY))
+AM_V_ALDOR_JAVATEST = $(am__v_ALDOR_JAVATEST_$(V))
+am__v_ALDOR_JAVATEST_ = $(am__v_ALDOR_JAVATEST_$(AM_DEFAULT_VERBOSITY))
am__v_ALDOR_JAVATEST_0 = @echo " ALDOR-JAVATEST " $@;
all: really-all
From 3d0a31fd2157fc7d9064a3c5f227d4f7a1a5f5e7 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 9 Sep 2017 16:13:30 +0100
Subject: [PATCH 192/352] lib/java: Add Java object for use by Foam.
---
.../lib/java/src/foamj/AbstractValue.java | 4 +++
aldor/aldor/lib/java/src/foamj/FoamJ.java | 29 +++++++++++++++++++
aldor/aldor/lib/java/src/foamj/Word.java | 13 +++++++++
3 files changed, 46 insertions(+)
diff --git a/aldor/aldor/lib/java/src/foamj/AbstractValue.java b/aldor/aldor/lib/java/src/foamj/AbstractValue.java
index 11845a069..ecde637fb 100644
--- a/aldor/aldor/lib/java/src/foamj/AbstractValue.java
+++ b/aldor/aldor/lib/java/src/foamj/AbstractValue.java
@@ -31,6 +31,10 @@ public Object toArray() {
throw new CastException(this);
}
+ public T toJavaObj() {
+ throw new CastException(this);
+ }
+
public Record toRecord() {
throw new CastException(this);
}
diff --git a/aldor/aldor/lib/java/src/foamj/FoamJ.java b/aldor/aldor/lib/java/src/foamj/FoamJ.java
index df5486ac2..53042481e 100644
--- a/aldor/aldor/lib/java/src/foamj/FoamJ.java
+++ b/aldor/aldor/lib/java/src/foamj/FoamJ.java
@@ -33,6 +33,35 @@ public String toString() {
}
+ /**
+ * JavaObj type - rely on casting to retract to base type
+ */
+ static public class JavaObj extends AbstractValue implements Value, Word {
+ private T obj;
+
+ JavaObj(T obj) {
+ this.obj = obj;
+ }
+
+ public T toJavaObj() {
+ return obj;
+ }
+
+ @Override
+ public Value toValue() {
+ return this;
+ }
+
+ public Word asWord() {
+ return this;
+ }
+
+ public String toString() {
+ return obj.toString();
+ }
+
+ }
+
/**
* a.
* T1 = (Add (Cast SInt x) 1)
diff --git a/aldor/aldor/lib/java/src/foamj/Word.java b/aldor/aldor/lib/java/src/foamj/Word.java
index f905a1b5b..2ef1ade71 100644
--- a/aldor/aldor/lib/java/src/foamj/Word.java
+++ b/aldor/aldor/lib/java/src/foamj/Word.java
@@ -19,6 +19,8 @@ public interface Word {
Object toArray();
+ T toJavaObj();
+
char toChar();
float toSFlo();
@@ -40,6 +42,13 @@ static public Object toArray(Word word) {
return word.toArray();
}
+ static public T toJavaObj(Word word) {
+ if (word == null)
+ return null;
+ else
+ return word.toJavaObj();
+ }
+
public static Word fromSInt(int x) {
return new SInt(x);
}
@@ -56,6 +65,10 @@ public static Word fromArray(Object x) {
return new Array(x);
}
+ public static Word fromJavaObj(T t) {
+ return new JavaObj(t);
+ }
+
public static Word fromBool(boolean b) {
return new Bool(b);
}
From 4bc0e034e1142b446e84ebf27da6c648e76acbfc Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 9 Sep 2017 18:02:31 +0100
Subject: [PATCH 193/352] java: Add Aldor string to Java string conversion
---
aldor/aldor/lib/java/Makefile.am | 2 +-
aldor/aldor/lib/java/src/foamj/Foam.java | 11 +++
aldor/aldor/lib/java/test/Makefile.in | 73 +++++++++++++++++++
aldor/aldor/lib/java/test/foamj/FoamTest.java | 15 ++++
aldor/configure.ac | 8 ++
aldor/m4/java-tests.m4 | 8 ++
6 files changed, 116 insertions(+), 1 deletion(-)
create mode 100644 aldor/aldor/lib/java/test/Makefile.in
create mode 100644 aldor/aldor/lib/java/test/foamj/FoamTest.java
create mode 100644 aldor/m4/java-tests.m4
diff --git a/aldor/aldor/lib/java/Makefile.am b/aldor/aldor/lib/java/Makefile.am
index 1bfdcf486..94c452302 100644
--- a/aldor/aldor/lib/java/Makefile.am
+++ b/aldor/aldor/lib/java/Makefile.am
@@ -1 +1 @@
-SUBDIRS=src
+SUBDIRS=src test
diff --git a/aldor/aldor/lib/java/src/foamj/Foam.java b/aldor/aldor/lib/java/src/foamj/Foam.java
index df61df524..13871750f 100644
--- a/aldor/aldor/lib/java/src/foamj/Foam.java
+++ b/aldor/aldor/lib/java/src/foamj/Foam.java
@@ -438,4 +438,15 @@ public static double atan2(double a, double b) {
return Math.atan2(a, b);
}
+ public static Word stringToJavaString(Word w) {
+ char[] arr = (char[]) w.toArray();
+ return new FoamJ.JavaObj(new String(arr, 0, arr.length-1));
+ }
+
+ public static Word javaStringToString(Word w) {
+ String s = (String) w.toJavaObj();
+ Word arr = Word.U.fromArray(("" + s + "\0").toCharArray());
+ return arr;
+ }
+
}
diff --git a/aldor/aldor/lib/java/test/Makefile.in b/aldor/aldor/lib/java/test/Makefile.in
new file mode 100644
index 000000000..a24153648
--- /dev/null
+++ b/aldor/aldor/lib/java/test/Makefile.in
@@ -0,0 +1,73 @@
+# ..From autoconf
+@SET_MAKE@
+
+VPATH = @srcdir@
+abs_top_builddir = @abs_top_builddir@
+srcdir = @srcdir@
+top_builddir = @top_builddir@
+builddir = @builddir@
+abs_builddir = @abs_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+subdir = aldor/lib/java/test
+HAS_JUNIT = @HAS_JUNIT@
+JUNIT_JAR = @JUNIT_JAR@
+
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ '; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ ;; \
+ esac;
+
+buildfiles := $(shell cd $(srcdir); find foamj -type f -name \*Test.java)
+@HAS_JUNIT_TRUE@tests := $(patsubst %,test-%,$(subst /,.,$(subst .java,,$(buildfiles))))
+
+outdir := $(abs_builddir)/classes
+jarfile := $(abs_builddir)/foamj-test.jar
+
+.PHONY: $(tests)
+
+$(tests): test-%: $(jarfile)
+ java -cp $(jarfile):$(abs_builddir)/../src/foamj.jar:$(JUNIT_JAR) \
+ org.junit.runner.JUnitCore $*
+
+test-junit: $(tests)
+.PHONY: test-junit
+
+check: test-junit
+
+# Build directly to a .jar file (easier than tracking .class files)
+$(jarfile): $(buildfiles)
+ mkdir -p $(outdir)
+ (cd $(srcdir); javac -cp $(abs_builddir)/../src/foamj.jar:$(JUNIT_JAR) -g -d $(outdir) $(buildfiles))
+ (cd $(outdir); jar cf $@ .)
+
+all:
+ echo $<
+
+#
+# :: Automake requires this little lot
+#
+mostlyclean:
+ rm -rf $(outdir)
+ rm -f $(jarfile)
+
+clean: mostlyclean
+
+distclean: clean
+ rm Makefile
+maintainer-clean: distclean
+
+
+EMPTY_AUTOMAKE_TARGETS = dvi pdf ps info html tags ctags
+EMPTY_AUTOMAKE_TARGETS += install install-data install-exec uninstall
+EMPTY_AUTOMAKE_TARGETS += install-dvi install-html install-info install-ps install-pdf
+EMPTY_AUTOMAKE_TARGETS += installdirs
+EMPTY_AUTOMAKE_TARGETS += check installcheck
+
+.PHONY: $(EMPTY_AUTOMAKE_TARGETS)
+$(EMPTY_AUTOMAKE_TARGETS):
+
diff --git a/aldor/aldor/lib/java/test/foamj/FoamTest.java b/aldor/aldor/lib/java/test/foamj/FoamTest.java
new file mode 100644
index 000000000..d589e0207
--- /dev/null
+++ b/aldor/aldor/lib/java/test/foamj/FoamTest.java
@@ -0,0 +1,15 @@
+package foamj;
+
+import org.junit.*;
+import foamj.Word;
+
+public class FoamTest {
+
+ @Test
+ public void testToJavaString() {
+ Word w = new FoamJ.JavaObj("hello");
+ Word aldorString = Foam.javaStringToString(w);
+ Assert.assertEquals("hello", Foam.stringToJavaString(aldorString).toJavaObj());
+ }
+
+}
diff --git a/aldor/configure.ac b/aldor/configure.ac
index 9917ce186..1166e747f 100644
--- a/aldor/configure.ac
+++ b/aldor/configure.ac
@@ -36,6 +36,10 @@ AC_ARG_ENABLE([java],
[BUILD_JAVA=false],
[BUILD_JAVA=true])
+AC_ARG_WITH([java-junit],
+ [AS_HELP_STRING([--with-java-junit], [specify location of junit jar file])],
+ [JUNIT_JAR=$withval], [JUNIT_JAR=/usr/share/java/junit4.jar])
+
AM_CONDITIONAL(BUILD_JAVA, test $JAVAC != no -a $BUILD_JAVA = true)
AC_ARG_WITH([boehm-gc],
@@ -58,6 +62,8 @@ AC_SUBST([LIBTOOL_DEPS])
# Enable extra warnings and -Werror if supported.
ALDOR_ERROR_ON_WARN
+ALDOR_JAVA_TESTS
+
ALDOR_GIT_BUILD_ID
# Generate Makefiles
@@ -70,12 +76,14 @@ AC_CONFIG_FILES(
aldor/src/Makefile
aldor/src/opsys_port.h
aldor/lib/Makefile
+
aldor/lib/libfoamlib/Makefile
aldor/lib/libfoamlib/al/Makefile
aldor/lib/libfoam/Makefile
aldor/lib/libfoam/al/Makefile
aldor/lib/java/Makefile
aldor/lib/java/src/Makefile
+ aldor/lib/java/test/Makefile
aldor/test/Makefile
aldor/tools/Makefile
aldor/tools/unix/Makefile
diff --git a/aldor/m4/java-tests.m4 b/aldor/m4/java-tests.m4
new file mode 100644
index 000000000..c1c981770
--- /dev/null
+++ b/aldor/m4/java-tests.m4
@@ -0,0 +1,8 @@
+# Find junit library, and if it exists, set JUNIT_JAR to its location
+AC_DEFUN([ALDOR_JAVA_TESTS],
+[AC_CHECK_FILE([$JUNIT_JAR],
+ [HAS_JUNIT=yes], [HAS_JUNIT=no])
+AC_SUBST([JUNIT_JAR])
+AC_SUBST([HAS_JUNIT])
+AM_CONDITIONAL(HAS_JUNIT, test $BUILD_JAVA = true -a $HAS_JUNIT != no)
+])
From b252eeb6d5651db9fc31766583347ed9f50f3a9a Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 9 Sep 2017 18:03:53 +0100
Subject: [PATCH 194/352] javaobj.c: jcoNewImport: Add assertions for non-null
arguments
---
aldor/aldor/src/java/javaobj.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/aldor/aldor/src/java/javaobj.c b/aldor/aldor/src/java/javaobj.c
index 3b18bb496..f0294a014 100644
--- a/aldor/aldor/src/java/javaobj.c
+++ b/aldor/aldor/src/java/javaobj.c
@@ -58,6 +58,9 @@ JavaCode
jcoNewImport(JavaCodeClass clss, String pkg, String name, Bool isImported)
{
JavaCode jco;
+ assert(pkg != NULL);
+ assert(name != NULL);
+
jco = (JavaCode) stoAlloc((int) OB_JCode, sizeof(struct jcoImport));
assert(clss && pkg && name);
From 49bd89be98f0dd04c5167adc67e5d288aa967e2c Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 9 Sep 2017 20:12:50 +0100
Subject: [PATCH 195/352] src/java: Add FOAM_JavaObj so we can represent java
objects in foam code.
---
aldor/aldor/src/foam.c | 5 +++
aldor/aldor/src/foam.h | 1 +
aldor/aldor/src/gf_java.c | 49 ++++++++++++++++++++++-------
aldor/aldor/src/java/genjava.c | 55 +++++++++++++++++++++++----------
aldor/aldor/src/java/javacode.c | 14 +++++++++
aldor/aldor/src/java/javacode.h | 1 +
aldor/aldor/src/of_deadv.c | 44 ++++++++++++++++++++++++++
aldor/aldor/src/of_util.c | 1 +
8 files changed, 142 insertions(+), 28 deletions(-)
diff --git a/aldor/aldor/src/foam.c b/aldor/aldor/src/foam.c
index 14db6a694..48a7a4459 100644
--- a/aldor/aldor/src/foam.c
+++ b/aldor/aldor/src/foam.c
@@ -1070,6 +1070,10 @@ foamAuditDecl(Foam decl)
if (fmt >= FOAM_DATA_LIMIT && fmt != FOAM_BInt)
foamAuditBadDecl(decl);
break;
+ case FOAM_JavaObj:
+ if (fmt >= faNumFormats)
+ foamAuditBadDecl(decl);
+ break;
case FOAM_Rec:
/*
TODO: Fix implicit exports so that they don't
@@ -3571,6 +3575,7 @@ struct foam_info foamInfoTable[] = {
{FOAM_PopEnv, 0,"PopEnv", 0, "", 0},
{FOAM_MFmt, 0,"MFmt", 2, "iC", 0},
{FOAM_RRFmt, 0,"RRFmt", 1, "C", 0},
+ {FOAM_JavaObj, 0,"JavaObj", 0, "", 0},
/* ========> FFO_ORIGIN (start of multi-format instructions) <======== */
diff --git a/aldor/aldor/src/foam.h b/aldor/aldor/src/foam.h
index ea845cb46..3dcfa792e 100644
--- a/aldor/aldor/src/foam.h
+++ b/aldor/aldor/src/foam.h
@@ -74,6 +74,7 @@ enum foamTag {
FOAM_PopEnv,
FOAM_MFmt, /* Indicate multiple values */
FOAM_RRFmt, /* Raw record (dynamic) format */
+ FOAM_JavaObj, /* Java things */
FOAM_CONTROL_LIMIT,
diff --git a/aldor/aldor/src/gf_java.c b/aldor/aldor/src/gf_java.c
index baf3a2f8d..7b4338ee4 100644
--- a/aldor/aldor/src/gf_java.c
+++ b/aldor/aldor/src/gf_java.c
@@ -16,12 +16,14 @@ local Foam gfjImportConstructor(Syme syme);
local Foam gfjImportStaticCall(Syme syme);
local FoamList gfjProgAddParams(TForm tf);
-local FoamTag gfjPCallFoamType(TForm tf);
+local FoamTag gfjPCallFoamType(TForm tf, AInt *pfmt);
local Foam gfjPCallFoamToJava(TForm tf, Foam foam);
local Foam gfjPCallJavaToFoam(TForm tf, Foam foam);
local AInt gfjPCallDecl(TForm tf, Bool);
local Foam gfjPCallDeclArg(TForm tf);
+local AInt gj0ClassDDecl(ForeignOrigin origin, String clsName);
+
void
gfjInit()
{
@@ -97,6 +99,7 @@ gfjImportApplyInner(Syme syme, AInt fmtNum)
FoamTag retType;
String fnName, globName;
AInt gnum, constnum;
+ AInt clsFmt;
constnum = gen0NumProgs;
@@ -105,6 +108,8 @@ gfjImportApplyInner(Syme syme, AInt fmtNum)
forg = symeForeign(esyme);
innerTf = tfMapRet(symeType(syme));
+ clsFmt = gj0ClassDDecl(forg, symeString(esyme));
+
globName = (forg->file ? strPrintf("%s.%s.%s",
forg->file, symeString(esyme), symeJavaApplyName(syme))
: strPrintf("%s.%s", symeString(esyme), symeJavaApplyName(syme)));
@@ -116,8 +121,8 @@ gfjImportApplyInner(Syme syme, AInt fmtNum)
prog = gen0ProgInitEmpty(fnName, NULL);
saved = gen0ProgSaveState(PT_ExFn);
- temp = gen0TempLocal0(FOAM_Arr, int0);
- gen0AddStmt(foamNewDef(foamCopy(temp), foamNewCast(FOAM_Arr, foamNewLex(1, int0))), NULL);
+ temp = gen0TempLocal0(FOAM_JavaObj, clsFmt);
+ gen0AddStmt(foamNewDef(foamCopy(temp), foamNewCast(FOAM_JavaObj, foamNewLex(1, int0))), NULL);
params = gfjProgAddParams(innerTf);
params = listCons(Foam)(foamCopy(temp), params);
@@ -133,7 +138,7 @@ gfjImportApplyInner(Syme syme, AInt fmtNum)
else {
Foam retval;
pcall = foamNewPCallOfList(FOAM_Proto_JavaMethod,
- gfjPCallFoamType(tfMapRet(innerTf)),
+ gfjPCallFoamType(tfMapRet(innerTf), NULL),
op, params);
retval = gfjPCallJavaToFoam(tfMapRet(innerTf), pcall);
gen0AddLexLevels(retval, 2);
@@ -181,7 +186,7 @@ gfjImportConstructor(Syme syme)
params = gfjProgAddParams(symeType(syme));
pcall = foamNewPCallOfList(FOAM_Proto_JavaConstructor,
- gfjPCallFoamType(exporter),
+ gfjPCallFoamType(exporter, NULL),
foamNewGlo(gnum), params);
gen0AddLexLevels(pcall, 1);
@@ -214,9 +219,14 @@ gfjImportStaticCall(Syme syme)
forg = symeForeign(esyme);
fnName = strCopy(symeString(syme));
- globName = strPrintf("%s.%s.%s", forg->file,
+ globName = forg->file == NULL
+ ? strPrintf("%s.%s",
+ symString(tfIdSym(exporter)),
+ symeString(syme))
+ : strPrintf("%s.%s.%s", forg->file,
symString(tfIdSym(exporter)),
symeString(syme));
+
constNum = gen0NumProgs;
gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme), false),
@@ -227,7 +237,7 @@ gfjImportStaticCall(Syme syme)
saved = gen0ProgSaveState(PT_ExFn);
params = gfjProgAddParams(symeType(syme));
- retType = gfjPCallFoamType(tfMapRet(symeType(syme)));
+ retType = gfjPCallFoamType(tfMapRet(symeType(syme)), NULL);
pcall = foamNewPCallOfList(FOAM_Proto_Java,
retType,
foamNewGlo(gnum), params);
@@ -261,22 +271,28 @@ gfjProgAddParams(TForm tf)
/*
* :: Java representation
*
- * Java objects are represented as Foam Arrays - these become Object in java.
* Aldor types used in Java imports are assumed to have toJava and fromJava methods
* which convert to and from java respectively.
*/
local FoamTag
-gfjPCallFoamType(TForm tf)
+gfjPCallFoamType(TForm tf, AInt *pfmt)
{
if (tfIsJavaImport(tf)) {
- return FOAM_Arr;
+ if (pfmt != NULL) {
+ Syme syme = tfIdSyme(tf);
+ TForm exporter = symeExporter(syme);
+ Syme esyme = tfIdSyme(exporter);
+ ForeignOrigin forg = symeForeign(esyme);
+ *pfmt = gj0ClassDDecl(forg, symeString(esyme));
+ }
+ return FOAM_JavaObj;
}
else {
Syme javaToSelf = tfGetDomImport(tf, symString(ssymTheFromJava),
tfIsJavaDecoder);
TForm convTf = symeType(javaToSelf);
tfFollow(convTf);
- return gen0Type(tfMapArg(convTf), NULL);
+ return gen0Type(tfMapArg(convTf), pfmt);
}
}
@@ -285,7 +301,7 @@ local Foam
gfjPCallFoamToJava(TForm tf, Foam foam)
{
if (tfIsJavaImport(tf)) {
- return foamNewCast(FOAM_Arr, foam);
+ return foamNewCast(FOAM_JavaObj, foam);
}
else {
Syme selfToJava = tfGetDomImport(tf,
@@ -362,3 +378,12 @@ gfjPCallDeclArg(TForm tf)
return decl;
}
+
+AInt
+gj0ClassDDecl(ForeignOrigin origin, String clsName)
+{
+ String name = origin->file == NULL ? strCopy(clsName): strPrintf("%s.%s", origin->file, clsName);
+ Foam decl = foamNewDecl(FOAM_Word, name, int0);
+
+ return gen0AddRealFormat(foamNewDDecl(FOAM_DDecl_JavaClass, decl, NULL));
+}
diff --git a/aldor/aldor/src/java/genjava.c b/aldor/aldor/src/java/genjava.c
index 553bb8e1d..a6b8d5855 100644
--- a/aldor/aldor/src/java/genjava.c
+++ b/aldor/aldor/src/java/genjava.c
@@ -157,6 +157,9 @@ local String gj0NameFrString(String fmName);
local JavaCodeList gj0ClassHeader(String className);
local String gj0InitVar(AInt idx);
+local JavaCode gj0TypeFrJavaObj(Foam format);
+
+
enum gjId {
GJ_INVALID = -1,
@@ -1138,12 +1141,24 @@ gj0TypeFrFmt(AInt id, AInt fmt)
return gj0Id(GJ_Object);
case FOAM_Values:
return gj0Id(GJ_Multi);
-
+ case FOAM_JavaObj:
+ if (fmt != 0 && fmt != emptyFormatSlot)
+ return gj0TypeFrJavaObj(gjContext->formats->foamDFmt.argv[fmt]);
+ else
+ return gj0Id(GJ_Object);
default:
return jcId(strCopy(foamStr(id)));
}
}
+local JavaCode
+gj0TypeFrJavaObj(Foam format)
+{
+ String txt = format->foamDDecl.argv[0]->foamDecl.id;
+ return jcImportedIdFrString(txt);
+}
+
+
local JavaCode
gj0TypeValueToObj(JavaCode val, FoamTag type, AInt fmt)
{
@@ -1268,6 +1283,10 @@ gj0TypeObjToValue(JavaCode val, FoamTag type, AInt fmt)
jcId(strCopy("U"))),
jcId(strCopy("fromByte")), 1,
val);
+ case FOAM_JavaObj:
+ return jcSpaceSeqV(2,
+ jcComment(strPrintf("asWord %d %d", type, fmt)),
+ val);
case FOAM_Env:
case FOAM_Clos:
case FOAM_Rec:
@@ -2971,7 +2990,7 @@ local JavaCode gj0CastObjToPtr(JavaCode jc, FoamTag type, AInt fmt);
local JavaCode
gj0Cast(Foam foam)
{
- return gj0CastFmt(foam, -1);
+ return gj0CastFmt(foam, emptyFormatSlot);
}
local JavaCode
@@ -2992,7 +3011,7 @@ gj0CastFmt(Foam foam, AInt cfmt)
return gj0CastObjToPtr(jc, iType, fmt);
}
else if (iType == FOAM_Word) {
- return gj0CastWordToObj(jc, type, fmt);
+ return gj0CastWordToObj(jc, type, cfmt);
}
else if (iType == type)
return jc;
@@ -3042,7 +3061,13 @@ gj0CastWordToObj(JavaCode jc, FoamTag type, AInt fmt)
case FOAM_Ptr:
return jc;
case FOAM_Arr:
- return jcApplyV(jcMemRef(gj0Id(GJ_FoamWord), jcId(strCopy("U.toArray"))), 1, jc);
+ return jcApplyMethodV(jcMemRef(gj0Id(GJ_FoamWord),
+ jcId(strCopy("U"))),
+ jcId(strCopy("toArray")), 1, jc);
+ case FOAM_JavaObj:
+ return jcApplyMethodV(jcMemRef(gj0Id(GJ_FoamWord),
+ jcId(strCopy("U"))),
+ jcId(strCopy("toJavaObj")), 1, jc);
default:
return jcCast(gj0TypeFrFmt(type, fmt), jc);
}
@@ -3110,6 +3135,11 @@ gj0CastObjToWord(JavaCode val, FoamTag type, AInt fmt)
jcId(strCopy("U"))),
jcId(strCopy("fromDFlo")),
listSingleton(JavaCode)(val));
+ case FOAM_JavaObj:
+ return jcApplyMethod(jcMemRef(gj0Id(GJ_FoamWord),
+ jcId(strCopy("U"))),
+ jcId(strCopy("fromJavaObj")),
+ listSingleton(JavaCode)(val));
case FOAM_Nil:
return val;
default:
@@ -3508,7 +3538,7 @@ gj0PCallJavaStatic(Foam foam)
{
JavaCodeList args;
Foam decl, op;
- String id, type, pkg;
+ String id, type;
op = foam->foamPCall.op;
@@ -3518,9 +3548,9 @@ gj0PCallJavaStatic(Foam foam)
args = gj0GenList(foam->foamPCall.argv, foamPCallArgc(foam));
strSplitLast(strCopy(decl->foamGDecl.id), '.', &type, &id);
- strSplitLast(type, '.', &pkg, &type);
+ JavaCode typeId = jcImportedIdFrString(type);
- return jcApply(jcMemRef(jcImportedId(pkg, type), jcId(id)),
+ return jcApply(jcMemRef(typeId, jcId(id)),
gj0PCallCastArgs(op, args));
}
@@ -3661,15 +3691,8 @@ gj0BCallApply(Foam foam)
inf = gj0BCallBValInfo(foam->foamBCall.op);
args = gj0GenList(foam->foamBCall.argv, foamArgc(foam)-1);
- p = strLastIndexOf(inf->c1, '.');
- if (p == NULL)
- tgtClss = jcId(strCopy(inf->c1));
- else {
- String pkg = strCopy(inf->c1);
- String id = strCopy(p+1);
- pkg[p-inf->c1] = '\0';
- tgtClss = jcImportedId(pkg, id);
- }
+ tgtClss = jcImportedIdFrString(inf->c1);
+
return jcApplyMethod(tgtClss, jcId(strCopy(inf->c2)), args);
}
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index 419582e0d..8e9c5e475 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -1664,3 +1664,17 @@ jcIsId(String word)
return true;
}
+
+JavaCode
+jcImportedIdFrString(String str)
+{
+ String p = strLastIndexOf(str, '.');
+ if (p == NULL) {
+ return jcId(strCopy(str));
+ }
+ else {
+ String pkg = strnCopy(str, p - str);
+ String id = strCopy(p+1);
+ return jcImportedId(pkg, id);
+ }
+}
diff --git a/aldor/aldor/src/java/javacode.h b/aldor/aldor/src/java/javacode.h
index 43a622d5a..6e8e9a885 100644
--- a/aldor/aldor/src/java/javacode.h
+++ b/aldor/aldor/src/java/javacode.h
@@ -159,6 +159,7 @@ extern void jcNodePrint(JavaCodePContext ctxt, JavaCode code);
extern Bool jcIsLegalClassName(String word);
extern String jcImportedIdName(JavaCode);
extern String jcImportedIdPkg(JavaCode);
+extern JavaCode jcImportedIdFrString(String str);
extern String jcIdName(JavaCode);
diff --git a/aldor/aldor/src/of_deadv.c b/aldor/aldor/src/of_deadv.c
index 21ffcd2ad..a289024b4 100644
--- a/aldor/aldor/src/of_deadv.c
+++ b/aldor/aldor/src/of_deadv.c
@@ -75,6 +75,9 @@ local void dvElimUnusedFormats (Foam unit);
local void dvRemoveNops (Foam ufoam);
local void dvRemoveSeqNops (Foam seq);
+local void dvMarkTypeFormats(Foam unit);
+local void dvMarkType(Foam decl);
+
Bool dvChanged;
DvUsage *dvFormatUsage;
@@ -149,6 +152,7 @@ dvElim(Foam unit)
dvChanged = false;
dvSetupUnit(unit);
dvMarkUnitUsage(unit);
+ dvMarkTypeFormats(unit);
dvElimUnused(unit);
count++;
@@ -254,6 +258,7 @@ dvMakeUsageVec(Foam ddecl)
* Top of recursive descent of the foam tree, starting at the file
* initialization program.
*/
+
local void
dvMarkUnitUsage(Foam unit)
{
@@ -270,6 +275,45 @@ dvMarkUnitUsage(Foam unit)
dvMarkExprUsage(dvDefs[i]);
}
+local void
+dvMarkTypeFormats(Foam unit)
+{
+ int i, j;
+ for (i=0; ifoamUnit.formats); i++) {
+ Foam ddecl = unit->foamUnit.formats->foamDFmt.argv[i];
+ for (j=0; jfoamDDecl.argv[j]);
+ }
+ }
+
+ for (i=0; ifoamUnit.defs); i++) {
+ Foam prog = dvDefs[i]->foamDef.rhs;
+ Foam ddecl;
+
+ if (foamTag(prog) != FOAM_Prog) continue;
+ if (foamOptInfo(prog)->dvState != DV_Checked) continue;
+
+ ddecl = prog->foamProg.locals;
+ for (j=0; jfoamDDecl.argv[j]);
+ }
+ ddecl = prog->foamProg.params;
+ for (j=0; jfoamDDecl.argv[j]);
+ }
+ }
+}
+
+local void
+dvMarkType(Foam decl)
+{
+ int j;
+ if (decl->foamDecl.type == FOAM_JavaObj) {
+ dvMarkWholeFormat(decl->foamDecl.format);
+ }
+}
+
/*
* Mark the usages in a program.
diff --git a/aldor/aldor/src/of_util.c b/aldor/aldor/src/of_util.c
index 00b956019..ef881e6c0 100644
--- a/aldor/aldor/src/of_util.c
+++ b/aldor/aldor/src/of_util.c
@@ -393,6 +393,7 @@ fpClearFormats(Foam ddecl)
decl->foamGDecl.format = emptyFormatSlot;
}
else if (decl->foamDecl.type != FOAM_Rec
+ && decl->foamDecl.type != FOAM_JavaObj
&& decl->foamDecl.type != FOAM_Arr
&& decl->foamDecl.type != FOAM_TR
&& decl->foamDecl.type != FOAM_NOp)
From 83613ac44372526bf309688c7e1184978de1cee2 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 31 Dec 2017 15:16:23 +0000
Subject: [PATCH 196/352] aldor/test: FIXUP remove generated rectest.java,
simple_j.java
---
aldor/aldor/test/rectest.java | 1074 --------------------------------
aldor/aldor/test/simple_j.java | 827 ------------------------
2 files changed, 1901 deletions(-)
delete mode 100644 aldor/aldor/test/rectest.java
delete mode 100644 aldor/aldor/test/simple_j.java
diff --git a/aldor/aldor/test/rectest.java b/aldor/aldor/test/rectest.java
deleted file mode 100644
index de8c62c2d..000000000
--- a/aldor/aldor/test/rectest.java
+++ /dev/null
@@ -1,1074 +0,0 @@
-/*...
-(nlseq
- (statement (spaceseq "import" (importid "foamj" "EnvRecord")))
- (statement (spaceseq "import" (importid "foamj" "Record")))
- (statement (spaceseq "import" (importid "foamj" "Format")))
- (statement (spaceseq "import" (importid "foamj" "Word")))
- (statement (spaceseq "import" (importid "foamj" "Value")))
- (statement (spaceseq "import" (importid "foamj" "Env")))
- (statement (spaceseq "import" (importid "foamj" "Clos")))
- (statement (spaceseq "import" (importid "foamj" "Globals")))
- (statement (spaceseq "import" (importid "foamj" "Fn")))
- (nlseq
- (javadoc "Generated by genjava - rectest\\\\n")
- (class
- (spaceseq public)
- "rectest"
- ()
- (commaseq)
- (nlseq
- (statement
- (declaration
- (spaceseq private static)
- (importid "foamj" "Format")
- (assign
- "FORMAT_5"
- (new (apply (importid "foamj" "Format") (paren (commaseq 3))) ()))))
- (statement
- (declaration
- (spaceseq private static)
- (importid "foamj" "Format")
- (assign
- "FORMAT_6"
- (new (apply (importid "foamj" "Format") (paren (commaseq 1))) ()))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C0_rectest"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement (apply "c0_rectest" (paren (commaseq "env"))))
- (statement (spaceseq return null)))))))))
- (method
- (declaration
- (spaceseq private static)
- void
- "c0_rectest"
- (paren
- (commaseq (declaration (spaceseq) (importid "foamj" "Env") "env0")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Word") (sqbracket (spaceseq)))
- (commaseq "t1")))
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Record")
- (commaseq "t2" "t3")))
- (statement
- (declaration
- (spaceseq)
- (spaceseq int (sqbracket (spaceseq)))
- (commaseq "t0")))
- (nlseq
- (statement
- (apply
- "ccall_Xx"
- (paren
- (commaseq
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "runtime")))
- "toClos")
- (paren (commaseq)))))))
- (statement
- (apply
- (memref (importid "foamj" "Globals") "setGlobal")
- (paren
- (commaseq
- "rectest"
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "noOperation")))
- "toClos")
- (paren (commaseq)))))))
- (statement
- (apply
- (memref (importid "foamj" "Globals") "setGlobal")
- (paren
- (commaseq
- "rectest_Rec_743553378"
- (apply
- (memref
- (apply
- "ccall_WxC"
- (paren
- (commaseq
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "domainMake")))
- "toClos")
- (paren (commaseq)))
- (new
- (apply
- (importid "foamj" "Clos")
- (paren (commaseq "env0" "C1_addLevel0")))
- ()))))
- "toValue")
- (paren (commaseq)))))))
- (statement (assign "t0" (new (arrayref int 2) ())))
- (statement
- (assign "t1" (new (arrayref (importid "foamj" "Word") 2) ())))
- (statement (assign (arrayref "t0" 0) 318528389))
- (statement
- (assign
- (arrayref "t1" 0)
- (apply (memref "new" "toCharArray") (paren (commaseq)))))
- (statement (assign (arrayref "t0" 1) 315787127))
- (statement
- (assign
- (arrayref "t1" 1)
- (apply (memref "tag" "toCharArray") (paren (commaseq)))))
- (statement
- (assign
- "t2"
- (new
- (apply (importid "foamj" "Record") (paren (commaseq "FORMAT_5")))
- ())))
- (statement
- (apply
- (memref "t2" "setField")
- (paren
- (commaseq
- 0
- "size"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t2" "setField")
- (paren
- (commaseq
- 1
- "nsize"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t2" "setField")
- (paren
- (commaseq
- 2
- "values"
- (apply
- (memref
- (cast (spaceseq (importid "foamj" "Word") (comment "Arr")) "t0")
- "toValue")
- (paren (commaseq)))))))
- (statement
- (assign
- "t3"
- (new
- (apply (importid "foamj" "Record") (paren (commaseq "FORMAT_5")))
- ())))
- (statement
- (apply
- (memref "t3" "setField")
- (paren
- (commaseq
- 0
- "size"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t3" "setField")
- (paren
- (commaseq
- 1
- "nsize"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t3" "setField")
- (paren
- (commaseq
- 2
- "values"
- (apply
- (memref
- (cast (spaceseq (importid "foamj" "Word") (comment "Arr")) "t1")
- "toValue")
- (paren (commaseq)))))))
- (statement
- (apply
- "ccall_XxWW"
- (paren
- (commaseq
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "rtAddStrings")))
- "toClos")
- (paren (commaseq)))
- (cast (spaceseq (importid "foamj" "Word") (comment "Rec")) "t2")
- (cast (spaceseq (importid "foamj" "Word") (comment "Rec")) "t3")))))
- (statement return)))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C1_addLevel0"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Clos")
- (assign
- "ret"
- (apply
- "c1_addLevel0"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "asWord") (paren (commaseq)))))))))
- (statement (spaceseq return "ret")))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Clos")
- "c1_addLevel0"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Word") "p0_domain")))
- (commaseq))
- (nlseq
- (nlseq
- (statement
- (apply
- "ccall_WxWW"
- (paren
- (commaseq
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "domainAddNameFn!")))
- "toClos")
- (paren (commaseq)))
- "p0_domain"
- (apply
- "ccall_WxA"
- (paren
- (commaseq
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "rtConstNameFn")))
- "toClos")
- (paren (commaseq)))
- (apply (memref "Rec" "toCharArray") (paren (commaseq))))))))))
- (statement
- (apply
- "ccall_WxWI"
- (paren
- (commaseq
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "domainAddHash!")))
- "toClos")
- (paren (commaseq)))
- "p0_domain"
- 316169045))))
- (statement
- (spaceseq
- return
- (new
- (apply
- (importid "foamj" "Clos")
- (paren (commaseq "env0" "C2_addLevel1")))
- ())))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C2_addLevel1"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Word")
- (assign
- "ret"
- (apply
- "c2_addLevel1"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "asWord") (paren (commaseq)))
- (apply (memref (arrayref "vals" 1) "asWord") (paren (commaseq)))))))))
- (statement
- (spaceseq return (apply (memref "ret" "toValue") (paren (commaseq))))))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "c2_addLevel1"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Word") "p0_domain")
- (declaration (spaceseq) (importid "foamj" "Word") "p1_hashcode")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Word") (sqbracket (spaceseq)))
- (commaseq "t2")))
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Record")
- (commaseq "t3" "t4" "t5")))
- (statement
- (declaration
- (spaceseq)
- (spaceseq int (sqbracket (spaceseq)))
- (commaseq "t0" "t1")))
- (statement (declaration (spaceseq) int (commaseq "t6" "t7")))
- (statement
- (declaration
- (spaceseq final)
- (importid "foamj" "EnvRecord")
- (assign "lvl0" (apply (memref "env0" "level") (paren (commaseq))))))
- (nlseq
- (statement (assign "t0" (new (arrayref int 2) ())))
- (statement (assign "t1" (new (arrayref int 2) ())))
- (statement
- (assign "t2" (new (arrayref (importid "foamj" "Word") 2) ())))
- (statement
- (apply
- (memref "lvl0" "setField")
- (paren
- (commaseq
- 2
- ""
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq "p1_hashcode")))))))
- (statement
- (apply
- (memref "lvl0" "setField")
- (paren
- (commaseq
- 1
- "new"
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C3_new")))
- ())))))
- (statement
- (apply
- (memref "lvl0" "setField")
- (paren
- (commaseq
- 0
- "tag"
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C4_tag")))
- ())))))
- (statement
- (assign
- "t6"
- (modulo
- (plus
- (apply
- (memref
- (apply (memref "lvl0" "getField") (paren (commaseq 2 "")))
- "toSInt")
- (paren (commaseq)))
- 447957760)
- 1073741789)))
- (statement
- (assign
- "t7"
- (modulo
- (plus
- 376332111
- (shiftup
- (and
- (modulo
- (plus
- 32236
- (shiftup
- (and
- (modulo
- (plus
- (apply
- (memref
- (apply (memref "lvl0" "getField") (paren (commaseq 2 "")))
- "toSInt")
- (paren (commaseq)))
- 74075968)
- 1073741789)
- 16777215)
- 6))
- 1073741789)
- 16777215)
- 6))
- 1073741789)))
- (statement
- (assign
- "t3"
- (new
- (apply (importid "foamj" "Record") (paren (commaseq "FORMAT_5")))
- ())))
- (statement
- (apply
- (memref "t3" "setField")
- (paren
- (commaseq
- 0
- "size"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t3" "setField")
- (paren
- (commaseq
- 1
- "nsize"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t3" "setField")
- (paren
- (commaseq
- 2
- "values"
- (apply
- (memref
- (cast (spaceseq (importid "foamj" "Word") (comment "Arr")) "t0")
- "toValue")
- (paren (commaseq)))))))
- (statement
- (assign
- "t4"
- (new
- (apply (importid "foamj" "Record") (paren (commaseq "FORMAT_5")))
- ())))
- (statement
- (apply
- (memref "t4" "setField")
- (paren
- (commaseq
- 0
- "size"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t4" "setField")
- (paren
- (commaseq
- 1
- "nsize"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t4" "setField")
- (paren
- (commaseq
- 2
- "values"
- (apply
- (memref
- (cast (spaceseq (importid "foamj" "Word") (comment "Arr")) "t1")
- "toValue")
- (paren (commaseq)))))))
- (statement
- (assign
- "t5"
- (new
- (apply (importid "foamj" "Record") (paren (commaseq "FORMAT_5")))
- ())))
- (statement
- (apply
- (memref "t5" "setField")
- (paren
- (commaseq
- 0
- "size"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t5" "setField")
- (paren
- (commaseq
- 1
- "nsize"
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq 2)))))))
- (statement
- (apply
- (memref "t5" "setField")
- (paren
- (commaseq
- 2
- "values"
- (apply
- (memref
- (cast (spaceseq (importid "foamj" "Word") (comment "Arr")) "t2")
- "toValue")
- (paren (commaseq)))))))
- (statement
- (apply
- "ccall_XxWRRR"
- (paren
- (commaseq
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "domainAddExports!")))
- "toClos")
- (paren (commaseq)))
- "p0_domain"
- "t3"
- "t4"
- "t5"))))
- (statement (assign (arrayref "t0" 0) 318528389))
- (statement (assign (arrayref "t1" 0) "t6"))
- (statement
- (assign
- (arrayref "t2" 0)
- (apply
- (memref
- (apply
- (memref
- (apply (memref "lvl0" "getField") (paren (commaseq 1 "new")))
- "toClos")
- (paren (commaseq)))
- "asWord")
- (paren (commaseq)))))
- (statement (assign (arrayref "t0" 1) 315787127))
- (statement (assign (arrayref "t1" 1) "t7"))
- (statement
- (assign
- (arrayref "t2" 1)
- (apply
- (memref
- (apply
- (memref
- (apply (memref "lvl0" "getField") (paren (commaseq 0 "tag")))
- "toClos")
- (paren (commaseq)))
- "asWord")
- (paren (commaseq)))))
- (statement (spaceseq return "p0_domain"))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C3_new"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Word")
- (assign "ret" (apply "c3_new" (paren (commaseq "env"))))))
- (statement
- (spaceseq return (apply (memref "ret" "toValue") (paren (commaseq))))))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "c3_new"
- (paren
- (commaseq (declaration (spaceseq) (importid "foamj" "Env") "env0")))
- (commaseq))
- (nlseq
- (statement
- (declaration (spaceseq) (importid "foamj" "Record") (commaseq "t0")))
- (nlseq
- (statement
- (assign
- "t0"
- (new
- (apply (importid "foamj" "Record") (paren (commaseq "FORMAT_6")))
- ())))
- (statement
- (apply
- (memref "t0" "setField")
- (paren
- (commaseq 0 "t" (apply (memref 0 "toValue") (paren (commaseq)))))))
- (statement
- (spaceseq
- return
- (cast (spaceseq (importid "foamj" "Word") (comment "Rec")) "t0")))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C4_tag"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Word")
- (assign
- "ret"
- (apply
- "c4_tag"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "asWord") (paren (commaseq)))))))))
- (statement
- (spaceseq return (apply (memref "ret" "toValue") (paren (commaseq))))))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "c4_tag"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Word") "p0_x")))
- (commaseq))
- (nlseq
- (nlseq
- (statement
- (spaceseq
- return
- (apply
- (memref
- (apply (memref "p0_x" "getField") (paren (commaseq 0 "t")))
- "asWord")
- (paren (commaseq)))))))))
- (method
- (declaration
- (spaceseq private static)
- void
- "ccall_XxWRRR"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Clos") "_0")
- (declaration (spaceseq) (importid "foamj" "Word") "_1")
- (declaration (spaceseq) (importid "foamj" "Record") "_2")
- (declaration (spaceseq) (importid "foamj" "Record") "_3")
- (declaration (spaceseq) (importid "foamj" "Record") "_4")))
- (commaseq))
- (nlseq
- (statement
- (apply
- (memref "_0" "call")
- (paren
- (commaseq
- (apply (memref "_1" "toValue") (paren (commaseq)))
- "_2"
- "_3"
- "_4"))))
- (statement return)))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "ccall_WxWW"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Clos") "_0")
- (declaration (spaceseq) (importid "foamj" "Word") "_1")
- (declaration (spaceseq) (importid "foamj" "Word") "_2")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Value")
- (assign
- "result"
- (apply
- (memref "_0" "call")
- (paren
- (commaseq
- (apply (memref "_1" "toValue") (paren (commaseq)))
- (apply (memref "_2" "toValue") (paren (commaseq)))))))))
- (statement
- (spaceseq
- return
- (apply (memref "result" "asWord") (paren (commaseq)))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "ccall_WxA"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Clos") "_0")
- (declaration (spaceseq) "Object" "_1")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Value")
- (assign "result" (apply (memref "_0" "call") (paren (commaseq "_1"))))))
- (statement
- (spaceseq
- return
- (apply (memref "result" "asWord") (paren (commaseq)))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "ccall_WxWI"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Clos") "_0")
- (declaration (spaceseq) (importid "foamj" "Word") "_1")
- (declaration (spaceseq) int "_2")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Value")
- (assign
- "result"
- (apply
- (memref "_0" "call")
- (paren
- (commaseq
- (apply (memref "_1" "toValue") (paren (commaseq)))
- (apply
- (memref (memref (importid "foamj" "Value") "U") "fromSInt")
- (paren (commaseq "_2")))))))))
- (statement
- (spaceseq
- return
- (apply (memref "result" "asWord") (paren (commaseq)))))))
- (method
- (declaration
- (spaceseq private static)
- void
- "ccall_Xx"
- (paren
- (commaseq (declaration (spaceseq) (importid "foamj" "Clos") "_0")))
- (commaseq))
- (nlseq
- (statement (apply (memref "_0" "call") (paren (commaseq))))
- (statement return)))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "ccall_WxC"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Clos") "_0")
- (declaration (spaceseq) (importid "foamj" "Clos") "_1")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Value")
- (assign "result" (apply (memref "_0" "call") (paren (commaseq "_1"))))))
- (statement
- (spaceseq
- return
- (apply (memref "result" "asWord") (paren (commaseq)))))))
- (method
- (declaration
- (spaceseq private static)
- void
- "ccall_XxWW"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Clos") "_0")
- (declaration (spaceseq) (importid "foamj" "Word") "_1")
- (declaration (spaceseq) (importid "foamj" "Word") "_2")))
- (commaseq))
- (nlseq
- (statement
- (apply
- (memref "_0" "call")
- (paren
- (commaseq
- (apply (memref "_1" "toValue") (paren (commaseq)))
- (apply (memref "_2" "toValue") (paren (commaseq)))))))
- (statement return)))))))
-...*/
-import foamj.EnvRecord;
-import foamj.Record;
-import foamj.Format;
-import foamj.Word;
-import foamj.Value;
-import foamj.Env;
-import foamj.Clos;
-import foamj.Globals;
-import foamj.Fn;
-/** Generated by genjava - rectest
- **/
-public class rectest {
- private static Format FORMAT_5 = new Format(3);
- private static Format FORMAT_6 = new Format(1);
- static Fn C0_rectest = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- c0_rectest(env);
- return null;
- }
-
- };
- private static void c0_rectest(Env env0) {
- Word [] t1;
- Record t2, t3;
- int [] t0;
- ccall_Xx(Globals.getGlobal("runtime").toClos());
- Globals.setGlobal("rectest", Globals.getGlobal("noOperation").toClos());
- Globals.setGlobal("rectest_Rec_743553378", ccall_WxC(Globals.getGlobal("domainMake").toClos(), new Clos(env0, C1_addLevel0)).toValue());
- t0 = new int[2];
- t1 = new Word[2];
- t0[0] = 318528389;
- t1[0] = "new".toCharArray();
- t0[1] = 315787127;
- t1[1] = "tag".toCharArray();
- t2 = new Record(FORMAT_5);
- t2.setField(0, "size", Value.U.fromSInt(2));
- t2.setField(1, "nsize", Value.U.fromSInt(2));
- t2.setField(2, "values", (Word /* Arr*/)t0.toValue());
- t3 = new Record(FORMAT_5);
- t3.setField(0, "size", Value.U.fromSInt(2));
- t3.setField(1, "nsize", Value.U.fromSInt(2));
- t3.setField(2, "values", (Word /* Arr*/)t1.toValue());
- ccall_XxWW(Globals.getGlobal("rtAddStrings").toClos(), (Word /* Rec*/)t2, (Word /* Rec*/)t3);
- return;
- }
-
- static Fn C1_addLevel0 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Clos ret = c1_addLevel0(env, vals[0].asWord());
- return ret;
- }
-
- };
- private static Clos c1_addLevel0(Env env0, Word p0_domain) {
- ccall_WxWW(Globals.getGlobal("domainAddNameFn!").toClos(), p0_domain, ccall_WxA(Globals.getGlobal("rtConstNameFn").toClos(), "Rec".toCharArray()));
- ccall_WxWI(Globals.getGlobal("domainAddHash!").toClos(), p0_domain, 316169045);
- return new Clos(env0, C2_addLevel1);
- }
-
- static Fn C2_addLevel1 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Word ret = c2_addLevel1(env, vals[0].asWord(), vals[1].asWord());
- return ret.toValue();
- }
-
- };
- private static Word c2_addLevel1(Env env0, Word p0_domain, Word p1_hashcode) {
- Word [] t2;
- Record t3, t4, t5;
- int [] t0, t1;
- int t6, t7;
- final EnvRecord lvl0 = env0.level();
- t0 = new int[2];
- t1 = new int[2];
- t2 = new Word[2];
- lvl0.setField(2, "", Value.U.fromSInt(p1_hashcode));
- lvl0.setField(1, "new", new Clos(env0, C3_new));
- lvl0.setField(0, "tag", new Clos(env0, C4_tag));
- t6 = (lvl0.getField(2, "").toSInt() + 447957760)%1073741789;
- t7 = (376332111 + (((32236 + (((lvl0.getField(2, "").toSInt() + 74075968)%1073741789 & 16777215)<<6))%1073741789 & 16777215)<<6))%1073741789;
- t3 = new Record(FORMAT_5);
- t3.setField(0, "size", Value.U.fromSInt(2));
- t3.setField(1, "nsize", Value.U.fromSInt(2));
- t3.setField(2, "values", (Word /* Arr*/)t0.toValue());
- t4 = new Record(FORMAT_5);
- t4.setField(0, "size", Value.U.fromSInt(2));
- t4.setField(1, "nsize", Value.U.fromSInt(2));
- t4.setField(2, "values", (Word /* Arr*/)t1.toValue());
- t5 = new Record(FORMAT_5);
- t5.setField(0, "size", Value.U.fromSInt(2));
- t5.setField(1, "nsize", Value.U.fromSInt(2));
- t5.setField(2, "values", (Word /* Arr*/)t2.toValue());
- ccall_XxWRRR(Globals.getGlobal("domainAddExports!").toClos(), p0_domain, t3, t4, t5);
- t0[0] = 318528389;
- t1[0] = t6;
- t2[0] = lvl0.getField(1, "new").toClos().asWord();
- t0[1] = 315787127;
- t1[1] = t7;
- t2[1] = lvl0.getField(0, "tag").toClos().asWord();
- return p0_domain;
- }
-
- static Fn C3_new = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Word ret = c3_new(env);
- return ret.toValue();
- }
-
- };
- private static Word c3_new(Env env0) {
- Record t0;
- t0 = new Record(FORMAT_6);
- t0.setField(0, "t", 0.toValue());
- return (Word /* Rec*/)t0;
- }
-
- static Fn C4_tag = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Word ret = c4_tag(env, vals[0].asWord());
- return ret.toValue();
- }
-
- };
- private static Word c4_tag(Env env0, Word p0_x) {
- return p0_x.getField(0, "t").asWord();
- }
-
- private static void ccall_XxWRRR(Clos _0, Word _1, Record _2, Record _3, Record _4) {
- _0.call(_1.toValue(), _2, _3, _4);
- return;
- }
-
- private static Word ccall_WxWW(Clos _0, Word _1, Word _2) {
- Value result = _0.call(_1.toValue(), _2.toValue());
- return result.asWord();
- }
-
- private static Word ccall_WxA(Clos _0, Object _1) {
- Value result = _0.call(_1);
- return result.asWord();
- }
-
- private static Word ccall_WxWI(Clos _0, Word _1, int _2) {
- Value result = _0.call(_1.toValue(), Value.U.fromSInt(_2));
- return result.asWord();
- }
-
- private static void ccall_Xx(Clos _0) {
- _0.call();
- return;
- }
-
- private static Word ccall_WxC(Clos _0, Clos _1) {
- Value result = _0.call(_1);
- return result.asWord();
- }
-
- private static void ccall_XxWW(Clos _0, Word _1, Word _2) {
- _0.call(_1.toValue(), _2.toValue());
- return;
- }
-
-}
diff --git a/aldor/aldor/test/simple_j.java b/aldor/aldor/test/simple_j.java
deleted file mode 100644
index 944d3b17e..000000000
--- a/aldor/aldor/test/simple_j.java
+++ /dev/null
@@ -1,827 +0,0 @@
-/*...
-(nlseq
- (statement (spaceseq "import" (importid "foamj" "EnvRecord")))
- (statement (spaceseq "import" (importid "foamj" "MultiRecord")))
- (statement (spaceseq "import" (importid "foamj" "Format")))
- (statement (spaceseq "import" (importid "foamj" "Word")))
- (statement (spaceseq "import" (importid "foamj" "Value")))
- (statement (spaceseq "import" (importid "foamj" "Env")))
- (statement (spaceseq "import" (importid "foamj" "Clos")))
- (statement (spaceseq "import" (importid "foamj" "Globals")))
- (statement (spaceseq "import" (importid "foamj" "Fn")))
- (nlseq
- (javadoc "Generated by genjava - simple_j\\\\n")
- (class
- (spaceseq public)
- "simple_j"
- ()
- (commaseq)
- (nlseq
- (statement
- (declaration
- (spaceseq private static)
- (importid "foamj" "Format")
- (assign
- "FORMAT_5"
- (new (apply (importid "foamj" "Format") (paren (commaseq 2))) ()))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C0_simple__j"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement (apply "c0_simple__j" (paren (commaseq "env"))))
- (statement (spaceseq return null)))))))))
- (method
- (declaration
- (spaceseq private static)
- void
- "c0_simple__j"
- (paren
- (commaseq (declaration (spaceseq) (importid "foamj" "Env") "env0")))
- (commaseq))
- (nlseq
- (nlseq
- (statement
- (apply
- "ccall_Xx"
- (paren
- (commaseq
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "runtime")))
- "toClos")
- (paren (commaseq)))))))
- (statement
- (apply
- (memref (importid "foamj" "Globals") "setGlobal")
- (paren
- (commaseq
- "simple_j"
- (apply
- (memref
- (apply
- (memref (importid "foamj" "Globals") "getGlobal")
- (paren (commaseq "noOperation")))
- "toClos")
- (paren (commaseq)))))))
- (statement
- (apply
- (memref (importid "foamj" "Globals") "setGlobal")
- (paren
- (commaseq
- "simple_j_t1_479859677"
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C1_t1")))
- ())))))
- (statement
- (apply
- (memref (importid "foamj" "Globals") "setGlobal")
- (paren
- (commaseq
- "simple_j_t2_494407402"
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C2_t2")))
- ())))))
- (statement
- (apply
- (memref (importid "foamj" "Globals") "setGlobal")
- (paren
- (commaseq
- "simple_j_t3_030021108"
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C3_t3")))
- ())))))
- (statement
- (apply
- (memref (importid "foamj" "Globals") "setGlobal")
- (paren
- (commaseq
- "simple_j_t4_905089460"
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C4_t4")))
- ())))))
- (statement
- (apply
- (memref (importid "foamj" "Globals") "setGlobal")
- (paren
- (commaseq
- "simple_j_t5_264916867"
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C6_t5")))
- ())))))
- (statement return)))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C1_t1"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Word")
- (assign "ret" (apply "c1_t1" (paren (commaseq "env"))))))
- (statement
- (spaceseq return (apply (memref "ret" "toValue") (paren (commaseq))))))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "c1_t1"
- (paren
- (commaseq (declaration (spaceseq) (importid "foamj" "Env") "env0")))
- (commaseq))
- (nlseq
- (nlseq
- (statement
- (spaceseq
- return
- (apply
- (memref (memref (importid "foamj" "Word") "U") "fromSInt")
- (paren (commaseq 12)))))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C2_t2"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Word")
- (assign
- "ret"
- (apply
- "c2_t2"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "asWord") (paren (commaseq)))))))))
- (statement
- (spaceseq return (apply (memref "ret" "toValue") (paren (commaseq))))))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "c2_t2"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Word") "p0_n")))
- (commaseq))
- (nlseq
- (nlseq
- (statement
- (spaceseq
- return
- (apply
- (memref (memref (importid "foamj" "Word") "U") "fromSInt")
- (paren
- (commaseq
- (plus (apply (memref "p0_n" "toSInt") (paren (commaseq))) 1))))))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C3_t3"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (apply
- "c3_t3"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "asWord") (paren (commaseq)))
- (apply (memref (arrayref "vals" 1) "asWord") (paren (commaseq)))))))
- (statement (spaceseq return null)))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "MultiRecord")
- "c3_t3"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Word") "p0_a")
- (declaration (spaceseq) (importid "foamj" "Word") "p1_b")))
- (commaseq))
- (nlseq
- (statement (declaration (spaceseq) int (commaseq "t0" "t1")))
- (nlseq
- (statement
- (assign
- "t0"
- (plus
- (apply (memref "p0_a" "toSInt") (paren (commaseq)))
- (apply (memref "p1_b" "toSInt") (paren (commaseq))))))
- (statement
- (assign
- "t1"
- (minus
- (apply (memref "p0_a" "toSInt") (paren (commaseq)))
- (apply (memref "p1_b" "toSInt") (paren (commaseq))))))
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "MultiRecord")
- (assign
- "var0"
- (new
- (apply (importid "foamj" "MultiRecord") (paren (commaseq "FORMAT_5")))
- ()))))
- (statement
- (apply
- (memref "var0" "setField")
- (paren
- (commaseq
- 0
- ""
- (apply
- (memref
- (apply
- (memref (memref (importid "foamj" "Word") "U") "fromSInt")
- (paren (commaseq "t0")))
- "toValue")
- (paren (commaseq)))))))
- (statement
- (apply
- (memref "var0" "setField")
- (paren
- (commaseq
- 1
- ""
- (apply
- (memref
- (apply
- (memref (memref (importid "foamj" "Word") "U") "fromSInt")
- (paren (commaseq "t1")))
- "toValue")
- (paren (commaseq)))))))
- (statement (spaceseq return "var0"))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C4_t4"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Clos")
- (assign
- "ret"
- (apply
- "c4_t4"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "asWord") (paren (commaseq)))))))))
- (statement (spaceseq return "ret")))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Clos")
- "c4_t4"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Word") "p0_a")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq final)
- (importid "foamj" "EnvRecord")
- (assign "lvl0" (apply (memref "env0" "level") (paren (commaseq))))))
- (nlseq
- (statement
- (apply
- (memref "lvl0" "setField")
- (paren
- (commaseq
- 0
- "a"
- (apply (memref "p0_a" "toValue") (paren (commaseq)))))))
- (statement
- (spaceseq
- return
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C5_t4")))
- ())))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C5_t4"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Word")
- (assign
- "ret"
- (apply
- "c5_t4"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "asWord") (paren (commaseq)))))))))
- (statement
- (spaceseq return (apply (memref "ret" "toValue") (paren (commaseq))))))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "c5_t4"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Word") "p0_x")))
- (commaseq))
- (nlseq
- (statement
- (declaration (spaceseq) (importid "foamj" "Word") (commaseq "t0")))
- (statement
- (declaration
- (spaceseq final)
- (importid "foamj" "Env")
- (assign "env1" (apply (memref "env0" "parent") (paren (commaseq))))))
- (statement
- (declaration
- (spaceseq final)
- (importid "foamj" "EnvRecord")
- (assign "lvl1" (apply (memref "env1" "level") (paren (commaseq))))))
- (nlseq
- (statement
- (assign
- "t0"
- (apply
- (memref
- (apply (memref "lvl1" "getField") (paren (commaseq 0 "a")))
- "asWord")
- (paren (commaseq)))))
- (statement
- (spaceseq
- return
- (apply
- (memref (memref (importid "foamj" "Word") "U") "fromSInt")
- (paren
- (commaseq
- (plus
- (apply (memref "t0" "toSInt") (paren (commaseq)))
- (apply (memref "p0_x" "toSInt") (paren (commaseq)))))))))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C6_t5"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Clos")
- (assign
- "ret"
- (apply
- "c6_t5"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "toClos") (paren (commaseq)))))))))
- (statement (spaceseq return "ret")))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Clos")
- "c6_t5"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Clos") "p0_f")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq final)
- (importid "foamj" "EnvRecord")
- (assign "lvl0" (apply (memref "env0" "level") (paren (commaseq))))))
- (nlseq
- (statement
- (apply (memref "lvl0" "setField") (paren (commaseq 0 "f" "p0_f"))))
- (statement
- (spaceseq
- return
- (new
- (apply (importid "foamj" "Clos") (paren (commaseq "env0" "C7_t5")))
- ())))))))
- (nlseq
- (statement
- (declaration
- (spaceseq static)
- (importid "foamj" "Fn")
- (assign
- "C7_t5"
- (new
- (apply (importid "foamj" "Fn") (paren (commaseq)))
- (nlseq
- (method
- (declaration
- (spaceseq public)
- (importid "foamj" "Value")
- "ocall"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env")
- (declaration
- (spaceseq)
- (spaceseq (importid "foamj" "Value") |...|)
- "vals")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Word")
- (assign
- "ret"
- (apply
- "c7_t5"
- (paren
- (commaseq
- "env"
- (apply (memref (arrayref "vals" 0) "asWord") (paren (commaseq)))))))))
- (statement
- (spaceseq return (apply (memref "ret" "toValue") (paren (commaseq))))))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "Word")
- "c7_t5"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Env") "env0")
- (declaration (spaceseq) (importid "foamj" "Word") "p0_n")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Word")
- (commaseq "t0" "t1")))
- (statement
- (declaration
- (spaceseq final)
- (importid "foamj" "Env")
- (assign "env1" (apply (memref "env0" "parent") (paren (commaseq))))))
- (statement
- (declaration
- (spaceseq final)
- (importid "foamj" "EnvRecord")
- (assign "lvl1" (apply (memref "env1" "level") (paren (commaseq))))))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "MultiRecord")
- (assign
- "var0"
- (apply
- "ccall_WWxW"
- (paren
- (commaseq
- (apply
- (memref
- (apply (memref "lvl1" "getField") (paren (commaseq 0 "f")))
- "toClos")
- (paren (commaseq)))
- "p0_n"))))))
- (statement
- (assign
- "t0"
- (apply
- (memref
- (apply (memref "var0" "getField") (paren (commaseq 0 "")))
- "asWord")
- (paren (commaseq)))))
- (statement
- (assign
- "t1"
- (apply
- (memref
- (apply (memref "var0" "getField") (paren (commaseq 1 "")))
- "asWord")
- (paren (commaseq)))))
- (statement
- (spaceseq
- return
- (apply
- (memref (memref (importid "foamj" "Word") "U") "fromSInt")
- (paren
- (commaseq
- (plus
- (apply (memref "t0" "toSInt") (paren (commaseq)))
- (apply (memref "t1" "toSInt") (paren (commaseq)))))))))))))
- (method
- (declaration
- (spaceseq private static)
- (importid "foamj" "MultiRecord")
- "ccall_WWxW"
- (paren
- (commaseq
- (declaration (spaceseq) (importid "foamj" "Clos") "_0")
- (declaration (spaceseq) (importid "foamj" "Word") "_1")))
- (commaseq))
- (nlseq
- (statement
- (declaration
- (spaceseq)
- (importid "foamj" "Value")
- (assign
- "result"
- (apply
- (memref "_0" "call")
- (paren (commaseq (apply (memref "_1" "toValue") (paren (commaseq)))))))))
- (statement
- (spaceseq
- return
- (apply (memref "result" "toMulti") (paren (commaseq)))))))
- (method
- (declaration
- (spaceseq private static)
- void
- "ccall_Xx"
- (paren
- (commaseq (declaration (spaceseq) (importid "foamj" "Clos") "_0")))
- (commaseq))
- (nlseq
- (statement (apply (memref "_0" "call") (paren (commaseq))))
- (statement return)))))))
-...*/
-import foamj.EnvRecord;
-import foamj.MultiRecord;
-import foamj.Format;
-import foamj.Word;
-import foamj.Value;
-import foamj.Env;
-import foamj.Clos;
-import foamj.Globals;
-import foamj.Fn;
-/** Generated by genjava - simple_j
- **/
-public class simple_j {
- private static Format FORMAT_5 = new Format(2);
- static Fn C0_simple__j = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- c0_simple__j(env);
- return null;
- }
-
- };
- private static void c0_simple__j(Env env0) {
- ccall_Xx(Globals.getGlobal("runtime").toClos());
- Globals.setGlobal("simple_j", Globals.getGlobal("noOperation").toClos());
- Globals.setGlobal("simple_j_t1_479859677", new Clos(env0, C1_t1));
- Globals.setGlobal("simple_j_t2_494407402", new Clos(env0, C2_t2));
- Globals.setGlobal("simple_j_t3_030021108", new Clos(env0, C3_t3));
- Globals.setGlobal("simple_j_t4_905089460", new Clos(env0, C4_t4));
- Globals.setGlobal("simple_j_t5_264916867", new Clos(env0, C6_t5));
- return;
- }
-
- static Fn C1_t1 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Word ret = c1_t1(env);
- return ret.toValue();
- }
-
- };
- private static Word c1_t1(Env env0) {
- return Word.U.fromSInt(12);
- }
-
- static Fn C2_t2 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Word ret = c2_t2(env, vals[0].asWord());
- return ret.toValue();
- }
-
- };
- private static Word c2_t2(Env env0, Word p0_n) {
- return Word.U.fromSInt(p0_n.toSInt() + 1);
- }
-
- static Fn C3_t3 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- c3_t3(env, vals[0].asWord(), vals[1].asWord());
- return null;
- }
-
- };
- private static MultiRecord c3_t3(Env env0, Word p0_a, Word p1_b) {
- int t0, t1;
- t0 = p0_a.toSInt() + p1_b.toSInt();
- t1 = p0_a.toSInt() - p1_b.toSInt();
- MultiRecord var0 = new MultiRecord(FORMAT_5);
- var0.setField(0, "", Word.U.fromSInt(t0).toValue());
- var0.setField(1, "", Word.U.fromSInt(t1).toValue());
- return var0;
- }
-
- static Fn C4_t4 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Clos ret = c4_t4(env, vals[0].asWord());
- return ret;
- }
-
- };
- private static Clos c4_t4(Env env0, Word p0_a) {
- final EnvRecord lvl0 = env0.level();
- lvl0.setField(0, "a", p0_a.toValue());
- return new Clos(env0, C5_t4);
- }
-
- static Fn C5_t4 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Word ret = c5_t4(env, vals[0].asWord());
- return ret.toValue();
- }
-
- };
- private static Word c5_t4(Env env0, Word p0_x) {
- Word t0;
- final Env env1 = env0.parent();
- final EnvRecord lvl1 = env1.level();
- t0 = lvl1.getField(0, "a").asWord();
- return Word.U.fromSInt(t0.toSInt() + p0_x.toSInt());
- }
-
- static Fn C6_t5 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Clos ret = c6_t5(env, vals[0].toClos());
- return ret;
- }
-
- };
- private static Clos c6_t5(Env env0, Clos p0_f) {
- final EnvRecord lvl0 = env0.level();
- lvl0.setField(0, "f", p0_f);
- return new Clos(env0, C7_t5);
- }
-
- static Fn C7_t5 = new Fn() {
- public Value ocall(Env env, Value ... vals) {
- Word ret = c7_t5(env, vals[0].asWord());
- return ret.toValue();
- }
-
- };
- private static Word c7_t5(Env env0, Word p0_n) {
- Word t0, t1;
- final Env env1 = env0.parent();
- final EnvRecord lvl1 = env1.level();
- MultiRecord var0 = ccall_WWxW(lvl1.getField(0, "f").toClos(), p0_n);
- t0 = var0.getField(0, "").asWord();
- t1 = var0.getField(1, "").asWord();
- return Word.U.fromSInt(t0.toSInt() + t1.toSInt());
- }
-
- private static MultiRecord ccall_WWxW(Clos _0, Word _1) {
- Value result = _0.call(_1.toValue());
- return result.toMulti();
- }
-
- private static void ccall_Xx(Clos _0) {
- _0.call();
- return;
- }
-
-}
From 0f8e952e857c431b66d859e2c4a2bad8d978b0f2 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 9 Sep 2017 20:13:40 +0100
Subject: [PATCH 197/352] test: Add a test case for imported java objects.
---
aldor/aldor/test/Makefile.in | 6 ++--
aldor/aldor/test/jimport.as | 53 ++++++++++++++++++++++++++++-----
aldor/aldor/test/jimport_opt.as | 1 +
3 files changed, 50 insertions(+), 10 deletions(-)
create mode 100644 aldor/aldor/test/jimport_opt.as
diff --git a/aldor/aldor/test/Makefile.in b/aldor/aldor/test/Makefile.in
index 327a68c7e..d802d1053 100644
--- a/aldor/aldor/test/Makefile.in
+++ b/aldor/aldor/test/Makefile.in
@@ -80,13 +80,14 @@ fmtests := rectest enumtest clos strtable1 simple apply
ctests := rectest enumtest multinever maptuple
otests := enumtest
xtests := enumtest
-@BUILD_JAVA_TRUE@jruntests := jimport
+@BUILD_JAVA_TRUE@jruntests := jimport jimport_opt
x_extra := rtexns
@BUILD_JAVA_TRUE@jtests := simple_j enumtest run_j
simple_j_AXLFLAGS=-Q2
+jimport_opt_AXLFLAGS=-Q9 -Qinline-all
badtests := opt1
@@ -192,8 +193,7 @@ $(patsubst %, %.exe, $(_xtests)): %.exe: %.o rtexns.o
# -Fmain=bobthebuilder.c \
$(patsubst %, %-javatest,$(_jruntests)): %-javatest: out/java/%.class
- $(AM_V_ALDOR_JAVATEST) \
- java -cp out/java:$(abs_top_builddir)/aldor/lib/java/src/foamj.jar:$(abs_top_builddir)/aldor/lib/libfoam/al/foam.jar:$(abs_top_builddir)/aldor/lib/libfoamlib/al/foamlib.jar: $*
+ $(AM_V_ALDOR_JAVATEST) java -cp out/java:$(abs_top_builddir)/aldor/lib/java/src/foamj.jar:$(abs_top_builddir)/aldor/lib/libfoam/al/foam.jar:$(abs_top_builddir)/aldor/lib/libfoamlib/al/foamlib.jar: $*
check-java: $(patsubst %,%-javatest,$(_jruntests))
diff --git a/aldor/aldor/test/jimport.as b/aldor/aldor/test/jimport.as
index 7e4207f65..ad2be479a 100644
--- a/aldor/aldor/test/jimport.as
+++ b/aldor/aldor/test/jimport.as
@@ -4,6 +4,25 @@ import from Machine;
APPLY(id, rhs) ==> { apply: (%, 'id') -> rhs; export from 'id' }
+JString ==> java_.lang_.String;
+import JString: with {
+} from Foreign Java;
+
+
+extend String: with {
+ toJava: % -> JString;
+ fromJava: JString -> %;
+}
+== add {
+ import {
+ javaStringToString: JString -> %;
+ stringToJavaString: % -> JString;
+ } from Foreign;
+
+ toJava(x: %): JString == stringToJavaString x;
+ fromJava(x: JString): % == javaStringToString x;
+}
+
import BitSet: with {
new: () -> %;
new: SingleInteger -> %;
@@ -20,14 +39,27 @@ import BitSet: with {
APPLY(equals, % -> Boolean);
} from Foreign Java "java.util";
-import Math: with {
- abs: SingleInteger -> SingleInteger;
-} from Foreign Java "java.lang";
+JMath ==> Math;
+import JMath: with {
+-- abs: SingleInteger -> SingleInteger;
+} from Foreign Java;
+
+import LocalDate: with {
+ now: () -> %;
+ _of: (SingleInteger, Month, SingleInteger) -> %;
+ APPLY(toString, () -> JString);
+} from Foreign Java "java.time";
+
+import Month: with {
+ --JANUARY: %;
+ valueOf: JString -> %;
+ _of: SingleInteger -> %;
+} from Foreign Java "java.time";
check(f: Boolean): () == if not f then never;
test1(): () == {
- import from SingleInteger, Math;
+ import from SingleInteger, JMath;
b: BitSet := new(5);
print << "BitSet: " << b.get(0) << newline;
b.set(0);
@@ -39,9 +71,9 @@ test1(): () == {
test2(): () == {
import from SingleInteger;
- print << abs(1)$Math << " " << abs(-1)$Math << newline;
- check(abs(1)$Math = abs(-1)$Math);
- check(1 = abs(-1)$Math);
+-- print << abs(1)$JMath << " " << abs(-1)$JMath << newline;
+-- check(abs(1)$JMath = abs(-1)$JMath);
+-- check(1 = abs(-1)$JMath);
}
test3(): () == {
@@ -57,6 +89,13 @@ test3(): () == {
check(not b1.equals(b2));
}
+test4(): () == {
+ import from String;
+ dd: LocalDate := now();
+ stdout << fromJava(dd.toString()) << newline
+}
+
test1();
test2();
test3();
+test4();
diff --git a/aldor/aldor/test/jimport_opt.as b/aldor/aldor/test/jimport_opt.as
new file mode 100644
index 000000000..e03ce0379
--- /dev/null
+++ b/aldor/aldor/test/jimport_opt.as
@@ -0,0 +1 @@
+#include "jimport.as"
From fe3a42d9f2c569296a1d8557da6eaf85784aacbe Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Fri, 22 Sep 2017 22:10:04 +0100
Subject: [PATCH 198/352] src/*: Rename AB_Foreign to AB_ForeignImport
Gives us space for a foreign export later...
---
aldor/aldor/src/abcheck.c | 12 ++++++------
aldor/aldor/src/abnorm.c | 2 +-
aldor/aldor/src/abpretty.c | 10 +++++-----
aldor/aldor/src/absyn.c | 2 +-
aldor/aldor/src/absyn.h | 10 +++++-----
aldor/aldor/src/abuse.c | 6 +++---
aldor/aldor/src/genfoam.c | 10 +++++-----
aldor/aldor/src/scobind.c | 16 ++++++++--------
aldor/aldor/src/ti_bup.c | 6 +++---
aldor/aldor/src/ti_sef.c | 6 +++---
aldor/aldor/src/ti_tdn.c | 14 +++++++-------
aldor/lib/ax0/src/ax/aggcat.ax | 2 +-
aldor/lib/ax0/src/ax/array2.ax | 2 +-
aldor/lib/ax0/src/ax/basecliq.ax | 2 +-
aldor/lib/ax0/src/ax/equation1.ax | 2 +-
aldor/lib/ax0/src/ax/equation2.ax | 2 +-
aldor/lib/ax0/src/ax/fraction.ax | 2 +-
aldor/lib/ax0/src/ax/fspace.ax | 2 +-
aldor/lib/ax0/src/ax/matcat.ax | 2 +-
aldor/lib/ax0/src/ax/polycat.ax | 2 +-
aldor/lib/ax0/src/ax/sf.ax | 2 +-
aldor/lib/ax0/src/ax/si.ax | 2 +-
aldor/lib/ax0/src/ax/stream.ax | 2 +-
aldor/lib/ax0/src/ax/vector.ax | 2 +-
24 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/aldor/aldor/src/abcheck.c b/aldor/aldor/src/abcheck.c
index ef0690eb8..cb189a2b3 100644
--- a/aldor/aldor/src/abcheck.c
+++ b/aldor/aldor/src/abcheck.c
@@ -31,7 +31,7 @@ local void abCheckExport (AbSyn);
local void abCheckExtend (AbSyn);
local void abCheckFluid (AbSyn);
local void abCheckFor (AbSyn);
-local void abCheckForeign (AbSyn);
+local void abCheckForeignImport (AbSyn);
local void abCheckFree (AbSyn);
local void abCheckImport (AbSyn);
local void abCheckLambda (AbSyn);
@@ -142,8 +142,8 @@ abCheck(AbSyn absyn)
abCheckFor(absyn);
break;
- case AB_Foreign:
- abCheckForeign(absyn);
+ case AB_ForeignImport:
+ abCheckForeignImport(absyn);
break;
case AB_Free:
@@ -650,14 +650,14 @@ abCheckFor0_old(AbSyn var)
/*****************************************************************************
*
- * :: abCheckForeign
+ * :: abCheckForeignImport
*
****************************************************************************/
local void
-abCheckForeign(AbSyn absyn)
+abCheckForeignImport(AbSyn absyn)
{
- AbSyn what = absyn->abForeign.what;
+ AbSyn what = absyn->abForeignImport.what;
AbSyn *argv = abArgvAs(AB_Sequence, what);
Length i, argc = abArgcAs(AB_Sequence, what);
diff --git a/aldor/aldor/src/abnorm.c b/aldor/aldor/src/abnorm.c
index 8997e5fc2..4ca7b84d8 100644
--- a/aldor/aldor/src/abnorm.c
+++ b/aldor/aldor/src/abnorm.c
@@ -880,7 +880,7 @@ abn0Import(AbSyn ab, AbSyn what, AbSyn where)
/* Replace the import with a foreign */
- ab = abNewForeign(abPos(oab), what, where);
+ ab = abNewForeignImport(abPos(oab), what, where);
/* Release storage associated with the original node */
diff --git a/aldor/aldor/src/abpretty.c b/aldor/aldor/src/abpretty.c
index 775ca56d0..f03a458c8 100644
--- a/aldor/aldor/src/abpretty.c
+++ b/aldor/aldor/src/abpretty.c
@@ -525,20 +525,20 @@ abPPClipped0(Buffer buf, AbSyn ab, long *pmaxchars)
}
break;
- case AB_Foreign:
+ case AB_ForeignImport:
{
f = f && abPPPuts(buf, "import ", pmaxchars);
- if (! abHasTag(ab->abForeign.what, AB_Sequence))
+ if (! abHasTag(ab->abForeignImport.what, AB_Sequence))
f = f && abPPIndent(buf, pmaxchars)
&& abPPPuts(buf, INDENTATION, pmaxchars);
- f = f && abPPClipped0(buf, ab->abForeign.what, pmaxchars);
+ f = f && abPPClipped0(buf, ab->abForeignImport.what, pmaxchars);
f = f && abPPIndent(buf, pmaxchars);
f = f && abPPPuts(buf, "from Foreign(", pmaxchars);
- if (abIsNotNothing(ab->abForeign.origin))
- f = f && abPPClipped0(buf, ab->abForeign.origin, pmaxchars);
+ if (abIsNotNothing(ab->abForeignImport.origin))
+ f = f && abPPClipped0(buf, ab->abForeignImport.origin, pmaxchars);
f = f && abPPPuts(buf, ")", pmaxchars);
}
break;
diff --git a/aldor/aldor/src/absyn.c b/aldor/aldor/src/absyn.c
index 92c9d228a..400d5c032 100644
--- a/aldor/aldor/src/absyn.c
+++ b/aldor/aldor/src/absyn.c
@@ -1551,7 +1551,7 @@ struct ab_info abInfoTable[] = {
{AB_Fix, 0, 0, "Fix", KW_Fix },
{AB_Fluid, 0, 0, "Fluid", KW_Fluid },
{AB_For, 0, 0, "For", KW_For },
- {AB_Foreign, 0, 0, "Foreign", TK_LIMIT },
+ {AB_ForeignImport,0, 0, "ForeignImport",TK_LIMIT },
{AB_Free, 0, 0, "Free", KW_Free },
{AB_Generate, 0, 0, "Generate", KW_Generate },
{AB_Goto, 0, 0, "Goto", KW_Goto },
diff --git a/aldor/aldor/src/absyn.h b/aldor/aldor/src/absyn.h
index 9c566df94..6eb5ff200 100644
--- a/aldor/aldor/src/absyn.h
+++ b/aldor/aldor/src/absyn.h
@@ -68,7 +68,7 @@ enum abSynTag {
AB_Fix,
AB_Fluid,
AB_For,
- AB_Foreign,
+ AB_ForeignImport,
AB_Free,
AB_Generate,
AB_Goto,
@@ -150,7 +150,7 @@ typedef Enum(abSynTag) AbSynTag;
# define abNewFluid(p,b) abNew(AB_Fluid, p,1, b)
# define abNewFix(p,b) abNew(AB_Fix, p,1, b)
# define abNewFor(p,v,i,c) abNew(AB_For, p,3, v,i,c)
-# define abNewForeign(p,w,o) abNew(AB_Foreign, p,2, w,o)
+# define abNewForeignImport(p,w,o) abNew(AB_ForeignImport,p,2, w,o)
# define abNewFree(p,b) abNew(AB_Free, p,1, b)
# define abNewGenerate(p,n,e) abNew(AB_Generate, p,2, n,e)
# define abNewGoto(p,l) abNew(AB_Goto, p,1, l)
@@ -497,7 +497,7 @@ struct abFor {
AbSyn test;
};
-struct abForeign {
+struct abForeignImport {
struct abHdr hdr;
AbSyn what;
AbSyn origin;
@@ -770,7 +770,7 @@ union abSyn {
struct abFix abFix;
struct abFluid abFluid;
struct abFor abFor;
- struct abForeign abForeign;
+ struct abForeignImport abForeignImport;
struct abFree abFree;
struct abGenerate abGenerate;
struct abGoto abGoto;
@@ -1164,7 +1164,7 @@ extern AbSyn abNewDocTextOfList (TokenList);
case AB_Fix: fun##Fix args; break; \
case AB_Fluid: fun##Fluid args; break; \
case AB_For: fun##For args; break; \
- case AB_Foreign: fun##Foreign args; break; \
+ case AB_ForeignImport: fun##ForeignImport args; break; \
case AB_Free: fun##Free args; break; \
case AB_Generate: fun##Generate args; break; \
case AB_Goto: fun##Goto args; break; \
diff --git a/aldor/aldor/src/abuse.c b/aldor/aldor/src/abuse.c
index d0063a8b0..c9c3ee55c 100644
--- a/aldor/aldor/src/abuse.c
+++ b/aldor/aldor/src/abuse.c
@@ -143,9 +143,9 @@ abPutUse(AbSyn absyn, AbUse context)
for (i = 0; i < abArgc(absyn); i++)
abPutUse(absyn->abFree.argv[i], AB_Use_Declaration);
break;
- case AB_Foreign:
- abPutUse(absyn->abForeign.what, AB_Use_Declaration);
- abPutUse(absyn->abForeign.origin, AB_Use_Type);
+ case AB_ForeignImport:
+ abPutUse(absyn->abForeignImport.what, AB_Use_Declaration);
+ abPutUse(absyn->abForeignImport.origin, AB_Use_Type);
break;
case AB_Builtin:
abPutUse(absyn->abBuiltin.what, AB_Use_Declaration);
diff --git a/aldor/aldor/src/genfoam.c b/aldor/aldor/src/genfoam.c
index 590c63987..9b28d67c1 100644
--- a/aldor/aldor/src/genfoam.c
+++ b/aldor/aldor/src/genfoam.c
@@ -102,7 +102,7 @@ local Foam genNever (AbSyn);
local Foam genWhere (AbSyn);
local Foam genExport (AbSyn);
local Foam genSelect (AbSyn);
-local Foam genForeign (AbSyn);
+local Foam genForeignImport (AbSyn);
local Foam genRestrict (AbSyn);
/*****************************************************************************
@@ -895,8 +895,8 @@ genFoam(AbSyn absyn)
case AB_Nothing:
case AB_Inline:
break;
- case AB_Foreign:
- genForeign(absyn);
+ case AB_ForeignImport:
+ genForeignImport(absyn);
break;
case AB_Has:
foam = genHas(absyn);
@@ -1067,9 +1067,9 @@ gen0ExportToC(AbSyn absyn)
* Generate Foreign inclusion hints.
*/
local Foam
-genForeign(AbSyn absyn)
+genForeignImport(AbSyn absyn)
{
- AbSyn origin = absyn->abForeign.origin;
+ AbSyn origin = absyn->abForeignImport.origin;
ForeignOrigin forg;
Foam decl;
diff --git a/aldor/aldor/src/scobind.c b/aldor/aldor/src/scobind.c
index 8906ab112..f4153ff8b 100644
--- a/aldor/aldor/src/scobind.c
+++ b/aldor/aldor/src/scobind.c
@@ -252,7 +252,7 @@ local void scobindExport (AbSyn);
local void scobindExtend (AbSyn);
local void scobindFluid (AbSyn);
local void scobindFor (AbSyn);
-local void scobindForeign (AbSyn);
+local void scobindForeignImport (AbSyn);
local void scobindFree (AbSyn);
local void scobindImport (AbSyn);
local void scobindInline (AbSyn);
@@ -615,7 +615,7 @@ scobindValue(AbSyn absyn)
case AB_Extend:
case AB_Fluid:
case AB_For:
- case AB_Foreign:
+ case AB_ForeignImport:
case AB_Free:
case AB_Import:
case AB_Inline:
@@ -770,8 +770,8 @@ scobindContext(AbSyn absyn)
scobindFor(absyn);
break;
- case AB_Foreign:
- scobindForeign(absyn);
+ case AB_ForeignImport:
+ scobindForeignImport(absyn);
break;
case AB_Free:
@@ -2560,15 +2560,15 @@ scobindForId(AbSyn id, AbSyn type)
/******************************************************************************
*
- * :: scobindForeign
+ * :: scobindForeignImport
*
*****************************************************************************/
local void
-scobindForeign(AbSyn ab)
+scobindForeignImport(AbSyn ab)
{
- AbSyn origin = ab->abForeign.origin;
- AbSyn what = ab->abForeign.what;
+ AbSyn origin = ab->abForeignImport.origin;
+ AbSyn what = ab->abForeignImport.what;
AbSyn *argv = abArgvAs(AB_Sequence, what);
Length i, argc = abArgcAs(AB_Sequence, what);
diff --git a/aldor/aldor/src/ti_bup.c b/aldor/aldor/src/ti_bup.c
index 0f7121b2f..cefb50f08 100644
--- a/aldor/aldor/src/ti_bup.c
+++ b/aldor/aldor/src/ti_bup.c
@@ -129,7 +129,7 @@ local void tibupExtend (Stab, AbSyn, TForm);
local void tibupFix (Stab, AbSyn, TForm);
local void tibupFluid (Stab, AbSyn, TForm);
local void tibupFor (Stab, AbSyn, TForm);
-local void tibupForeign (Stab, AbSyn, TForm);
+local void tibupForeignImport(Stab, AbSyn, TForm);
local void tibupFree (Stab, AbSyn, TForm);
local void tibupGenerate (Stab, AbSyn, TForm);
local void tibupReference (Stab, AbSyn, TForm);
@@ -2650,9 +2650,9 @@ tibupFor(Stab stab, AbSyn absyn, TForm type)
***************************************************************************/
local void
-tibupForeign(Stab stab, AbSyn absyn, TForm type)
+tibupForeignImport(Stab stab, AbSyn absyn, TForm type)
{
- tibup(stab, absyn->abForeign.what, tfUnknown);
+ tibup(stab, absyn->abForeignImport.what, tfUnknown);
abTPoss(absyn) = tpossSingleton(tfNone());
}
diff --git a/aldor/aldor/src/ti_sef.c b/aldor/aldor/src/ti_sef.c
index 7b0b2d360..b2c1e5a55 100644
--- a/aldor/aldor/src/ti_sef.c
+++ b/aldor/aldor/src/ti_sef.c
@@ -81,7 +81,7 @@ local void tisefExtend (Stab, Sefo);
local void tisefFix (Stab, Sefo);
local void tisefFluid (Stab, Sefo);
local void tisefFor (Stab, Sefo);
-local void tisefForeign (Stab, Sefo);
+local void tisefForeignImport(Stab, Sefo);
local void tisefFree (Stab, Sefo);
local void tisefGenerate (Stab, Sefo);
local void tisefReference (Stab, Sefo);
@@ -1017,12 +1017,12 @@ tisefFor(Stab stab, Sefo sefo)
/****************************************************************************
*
- * :: Foreign: import ... from Foreign(...)
+ * :: ForeignImport: import ... from Foreign(...)
*
***************************************************************************/
local void
-tisefForeign(Stab stab, Sefo sefo)
+tisefForeignImport(Stab stab, Sefo sefo)
{
tisef0Generic(stab, sefo);
}
diff --git a/aldor/aldor/src/ti_tdn.c b/aldor/aldor/src/ti_tdn.c
index 42ae684e4..cd487193b 100644
--- a/aldor/aldor/src/ti_tdn.c
+++ b/aldor/aldor/src/ti_tdn.c
@@ -116,7 +116,7 @@ local Bool titdnExtend (Stab, AbSyn, TForm);
local Bool titdnFix (Stab, AbSyn, TForm);
local Bool titdnFluid (Stab, AbSyn, TForm);
local Bool titdnFor (Stab, AbSyn, TForm);
-local Bool titdnForeign (Stab, AbSyn, TForm);
+local Bool titdnForeignImport(Stab, AbSyn, TForm);
local Bool titdnFree (Stab, AbSyn, TForm);
local Bool titdnGenerate (Stab, AbSyn, TForm);
local Bool titdnGoto (Stab, AbSyn, TForm);
@@ -1837,15 +1837,15 @@ local Bool titdnForeignJava(Stab stab, AbSyn absyn);
local Bool titdnForeignJavaDeclare(Stab stab, AbSyn decl);
local Bool
-titdnForeign(Stab stab, AbSyn absyn, TForm type)
+titdnForeignImport(Stab stab, AbSyn absyn, TForm type)
{
- ForeignOrigin forg = forgFrAbSyn(absyn->abForeign.origin);
+ ForeignOrigin forg = forgFrAbSyn(absyn->abForeignImport.origin);
Bool ok;
- titdn(stab, absyn->abForeign.what, tfUnknown);
+ titdn(stab, absyn->abForeignImport.what, tfUnknown);
switch (forg->protocol) {
case FOAM_Proto_Java:
- ok = titdnForeignJava(stab, absyn->abForeign.what);
+ ok = titdnForeignJava(stab, absyn->abForeignImport.what);
break;
default:
ok = true;
@@ -2788,8 +2788,8 @@ titdnError(Stab stab, AbSyn absyn, TForm type)
titdnError(stab, absyn->abFor.test, tfBoolean);
titdnError(stab, absyn->abFor.lhs, tfUnknown);
break;
- case AB_Foreign:
- titdnError(stab, absyn->abForeign.what, tfUnknown);
+ case AB_ForeignImport:
+ titdnError(stab, absyn->abForeignImport.what, tfUnknown);
break;
case AB_Import:
titdnError(stab, absyn->abImport.what, tfUnknown);
diff --git a/aldor/lib/ax0/src/ax/aggcat.ax b/aldor/lib/ax0/src/ax/aggcat.ax
index f859e4960..0c0f3c7d0 100644
--- a/aldor/lib/ax0/src/ax/aggcat.ax
+++ b/aldor/lib/ax0/src/ax/aggcat.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Define|
(|Declare| |BitAggregate| |Category|)
(|With|
diff --git a/aldor/lib/ax0/src/ax/array2.ax b/aldor/lib/ax0/src/ax/array2.ax
index 208958f65..0d421fd37 100644
--- a/aldor/lib/ax0/src/ax/array2.ax
+++ b/aldor/lib/ax0/src/ax/array2.ax
@@ -1,7 +1,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Export|
(|Declare|
|TwoDimensionalArray|
diff --git a/aldor/lib/ax0/src/ax/basecliq.ax b/aldor/lib/ax0/src/ax/basecliq.ax
index eb8fd8207..5760f3f54 100644
--- a/aldor/lib/ax0/src/ax/basecliq.ax
+++ b/aldor/lib/ax0/src/ax/basecliq.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Export| (|Declare| |DoubleFloat| |SetCategory|) NIL NIL)
(|Export| (|Declare| |Float| |SetCategory|) NIL NIL)
(|Export| (|Declare| |Integer| |IntegralDomain|) NIL NIL)
diff --git a/aldor/lib/ax0/src/ax/equation1.ax b/aldor/lib/ax0/src/ax/equation1.ax
index 6e983fc24..3e3d54f06 100644
--- a/aldor/lib/ax0/src/ax/equation1.ax
+++ b/aldor/lib/ax0/src/ax/equation1.ax
@@ -1,7 +1,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Define|
(|Declare|
|Evalable|
diff --git a/aldor/lib/ax0/src/ax/equation2.ax b/aldor/lib/ax0/src/ax/equation2.ax
index adac54541..e91310f03 100644
--- a/aldor/lib/ax0/src/ax/equation2.ax
+++ b/aldor/lib/ax0/src/ax/equation2.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Define|
(|Declare|
|FullyEvalableOver|
diff --git a/aldor/lib/ax0/src/ax/fraction.ax b/aldor/lib/ax0/src/ax/fraction.ax
index 365fcdb25..2dda78741 100644
--- a/aldor/lib/ax0/src/ax/fraction.ax
+++ b/aldor/lib/ax0/src/ax/fraction.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Export|
(|Declare|
|FractionFunctions2|
diff --git a/aldor/lib/ax0/src/ax/fspace.ax b/aldor/lib/ax0/src/ax/fspace.ax
index 616f9bf40..f7365000b 100644
--- a/aldor/lib/ax0/src/ax/fspace.ax
+++ b/aldor/lib/ax0/src/ax/fspace.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Export|
(|Declare|
|FunctionSpaceFunctions2|
diff --git a/aldor/lib/ax0/src/ax/matcat.ax b/aldor/lib/ax0/src/ax/matcat.ax
index 03d48e38a..f54ec0397 100644
--- a/aldor/lib/ax0/src/ax/matcat.ax
+++ b/aldor/lib/ax0/src/ax/matcat.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Define|
(|Declare|
|SquareMatrixCategory|
diff --git a/aldor/lib/ax0/src/ax/polycat.ax b/aldor/lib/ax0/src/ax/polycat.ax
index afb1319e3..633f609f2 100644
--- a/aldor/lib/ax0/src/ax/polycat.ax
+++ b/aldor/lib/ax0/src/ax/polycat.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Export|
(|Declare|
|CommuteUnivariatePolynomialCategory|
diff --git a/aldor/lib/ax0/src/ax/sf.ax b/aldor/lib/ax0/src/ax/sf.ax
index d83f522c6..457617fe4 100644
--- a/aldor/lib/ax0/src/ax/sf.ax
+++ b/aldor/lib/ax0/src/ax/sf.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Extend|
(|Define|
(|Declare|
diff --git a/aldor/lib/ax0/src/ax/si.ax b/aldor/lib/ax0/src/ax/si.ax
index e7cce1c83..6f1befa74 100644
--- a/aldor/lib/ax0/src/ax/si.ax
+++ b/aldor/lib/ax0/src/ax/si.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Extend|
(|Define|
(|Declare|
diff --git a/aldor/lib/ax0/src/ax/stream.ax b/aldor/lib/ax0/src/ax/stream.ax
index fc8917777..558b24cf9 100644
--- a/aldor/lib/ax0/src/ax/stream.ax
+++ b/aldor/lib/ax0/src/ax/stream.ax
@@ -1,7 +1,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Export|
(|Declare|
|StreamFunctions3|
diff --git a/aldor/lib/ax0/src/ax/vector.ax b/aldor/lib/ax0/src/ax/vector.ax
index 45744ad9c..44fb43f2a 100644
--- a/aldor/lib/ax0/src/ax/vector.ax
+++ b/aldor/lib/ax0/src/ax/vector.ax
@@ -2,7 +2,7 @@
(|Sequence|
(|Import| NIL |AxiomLib|)
(|Import| NIL |Boolean|)
- (|Foreign| (|Declare| |dummyDefault| |Exit|) |Lisp|)
+ (|ForeignImport| (|Declare| |dummyDefault| |Exit|) |Lisp|)
(|Export|
(|Declare|
|DirectProductFunctions2|
From f5c2c98167c5aa6e016410d0c7bbb18f29ceb864 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sat, 30 Sep 2017 16:07:28 +0100
Subject: [PATCH 199/352] aldor/src: Add AB_ForeignExport
Similar to imports, but for exports.
---
aldor/aldor/src/abnorm.c | 37 ++++++++++++++++++++++++++++++++++++-
aldor/aldor/src/absyn.c | 1 +
aldor/aldor/src/absyn.h | 10 ++++++++++
aldor/aldor/src/genfoam.c | 34 ++++++++++++++++++++++++++++++++++
aldor/aldor/src/scobind.c | 25 +++++++++++++++++++++++++
aldor/aldor/src/ti_bup.c | 14 ++++++++++++++
aldor/aldor/src/ti_sef.c | 13 +++++++++++++
aldor/aldor/src/ti_tdn.c | 20 ++++++++++++++++++++
8 files changed, 153 insertions(+), 1 deletion(-)
diff --git a/aldor/aldor/src/abnorm.c b/aldor/aldor/src/abnorm.c
index 4ca7b84d8..ef3e45802 100644
--- a/aldor/aldor/src/abnorm.c
+++ b/aldor/aldor/src/abnorm.c
@@ -990,6 +990,9 @@ abn0ImportSeq(AbSyn ab)
* generated statement looks like [Export [With ...] id].
*/
+local AbSyn abnExportTo(AbSyn ab);
+local AbSyn abnExportToForeign(AbSyn ab);
+
local AbSyn
abnExport(AbSyn ab)
{
@@ -1000,7 +1003,7 @@ abnExport(AbSyn ab)
int i, n = abArgc(ab->abExport.origin);
if (!abHasTag(dest, AB_Nothing))
- return ab;
+ return abnExportTo(ab);
if (abHasTag(dest, AB_Nothing) && abHasTag(origin, AB_Nothing))
return ab;
@@ -1036,6 +1039,38 @@ abnExport(AbSyn ab)
return origin;
}
+local AbSyn
+abnExportTo(AbSyn ab)
+{
+ AbSyn dest = ab->abExport.destination;
+
+ if (abIsTheId(dest, ssymForeign)) {
+ return abnExportToForeign(ab);
+ }
+ else if (abIsApplyOf(dest, ssymForeign)) {
+ return abnExportToForeign(ab);
+ }
+ else {
+ return ab;
+ }
+}
+
+local AbSyn
+abnExportToForeign(AbSyn ab)
+{
+ AbSyn what = ab->abExport.what;
+ AbSyn dest = ab->abExport.destination;
+ AbSyn origin = ab->abExport.origin;
+ SrcPos pos = abPos(ab);
+
+ if (!abIsNothing(origin))
+ return ab;
+
+ abFreeNode(ab);
+
+ return abNewForeignExport(pos, what, dest);
+}
+
/*****************************************************************************
*
* :: Inline
diff --git a/aldor/aldor/src/absyn.c b/aldor/aldor/src/absyn.c
index 400d5c032..4276432ce 100644
--- a/aldor/aldor/src/absyn.c
+++ b/aldor/aldor/src/absyn.c
@@ -1552,6 +1552,7 @@ struct ab_info abInfoTable[] = {
{AB_Fluid, 0, 0, "Fluid", KW_Fluid },
{AB_For, 0, 0, "For", KW_For },
{AB_ForeignImport,0, 0, "ForeignImport",TK_LIMIT },
+ {AB_ForeignExport,0, 0, "ForeignExport",TK_LIMIT },
{AB_Free, 0, 0, "Free", KW_Free },
{AB_Generate, 0, 0, "Generate", KW_Generate },
{AB_Goto, 0, 0, "Goto", KW_Goto },
diff --git a/aldor/aldor/src/absyn.h b/aldor/aldor/src/absyn.h
index 6eb5ff200..9ebb55e03 100644
--- a/aldor/aldor/src/absyn.h
+++ b/aldor/aldor/src/absyn.h
@@ -69,6 +69,7 @@ enum abSynTag {
AB_Fluid,
AB_For,
AB_ForeignImport,
+ AB_ForeignExport,
AB_Free,
AB_Generate,
AB_Goto,
@@ -151,6 +152,7 @@ typedef Enum(abSynTag) AbSynTag;
# define abNewFix(p,b) abNew(AB_Fix, p,1, b)
# define abNewFor(p,v,i,c) abNew(AB_For, p,3, v,i,c)
# define abNewForeignImport(p,w,o) abNew(AB_ForeignImport,p,2, w,o)
+# define abNewForeignExport(p,w,o) abNew(AB_ForeignExport,p,2, w,o)
# define abNewFree(p,b) abNew(AB_Free, p,1, b)
# define abNewGenerate(p,n,e) abNew(AB_Generate, p,2, n,e)
# define abNewGoto(p,l) abNew(AB_Goto, p,1, l)
@@ -503,6 +505,12 @@ struct abForeignImport {
AbSyn origin;
};
+struct abForeignExport {
+ struct abHdr hdr;
+ AbSyn what;
+ AbSyn dest;
+};
+
struct abFree {
struct abHdr hdr;
AbSyn argv[NARY];
@@ -771,6 +779,7 @@ union abSyn {
struct abFluid abFluid;
struct abFor abFor;
struct abForeignImport abForeignImport;
+ struct abForeignExport abForeignExport;
struct abFree abFree;
struct abGenerate abGenerate;
struct abGoto abGoto;
@@ -1165,6 +1174,7 @@ extern AbSyn abNewDocTextOfList (TokenList);
case AB_Fluid: fun##Fluid args; break; \
case AB_For: fun##For args; break; \
case AB_ForeignImport: fun##ForeignImport args; break; \
+ case AB_ForeignExport: fun##ForeignExport args; break; \
case AB_Free: fun##Free args; break; \
case AB_Generate: fun##Generate args; break; \
case AB_Goto: fun##Goto args; break; \
diff --git a/aldor/aldor/src/genfoam.c b/aldor/aldor/src/genfoam.c
index 9b28d67c1..10d066ff1 100644
--- a/aldor/aldor/src/genfoam.c
+++ b/aldor/aldor/src/genfoam.c
@@ -103,6 +103,7 @@ local Foam genWhere (AbSyn);
local Foam genExport (AbSyn);
local Foam genSelect (AbSyn);
local Foam genForeignImport (AbSyn);
+local Foam genForeignExport (AbSyn);
local Foam genRestrict (AbSyn);
/*****************************************************************************
@@ -898,6 +899,9 @@ genFoam(AbSyn absyn)
case AB_ForeignImport:
genForeignImport(absyn);
break;
+ case AB_ForeignExport:
+ genForeignExport(absyn);
+ break;
case AB_Has:
foam = genHas(absyn);
break;
@@ -1099,6 +1103,36 @@ genForeignImport(AbSyn absyn)
return (Foam)NULL;
}
+/*
+ * Generate Foreign inclusion hints.
+ */
+local Foam
+genForeignExport(AbSyn absyn)
+{
+ AbSyn what = absyn->abForeignExport.what;
+ AbSyn dest = absyn->abForeignExport.dest;
+ AbSyn *argv;
+ Symbol sym = gen0ExportingTo(dest);
+ int argc, i;
+
+ AB_SEQ_ITER(what, argc, argv);
+
+ for (i = 0; i < argc; i += 1) {
+ AbSyn ab = argv[i];
+ genFoamStmt(ab);
+ if (sym == ssymBuiltin)
+ gen0ExportToBuiltin(ab);
+ else if (sym == ssymC)
+ gen0ExportToC(ab);
+ else if (sym == ssymFortran)
+ gen0ExportToFortran(ab);
+ else
+ comsgFatal(ab, ALDOR_F_Bug, "Export not implemented");
+ }
+ return 0;
+
+}
+
local Foam
genNever(AbSyn absyn)
{
diff --git a/aldor/aldor/src/scobind.c b/aldor/aldor/src/scobind.c
index f4153ff8b..736bec2af 100644
--- a/aldor/aldor/src/scobind.c
+++ b/aldor/aldor/src/scobind.c
@@ -253,6 +253,7 @@ local void scobindExtend (AbSyn);
local void scobindFluid (AbSyn);
local void scobindFor (AbSyn);
local void scobindForeignImport (AbSyn);
+local void scobindForeignExport (AbSyn);
local void scobindFree (AbSyn);
local void scobindImport (AbSyn);
local void scobindInline (AbSyn);
@@ -616,6 +617,7 @@ scobindValue(AbSyn absyn)
case AB_Fluid:
case AB_For:
case AB_ForeignImport:
+ case AB_ForeignExport:
case AB_Free:
case AB_Import:
case AB_Inline:
@@ -774,6 +776,10 @@ scobindContext(AbSyn absyn)
scobindForeignImport(absyn);
break;
+ case AB_ForeignExport:
+ scobindForeignExport(absyn);
+ break;
+
case AB_Free:
scobindFree(absyn);
break;
@@ -2379,6 +2385,25 @@ scobindExportId(AbSyn id, AbSyn type, AbSyn val)
(AInt) doc);
}
+/******************************************************************************
+ *
+ * :: scobindForeignExport
+ *
+ *****************************************************************************/
+
+local void
+scobindForeignExport(AbSyn ab)
+{
+ AbSyn dest = ab->abForeignExport.dest;
+ AbSyn what = ab->abForeignExport.what;
+
+ scoIsInExport = true;
+
+ scobindLOF(what, SCO_Sig_Local);
+
+ scoIsInExport = false;
+}
+
/******************************************************************************
*
* :: scobindFluid
diff --git a/aldor/aldor/src/ti_bup.c b/aldor/aldor/src/ti_bup.c
index cefb50f08..f6cee3ed9 100644
--- a/aldor/aldor/src/ti_bup.c
+++ b/aldor/aldor/src/ti_bup.c
@@ -130,6 +130,7 @@ local void tibupFix (Stab, AbSyn, TForm);
local void tibupFluid (Stab, AbSyn, TForm);
local void tibupFor (Stab, AbSyn, TForm);
local void tibupForeignImport(Stab, AbSyn, TForm);
+local void tibupForeignExport(Stab, AbSyn, TForm);
local void tibupFree (Stab, AbSyn, TForm);
local void tibupGenerate (Stab, AbSyn, TForm);
local void tibupReference (Stab, AbSyn, TForm);
@@ -2656,6 +2657,19 @@ tibupForeignImport(Stab stab, AbSyn absyn, TForm type)
abTPoss(absyn) = tpossSingleton(tfNone());
}
+/****************************************************************************
+ *
+ * :: Foreign: import ... from Foreign(...)
+ *
+ ***************************************************************************/
+
+local void
+tibupForeignExport(Stab stab, AbSyn absyn, TForm type)
+{
+ tibup(stab, absyn->abForeignExport.what, tfUnknown);
+ abTPoss(absyn) = tpossSingleton(tfNone());
+}
+
/****************************************************************************
*
* :: Import: import ... from D
diff --git a/aldor/aldor/src/ti_sef.c b/aldor/aldor/src/ti_sef.c
index b2c1e5a55..e2f20d170 100644
--- a/aldor/aldor/src/ti_sef.c
+++ b/aldor/aldor/src/ti_sef.c
@@ -82,6 +82,7 @@ local void tisefFix (Stab, Sefo);
local void tisefFluid (Stab, Sefo);
local void tisefFor (Stab, Sefo);
local void tisefForeignImport(Stab, Sefo);
+local void tisefForeignExport(Stab, Sefo);
local void tisefFree (Stab, Sefo);
local void tisefGenerate (Stab, Sefo);
local void tisefReference (Stab, Sefo);
@@ -1015,6 +1016,18 @@ tisefFor(Stab stab, Sefo sefo)
tisef0ApplySymIfNeeded(stab,sefo,1,abForIterArgf,NULL,tfIsGeneratorFn);
}
+/****************************************************************************
+ *
+ * :: ForeignExport: export ... from Foreign(...)
+ *
+ ***************************************************************************/
+
+local void
+tisefForeignExport(Stab stab, Sefo sefo)
+{
+ tisef0Generic(stab, sefo);
+}
+
/****************************************************************************
*
* :: ForeignImport: import ... from Foreign(...)
diff --git a/aldor/aldor/src/ti_tdn.c b/aldor/aldor/src/ti_tdn.c
index cd487193b..5d83dbd7d 100644
--- a/aldor/aldor/src/ti_tdn.c
+++ b/aldor/aldor/src/ti_tdn.c
@@ -117,6 +117,7 @@ local Bool titdnFix (Stab, AbSyn, TForm);
local Bool titdnFluid (Stab, AbSyn, TForm);
local Bool titdnFor (Stab, AbSyn, TForm);
local Bool titdnForeignImport(Stab, AbSyn, TForm);
+local Bool titdnForeignExport(Stab, AbSyn, TForm);
local Bool titdnFree (Stab, AbSyn, TForm);
local Bool titdnGenerate (Stab, AbSyn, TForm);
local Bool titdnGoto (Stab, AbSyn, TForm);
@@ -1930,6 +1931,22 @@ titdnForeignJavaDeclare(Stab stab, AbSyn decl)
return true;
}
+/****************************************************************************
+ *
+ * :: export: export ... to D
+ *
+ ***************************************************************************/
+
+local Bool
+titdnForeignExport(Stab stab, AbSyn absyn, TForm type)
+{
+ AbSyn what = absyn->abForeignExport.what;
+
+ titdn(stab, absyn->abForeignExport.what, tfUnknown);
+
+ abTUnique(absyn) = type;
+ return true;
+}
/****************************************************************************
*
@@ -2791,6 +2808,9 @@ titdnError(Stab stab, AbSyn absyn, TForm type)
case AB_ForeignImport:
titdnError(stab, absyn->abForeignImport.what, tfUnknown);
break;
+ case AB_ForeignExport:
+ titdnError(stab, absyn->abForeignExport.what, tfUnknown);
+ break;
case AB_Import:
titdnError(stab, absyn->abImport.what, tfUnknown);
break;
From 3f44bc7c6605d0feef51be47f9e0b04f072ebc7b Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 1 Oct 2017 12:15:11 +0100
Subject: [PATCH 200/352] java/javaobj.c: Add a common jcoAlloc function
---
aldor/aldor/src/java/javaobj.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/aldor/aldor/src/java/javaobj.c b/aldor/aldor/src/java/javaobj.c
index f0294a014..377fc1db3 100644
--- a/aldor/aldor/src/java/javaobj.c
+++ b/aldor/aldor/src/java/javaobj.c
@@ -7,11 +7,20 @@ CREATE_LIST(JavaCode);
local void jco0Indent(JavaCodePContext ctxt);
+local JavaCode jcoAlloc(int sz);
+
+local JavaCode jcoAlloc(int sz)
+{
+ JavaCode jco = (JavaCode) (stoAlloc(OB_JCode, sz));
+
+ return jco;
+}
+
+
JavaCode
jcoNewNode(JavaCodeClass clss, int argc)
{
- JavaCode jco = (JavaCode) (stoAlloc( (int) OB_JCode,
- fullsizeof(struct jcoNode, argc, JavaCode)));
+ JavaCode jco = jcoAlloc(fullsizeof(struct jcoNode, argc, JavaCode));
assert(clss);
jcoTag(jco) = JCO_JAVA;
@@ -29,7 +38,7 @@ jcoNewToken(JavaCodeClass clss, Symbol sym)
assert(clss && sym);
- jco = (JavaCode) stoAlloc((int) OB_JCode, sizeof(struct jcoToken));
+ jco = jcoAlloc(sizeof(struct jcoToken));
jcoTag(jco) = JCO_TOKEN;
jcoClass(jco) = clss;
jcoPos(jco) = sposNone;
@@ -43,7 +52,8 @@ jcoNewLiteral(JavaCodeClass clss, String txt)
{
JavaCode jco;
assert(clss && txt);
- jco = (JavaCode) stoAlloc((int) OB_JCode, sizeof(struct jcoLiteral));
+ jco = jcoAlloc(sizeof(struct jcoLiteral));
+
jcoTag(jco) = JCO_LIT;
jcoClass(jco) = clss;
jcoPos(jco) = sposNone;
@@ -61,7 +71,7 @@ jcoNewImport(JavaCodeClass clss, String pkg, String name, Bool isImported)
assert(pkg != NULL);
assert(name != NULL);
- jco = (JavaCode) stoAlloc((int) OB_JCode, sizeof(struct jcoImport));
+ jco = jcoAlloc(sizeof(struct jcoImport));
assert(clss && pkg && name);
jcoTag(jco) = JCO_IMPORT;
From 8d03b0ea6ac8fdb750618606a79c1d8c9e99c028 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 1 Oct 2017 12:23:26 +0100
Subject: [PATCH 201/352] foam.c: Add foamGDecl functions
fun facts about globals.
---
aldor/aldor/src/foam.c | 25 +++++++++++++++++++++++++
aldor/aldor/src/foam.h | 3 +++
2 files changed, 28 insertions(+)
diff --git a/aldor/aldor/src/foam.c b/aldor/aldor/src/foam.c
index 48a7a4459..b67a2a056 100644
--- a/aldor/aldor/src/foam.c
+++ b/aldor/aldor/src/foam.c
@@ -2073,6 +2073,31 @@ foamFrString(String s)
return foam;
}
+/*****************************************************************************
+ *
+ * :: FOAM_GDecl
+ *
+ ****************************************************************************/
+
+Bool
+foamGDeclIsExport(Foam foam)
+{
+ return foam->foamGDecl.dir == FOAM_GDecl_Export;
+}
+
+Bool
+foamGDeclIsImport(Foam foam)
+{
+ return foam->foamGDecl.dir == FOAM_GDecl_Import;
+}
+
+Bool
+foamGDeclIsExportOf(AInt tag, Foam foam)
+{
+ return foamGDeclIsExport(foam) && foam->foamGDecl.protocol == tag;
+}
+
+
/*****************************************************************************
*
* :: Byte code conversion to/from Buffer
diff --git a/aldor/aldor/src/foam.h b/aldor/aldor/src/foam.h
index 3dcfa792e..8253f9f41 100644
--- a/aldor/aldor/src/foam.h
+++ b/aldor/aldor/src/foam.h
@@ -683,6 +683,9 @@ struct foamClos {
(AInt)FOAM_Nil,f, \
(AInt)(pr),(AInt)(dir))
#define foamGDeclSetRType(fm,ty) ((fm)->foamGDecl.rtype = (ty))
+extern Bool foamGDeclIsImport(Foam);
+extern Bool foamGDeclIsExport(Foam);
+extern Bool foamGDeclIsExportOf(AInt, Foam);
struct foamGDecl {
struct foamHdr hdr;
From e7823495f45f1e6d8677656ee14a90503ff9690c Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 1 Oct 2017 12:25:31 +0100
Subject: [PATCH 202/352] genc.c: Use foamGDecl functions
---
aldor/aldor/src/genc.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/aldor/aldor/src/genc.c b/aldor/aldor/src/genc.c
index d25430c85..47b4d3deb 100644
--- a/aldor/aldor/src/genc.c
+++ b/aldor/aldor/src/genc.c
@@ -321,7 +321,6 @@ local int gc0IsNewHeader (String);
local void gc0AddHeaderIfNeeded (String);
local CCode gc0ModuleInitFun (String, int);
-local Bool gc0IsGloExported (int);
local CCode gc0ListOf (CCodeTag, CCodeList);
local void gc0AddLineFun (CCodeList *, CCode);
local Bool gc0IsReturn (CCode);
@@ -1147,9 +1146,8 @@ gc0CreateGloList(String name)
/* Handle Exports to C/Fortran */
- if (gc0IsGloExported(i) &&
- (gdecl->foamGDecl.protocol == FOAM_Proto_C ||
- gdecl->foamGDecl.protocol == FOAM_Proto_Fortran)) {
+ if (foamGDeclIsExportOf(FOAM_Proto_C, gdecl)
+ || foamGDeclIsExportOf(FOAM_Proto_Fortran, gdecl)) {
Foam fakedecl;
CCode cco;
@@ -4411,7 +4409,7 @@ gccGetVar(Foam foam)
case FOAM_Proto_Foam:
case FOAM_Proto_Init:
- if (!gc0IsGloExported(idx)) {
+ if (!foamGDeclIsExport(decl)) {
ccode = gc0MultVarId("pG", idx, s);
ccode = ccoParen(ccoPreStar(ccode));
}
@@ -4423,13 +4421,13 @@ gccGetVar(Foam foam)
s = strCopy(s);
s = gc0StompOffIncludeFile(s, FOAM_Proto_C);
}
- if (gc0IsGloExported(idx))
+ if (foamGDeclIsExport(decl))
ccode = gc0MultVarId("G", idx, s);
else
ccode = ccoIdOf(s);
break;
case FOAM_Proto_Fortran:
- if (gc0IsGloExported(idx))
+ if (foamGDeclIsExport(decl))
ccode = gc0MultVarId("G", idx, s);
else {
s = gc0GenFortranName(s);
@@ -6654,15 +6652,6 @@ gc0ModuleInitFun(String modName, int n)
return gc0MultVarId(gcFiInitModulePrefix, n, modName);
}
-local Bool
-gc0IsGloExported(int i)
-{
- Foam decl = gcvGlo->foamDDecl.argv[i];
-
- return (decl->foamGDecl.dir == FOAM_GDecl_Export);
-}
-
-
void
ccodeListPrintDb(CCodeList cl)
{
From 5e310529d61cfd9e99e6edd98b0165bbc6f23557 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 1 Oct 2017 17:09:10 +0100
Subject: [PATCH 203/352] gf_java.c: Remove unused parameter on gfjPCallDecl
---
aldor/aldor/src/gf_java.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/aldor/aldor/src/gf_java.c b/aldor/aldor/src/gf_java.c
index 7b4338ee4..3b21c9993 100644
--- a/aldor/aldor/src/gf_java.c
+++ b/aldor/aldor/src/gf_java.c
@@ -19,7 +19,7 @@ local FoamList gfjProgAddParams(TForm tf);
local FoamTag gfjPCallFoamType(TForm tf, AInt *pfmt);
local Foam gfjPCallFoamToJava(TForm tf, Foam foam);
local Foam gfjPCallJavaToFoam(TForm tf, Foam foam);
-local AInt gfjPCallDecl(TForm tf, Bool);
+local AInt gfjPCallDecl(TForm tf);
local Foam gfjPCallDeclArg(TForm tf);
local AInt gj0ClassDDecl(ForeignOrigin origin, String clsName);
@@ -113,7 +113,7 @@ gfjImportApplyInner(Syme syme, AInt fmtNum)
globName = (forg->file ? strPrintf("%s.%s.%s",
forg->file, symeString(esyme), symeJavaApplyName(syme))
: strPrintf("%s.%s", symeString(esyme), symeJavaApplyName(syme)));
- gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(innerTf, true),
+ gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(innerTf),
FOAM_GDecl_Import, FOAM_Proto_JavaMethod);
gnum = gen0AddGlobal(gdecl);
fnName = strPrintf("%s-inner", symeJavaApplyName(syme));
@@ -176,7 +176,7 @@ gfjImportConstructor(Syme syme)
symString(tfIdSym(exporter)));
constNum = gen0NumProgs;
- gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme), false),
+ gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme)),
FOAM_GDecl_Import, FOAM_Proto_JavaConstructor);
gnum = gen0AddGlobal(gdecl);
@@ -229,7 +229,7 @@ gfjImportStaticCall(Syme syme)
constNum = gen0NumProgs;
- gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme), false),
+ gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme)),
FOAM_GDecl_Import, FOAM_Proto_Java);
gnum = gen0AddGlobal(gdecl);
@@ -335,7 +335,7 @@ gfjPCallJavaToFoam(TForm tf, Foam foam)
}
local AInt
-gfjPCallDecl(TForm tf, Bool method)
+gfjPCallDecl(TForm tf)
{
FoamList decls;
Foam ddecl;
From 00f1bd8eb61688463711329a5681b37218b28822 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 1 Oct 2017 18:42:20 +0100
Subject: [PATCH 204/352] foam.c: Include return type in FOAM_Proto_JavaSig
---
aldor/aldor/src/foam.c | 3 ++-
aldor/aldor/src/gf_java.c | 6 ++++--
aldor/aldor/src/java/genjava.c | 5 ++++-
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/aldor/aldor/src/foam.c b/aldor/aldor/src/foam.c
index b67a2a056..2227884d3 100644
--- a/aldor/aldor/src/foam.c
+++ b/aldor/aldor/src/foam.c
@@ -1153,7 +1153,8 @@ foamAuditPCallJava(Foam foam)
/* Methods have an implicit argument. */
extra = foam->foamPCall.protocol == FOAM_Proto_JavaMethod ? 1 : 0;
- if (foamDDeclArgc(ddecl) + extra != foamPCallArgc(foam))
+ /* dock one for return type */
+ if (foamDDeclArgc(ddecl) + extra - 1 != foamPCallArgc(foam))
foamAuditBadType(foam);
}
diff --git a/aldor/aldor/src/gf_java.c b/aldor/aldor/src/gf_java.c
index 3b21c9993..86050035c 100644
--- a/aldor/aldor/src/gf_java.c
+++ b/aldor/aldor/src/gf_java.c
@@ -338,7 +338,7 @@ local AInt
gfjPCallDecl(TForm tf)
{
FoamList decls;
- Foam ddecl;
+ Foam ddecl, retdecl;
int i;
decls = listNil(Foam);
@@ -349,7 +349,9 @@ gfjPCallDecl(TForm tf)
decls = listCons(Foam)(decl, decls);
}
- ddecl = foamNewDDeclOfList(FOAM_DDecl_JavaSig, listNReverse(Foam)(decls));
+ retdecl = gfjPCallDeclArg(tfMapRet(tf));
+ ddecl = foamNewDDeclOfList(FOAM_DDecl_JavaSig,
+ listCons(Foam)(retdecl, listNReverse(Foam)(decls)));
return gen0AddRealFormat(ddecl);
diff --git a/aldor/aldor/src/java/genjava.c b/aldor/aldor/src/java/genjava.c
index a6b8d5855..67c86426e 100644
--- a/aldor/aldor/src/java/genjava.c
+++ b/aldor/aldor/src/java/genjava.c
@@ -3560,7 +3560,10 @@ gj0PCallCastArgs(Foam op, JavaCodeList argsIn)
JavaCodeList args = argsIn;
Foam glo = gjContextGlobals->foamDDecl.argv[op->foamGlo.index];
Foam ddecl = gjContext->formats->foamDFmt.argv[glo->foamGDecl.format];
- int i = 0;
+ int i = 1;
+
+ assert(ddecl->foamDDecl.usage == FOAM_DDecl_JavaSig);
+ assert(foamDDeclArgc(ddecl) == listLength(JavaCode)(argsIn));
/* Cast java-valued arguments - all other types are not converted */
while (args != listNil(JavaCode)) {
From 9c158866a5fd8d7398c7acb625ad0eced7e83d4f Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 1 Oct 2017 18:42:46 +0100
Subject: [PATCH 205/352] test/Makefile: .ao depends on aldor executable.
---
aldor/aldor/test/Makefile.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/aldor/aldor/test/Makefile.in b/aldor/aldor/test/Makefile.in
index d802d1053..0c6b619e9 100644
--- a/aldor/aldor/test/Makefile.in
+++ b/aldor/aldor/test/Makefile.in
@@ -169,6 +169,7 @@ $(patsubst %, out/ap/%.ap, $(_aotests)): out/ap/%.ap: %.as
mkdir -p $$(dirname $@); \
$(aldorexedir)/aldor $(nfile) -Fap=$@ $(srcdir)/$*.as
+$(patsubst %, out/ao/%.ao, $(_aotests)): $(aldorexedir)/aldor
$(patsubst %, out/ao/%.ao, $(_aotests)): out/ao/%.ao: %.as
$(AM_V_ALDOR) \
mkdir -p $$(dirname $@); \
From 2fb7914d6c24aae19bea18a4d620f958c06847e9 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 8 Oct 2017 19:28:09 +0100
Subject: [PATCH 206/352] src/list.h: Add ListCopier type
---
aldor/aldor/src/list.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/src/list.h b/aldor/aldor/src/list.h
index 9a0daa0c8..84d545027 100644
--- a/aldor/aldor/src/list.h
+++ b/aldor/aldor/src/list.h
@@ -32,6 +32,7 @@
struct ListOpsStructName(Type) const *ListOps(Type) = \
(struct ListOpsStructName(Type) const *) &ptrlistOps
+#define ListCopier(Type) Type (*)(Type)
/*
* Various list operations.
@@ -138,9 +139,9 @@ Statement({ \
Bool (*IsLonger) (List(Type), Length); \
List(Type) (*Copy) (List(Type)); \
List(Type) (*CopyTo) (List(Type), List(Type)); \
- List(Type) (*CopyDeeply) (List(Type), Type (*f)(Type)); \
+ List(Type) (*CopyDeeply) (List(Type), ListCopier(Type)); \
List(Type) (*CopyDeeplyTo) (List(Type), List(Type), \
- Type (*f) (Type) ); \
+ ListCopier(Type)); \
List(Type) (*Map) (Type (*f)(Type), List(Type)); \
List(Type) (*NMap) (Type (*f)(Type), List(Type)); \
List(Type) (*Reverse) (List(Type)); \
From e7ccff5a14cf3c377f296849c5bf7086c1080637 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 8 Oct 2017 19:36:55 +0100
Subject: [PATCH 207/352] javaobj.c: Add path to java imported ids
.. An import is 'pkgname.path.Id', where path is a possibly empty list of
classnames.
---
aldor/aldor/src/java/javacode.c | 72 ++++++++++++++++++++++++---------
aldor/aldor/src/java/javacode.h | 10 ++++-
aldor/aldor/src/java/javaobj.c | 19 +++++++--
aldor/aldor/src/java/javaobj.h | 4 +-
4 files changed, 80 insertions(+), 25 deletions(-)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index 8e9c5e475..ad496e6fa 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -655,17 +655,26 @@ jcCommentSExpr(JavaCode code)
*/
JavaCode
-jcImportedId(String pkg, String name)
+jcImportedIdFrString(String str)
{
- return jcoNewImport(jc0ClassObj(JCO_CLSS_ImportedId), pkg, name, false);
+ String p = strLastIndexOf(str, '.');
+ if (p == NULL) {
+ return jcId(strCopy(str));
+ }
+ else {
+ String pkg = strnCopy(str, p - str);
+ String id = strCopy(p+1);
+ return jcImportedId(pkg, id);
+ }
}
JavaCode
-jcImportedStaticId(String pkg, String name)
+jcImportedId(String pkg, String name)
{
- return jcoNewImport(jc0ClassObj(JCO_CLSS_ImportedStatic), pkg, name, false);
+ return jcoNewImport(jc0ClassObj(JCO_CLSS_ImportedId), pkg, listNil(String), name, false);
}
+
String
jcImportedIdName(JavaCode id)
{
@@ -679,6 +688,47 @@ jcImportedIdPkg(JavaCode id)
}
+JavaCode
+jcImportedStaticId(String pkg, String clss, String name)
+{
+ assert(strLastIndexOf(clss, '.') == NULL);
+ assert(strLastIndexOf(name, '.') == NULL);
+
+ return jcoNewImport(jc0ClassObj(JCO_CLSS_ImportedStatic), pkg,
+ listSingleton(String)(clss), name, false);
+}
+
+JavaCode
+jcImportedStaticIdFrString(String str)
+{
+ String p = strLastIndexOf(str, '.');
+ String id = strCopy(p+1);
+ String pkgClss = strnCopy(str, p - str);
+ String dclss = strLastIndexOf(pkgClss, '.');
+ String clss = strCopy(dclss+1);
+ String pkg = strnCopy(pkgClss, dclss - pkgClss);
+
+ return jcImportedStaticId(pkg, clss, id);
+}
+
+String
+jcImportedStaticIdClass(JavaCode importedId)
+{
+ return car(jcoImportPath(importedId));
+}
+
+
+String
+jcImportedStaticIdPkg(JavaCode importedId)
+{
+ return jcoImportPkg(importedId);
+}
+
+String
+jcImportedStaticIdName(JavaCode importedId)
+{
+ return jcImportedIdName(importedId);
+}
local void
jcImportPrint(JavaCodePContext ctxt, JavaCode code)
{
@@ -1664,17 +1714,3 @@ jcIsId(String word)
return true;
}
-
-JavaCode
-jcImportedIdFrString(String str)
-{
- String p = strLastIndexOf(str, '.');
- if (p == NULL) {
- return jcId(strCopy(str));
- }
- else {
- String pkg = strnCopy(str, p - str);
- String id = strCopy(p+1);
- return jcImportedId(pkg, id);
- }
-}
diff --git a/aldor/aldor/src/java/javacode.h b/aldor/aldor/src/java/javacode.h
index 6e8e9a885..1f522ea97 100644
--- a/aldor/aldor/src/java/javacode.h
+++ b/aldor/aldor/src/java/javacode.h
@@ -85,7 +85,7 @@ extern JavaCodeList jcCollectImports(JavaCode code);
extern JavaCode jcDocumented(String comment, JavaCode code);
extern JavaCode jcComment(String comment);
extern JavaCode jcImportedId(String pkg, String name);
-extern JavaCode jcImportedStaticId(String pkg, String name);
+extern JavaCode jcImportedStaticId(String pkg, String clss, String name);
extern JavaCode jcLiteralString(String s);
extern JavaCode jcLiteralStringWithTerminalChar(String s);
extern JavaCode jcLiteralChar(String s);
@@ -157,9 +157,15 @@ extern SExpr jcNodeSExpr(JavaCode code);
extern void jcNodePrint(JavaCodePContext ctxt, JavaCode code);
extern Bool jcIsLegalClassName(String word);
+extern JavaCode jcIdFrImported(JavaCode id);
+extern JavaCode jcImportedIdFrString(String str);
extern String jcImportedIdName(JavaCode);
extern String jcImportedIdPkg(JavaCode);
-extern JavaCode jcImportedIdFrString(String str);
+
+extern JavaCode jcImportedStaticIdFrString(String str);
+extern String jcImportedStaticIdName(JavaCode);
+extern String jcImportedStaticIdClass(JavaCode);
+extern String jcImportedStaticIdPkg(JavaCode);
extern String jcIdName(JavaCode);
diff --git a/aldor/aldor/src/java/javaobj.c b/aldor/aldor/src/java/javaobj.c
index 377fc1db3..2025918ee 100644
--- a/aldor/aldor/src/java/javaobj.c
+++ b/aldor/aldor/src/java/javaobj.c
@@ -65,7 +65,7 @@ jcoNewLiteral(JavaCodeClass clss, String txt)
JavaCode
-jcoNewImport(JavaCodeClass clss, String pkg, String name, Bool isImported)
+jcoNewImport(JavaCodeClass clss, String pkg, StringList path, String name, Bool isImported)
{
JavaCode jco;
assert(pkg != NULL);
@@ -77,8 +77,9 @@ jcoNewImport(JavaCodeClass clss, String pkg, String name, Bool isImported)
jcoTag(jco) = JCO_IMPORT;
jcoClass(jco) = clss;
jcoPos(jco) = sposNone;
- jco->import.pkg = pkg;
- jco->import.id = name;
+ jco->import.pkg = pkg;
+ jco->import.path = path;
+ jco->import.id = name;
jcoImportSetImported(jco, isImported);
return jco;
@@ -155,7 +156,10 @@ jcoCopy(JavaCode code)
return jcoNewToken(jcoClass(code), jcoToken(code));
if (jcoIsImport(code))
return jcoNewImport(jcoClass(code),
- jcoImportPkg(code), jcoImportId(code),
+ jcoImportPkg(code),
+ listCopyDeeply(String)(jcoImportPath(code),
+ (ListCopier(String)) strCopy),
+ jcoImportId(code),
jcoImportIsImported(code));
if (jcoIsNode(code)) {
JavaCodeList l = listNil(JavaCode);
@@ -209,6 +213,13 @@ jcoImportPkg(JavaCode jco)
return jco->import.pkg;
}
+extern StringList
+jcoImportPath(JavaCode jco)
+{
+ assert(jcoIsImport(jco));
+ return jco->import.path;
+}
+
extern String
jcoImportId(JavaCode jco)
{
diff --git a/aldor/aldor/src/java/javaobj.h b/aldor/aldor/src/java/javaobj.h
index 49803d1d0..b56b331bf 100644
--- a/aldor/aldor/src/java/javaobj.h
+++ b/aldor/aldor/src/java/javaobj.h
@@ -793,6 +793,7 @@ struct jcoLiteral {
struct jcoImport {
struct jcoHdr hdr;
String pkg;
+ StringList path;
String id;
Bool isImported;
};
@@ -819,13 +820,14 @@ extern String jcoLiteral(JavaCode jco);
extern String jcoImportPkg(JavaCode jco);
extern String jcoImportId(JavaCode jco);
+extern StringList jcoImportPath(JavaCode jco);
extern Bool jcoImportIsImported(JavaCode jco);
extern void jcoImportSetImported(JavaCode jco, Bool flg);
extern JavaCode jcoNewNode(JavaCodeClass class, int argc);
extern JavaCode jcoNewToken(JavaCodeClass class, Symbol sym);
extern JavaCode jcoNewLiteral(JavaCodeClass class, String str);
-extern JavaCode jcoNewImport(JavaCodeClass class, String pkg, String id, Bool flg);
+extern JavaCode jcoNewImport(JavaCodeClass class, String pkg, StringList path, String id, Bool flg);
extern JavaCode jcoNew(JavaCodeClass class, int argc, ...);
extern JavaCode jcoNewP(JavaCodeClass clss, int argc, va_list argp);
extern JavaCode jcoNewFrList(JavaCodeClass class, JavaCodeList lst);
From d1f20e8e0f6bbc1374d6301cadcdbefb6f8c82fc Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 31 Dec 2017 15:03:37 +0000
Subject: [PATCH 208/352] src/java/javacode.c: Correct escaping of quote
characters in strings. BUGFIX!
---
aldor/aldor/src/java/javacode.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index ad496e6fa..4963380a1 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -1655,9 +1655,6 @@ jc0EscapeString(String s, Bool addTerminalChar)
case '\\':
bufPuts(buf, "\\\\");
break;
- case '\'':
- bufPuts(buf, "\\\\");
- break;
case '\n':
bufPuts(buf, "\\\n");
break;
From fa824c9b4d5986fe9c7f12051e2c1de4477aa5e4 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 31 Dec 2017 15:06:23 +0000
Subject: [PATCH 209/352] src/java/javacode.c: Add generic ids and method calls
---
aldor/aldor/src/java/javacode.c | 47 ++++++++++++++++++++++++++++++++-
aldor/aldor/src/java/javacode.h | 7 +++++
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index 4963380a1..184b2bdff 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -268,7 +268,7 @@ static struct jclss jcClss[] = {
{ JCO_CLSS_CommaSeq, jcSequencePrint,jcNodeSExpr, "commaseq", ", "},
{ JCO_CLSS_SpaceSeq, jcSequencePrint,jcNodeSExpr, "spaceseq", " "},
{ JCO_CLSS_NLSeq, jcSequencePrint,jcNodeSExpr, "nlseq", "\n"},
- { JCO_CLSS_Seq, jcSequencePrint,jcNodeSExpr, "seq"},
+ { JCO_CLSS_Seq, jcSequencePrint,jcNodeSExpr, "seq", ""},
{ JCO_CLSS_Parens, jcParenPrint, jcNodeSExpr, "paren", "()", 15, JCO_NONE },
{ JCO_CLSS_Braces, jcParenPrint, jcNodeSExpr, "braces", "{}", 15, JCO_NONE },
{ JCO_CLSS_SqBrackets, jcParenPrint, jcNodeSExpr, "sqbracket", "[]", 15, JCO_NONE },
@@ -557,6 +557,23 @@ jcApplyPrint(JavaCodePContext ctxt, JavaCode code)
jcoWrite(ctxt, jcoArgv(code)[1]);
}
+JavaCode
+jcGenericMethodName(JavaCode methodName, JavaCodeList genArgs)
+{
+ return jcSeqV(2, jcABrackets(jcCommaSeq(genArgs)));
+}
+
+JavaCode
+jcGenericMethodNameV(JavaCode methodName, int n, ...)
+{
+ JavaCode jc;
+ va_list argp;
+ va_start(argp, n);
+ jc = jcSeqV(2, jcABrackets(jcCommaSeqP(n, argp)), methodName);
+ va_end(argp);
+ return jc;
+}
+
/*
* :: Parens
@@ -935,6 +952,17 @@ jcIdPrint(JavaCodePContext ctxt, JavaCode code)
jcoPContextWrite(ctxt, name);
}
+
+/*
+ * :: Generic id
+ */
+JavaCode
+jcGenericId(JavaCode root, JavaCodeList genArgs)
+{
+ return jcSeqV(2, root, jcABrackets(jcCommaSeq(genArgs)));
+}
+
+
/*
* :: Constructor Call
*/
@@ -1296,6 +1324,23 @@ jcCommaSeqP(int n, va_list argp)
return jcoNewP(jc0ClassObj(JCO_CLSS_CommaSeq), n, argp);
}
+JavaCode
+jcSeq(JavaCodeList lst)
+{
+ return jcoNewFrList(jc0ClassObj(JCO_CLSS_Seq), lst);
+}
+
+JavaCode
+jcSeqV(int n, ...)
+{
+ va_list argp;
+ JavaCode jc;
+ va_start(argp, n);
+ jc = jcoNewP(jc0ClassObj(JCO_CLSS_Seq), n, argp);
+ va_end(argp);
+ return jc;
+}
+
JavaCode
jcNLSeq(JavaCodeList lst)
{
diff --git a/aldor/aldor/src/java/javacode.h b/aldor/aldor/src/java/javacode.h
index 1f522ea97..52be58b21 100644
--- a/aldor/aldor/src/java/javacode.h
+++ b/aldor/aldor/src/java/javacode.h
@@ -56,6 +56,8 @@ extern JavaCode jcThis();
extern JavaCode jcTrue();
extern JavaCode jcFalse();
+extern JavaCode jcGenericId(JavaCode root, JavaCodeList genArgs);
+
extern JavaCode jcClass(int modifiers, String comment,
JavaCode id, JavaCode superclass,
JavaCodeList implList, JavaCodeList body);
@@ -120,6 +122,8 @@ extern JavaCode jcMemRef(JavaCode lhs, JavaCode rhs);
extern JavaCode jcCast(JavaCode type, JavaCode val);
extern JavaCode jcStatement(JavaCode stmt);
+extern JavaCode jcSeq(JavaCodeList lst);
+extern JavaCode jcSeqV(int n, ...);
extern JavaCode jcCommaSeq(JavaCodeList lst);
extern JavaCode jcCommaSeqP(int n, va_list l);
extern JavaCode jcSpaceSeq(JavaCodeList lst);
@@ -138,6 +142,9 @@ extern JavaCode jcApplyP(JavaCode c, int n, va_list argp);
extern JavaCode jcApplyMethod(JavaCode obj, JavaCode id, JavaCodeList args);
extern JavaCode jcApplyMethodV(JavaCode obj, JavaCode id, int n, ...);
+extern JavaCode jcGenericMethodName(JavaCode methodName, JavaCodeList genArgs);
+extern JavaCode jcGenericMethodNameV(JavaCode methodName, int n, ...);
+
extern JavaCode jcNAry(JavaCode t);
extern JavaCode jcArrayOf(JavaCode t);
extern JavaCode jcArrayNew(JavaCode t, JavaCode sz);
From 8be31714a35ff411127d68550e02d0db012d49e9 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 31 Dec 2017 15:08:55 +0000
Subject: [PATCH 210/352] src/java/javacode.c: jcCollectImports needs to track
usages
So we don't import the same id twice from two packages.
Pass around a table to do it nicely
---
aldor/aldor/src/java/javacode.c | 37 ++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index 184b2bdff..51adc964e 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -1626,30 +1626,37 @@ jc0ModifierSymbol(int idx)
local Bool jc0ImportEq(JavaCode c1, JavaCode c2);
-local void jc0CollectImports(Table tbl, JavaCode code);
+local void jc0CollectImports(Table tbl, Table nameTbl, JavaCode code);
JavaCodeList
jcCollectImports(JavaCode code)
{
Table tbl = tblNew((TblHashFun) jcoHash, (TblEqFun) jc0ImportEq);
+ Table nameTbl = tblNew((TblHashFun) strHash, (TblEqFun) strEqual);
TableIterator it;
JavaCodeList resList = listNil(JavaCode);
- jc0CollectImports(tbl, code);
+ jc0CollectImports(tbl, nameTbl, code);
for (tblITER(it, tbl); tblMORE(it); tblSTEP(it)) {
JavaCode id = (JavaCode) tblKEY(it);
JavaCodeList codes = (JavaCodeList) tblELT(it);
JavaCodeList tmp;
- JavaCode cp = jcImportedId(jcoImportPkg(id), jcoImportId(id));
- resList = listCons(JavaCode)(cp, resList);
- tmp = codes;
- while (tmp != 0) {
- JavaCode imp = car(tmp);
- jcoImportSetImported(imp, true);
- tmp = cdr(tmp);
+ JavaCode copy = jcImportedId(jcoImportPkg(id), jcoImportId(id));
+ JavaCodeList usages = (JavaCodeList) tblElt(nameTbl, jcoImportId(id), listNil(JavaCode));
+ if (cdr(usages) != listNil(JavaCode)) {
+ continue;
+ }
+ else {
+ resList = listCons(JavaCode)(copy, resList);
+ tmp = codes;
+ while (tmp != 0) {
+ JavaCode imp = car(tmp);
+ jcoImportSetImported(imp, true);
+ tmp = cdr(tmp);
+ }
+ listFree(JavaCode)(codes);
}
- listFree(JavaCode)(codes);
}
return resList;
}
@@ -1669,7 +1676,7 @@ jc0ImportEq(JavaCode c1, JavaCode c2)
local void
-jc0CollectImports(Table tbl, JavaCode code)
+jc0CollectImports(Table tbl, Table nameTbl, JavaCode code)
{
if (code == 0)
return;
@@ -1678,11 +1685,17 @@ jc0CollectImports(Table tbl, JavaCode code)
JavaCode key = code;
l = listCons(JavaCode)(code, l);
tblSetElt(tbl, key, l);
+
+ String name = jcoImportId(code);
+ JavaCodeList ids = (JavaCodeList) tblElt(nameTbl, name, listNil(JavaCode));
+ if (!listMember(JavaCode)(ids, code, jc0ImportEq)) {
+ tblSetElt(nameTbl, name, (TblElt) listCons(JavaCode)(code, ids));
+ }
}
if (jcoIsNode(code)) {
int i=0;
for (i=0; i
Date: Sun, 31 Dec 2017 15:13:22 +0000
Subject: [PATCH 211/352] src/java/javacode.c: Add try/catch functions
---
aldor/aldor/src/java/javacode.c | 50 +++++++++++++++++++++++++++++++++
aldor/aldor/src/java/javacode.h | 3 ++
2 files changed, 53 insertions(+)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index 51adc964e..6b972ec41 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -34,6 +34,9 @@ enum jc_clss_enum {
JCO_CLSS_Switch,
JCO_CLSS_Case,
JCO_CLSS_Block,
+ JCO_CLSS_Try,
+ JCO_CLSS_Catch,
+ JCO_CLSS_Finally,
JCO_CLSS_ArrRef,
JCO_CLSS_MemRef,
@@ -193,6 +196,7 @@ local JWriteFn jcApplyPrint;
local JWriteFn jcARefPrint;
local JWriteFn jcBinOpPrint;
local JWriteFn jcBlockHdrPrint;
+local JWriteFn jcBlockKeywordPrint;
local JWriteFn jcBlockPrint;
local JWriteFn jcCasePrint;
local JWriteFn jcCastPrint;
@@ -288,6 +292,9 @@ static struct jclss jcClss[] = {
{ JCO_CLSS_Switch, jcBlockHdrPrint, jcNodeSExpr, "switch", "switch"},
{ JCO_CLSS_Case, jcCasePrint, jcNodeSExpr, "case", "case"},
{ JCO_CLSS_Block, jcBlockPrint, jcNodeSExpr, "block"},
+ { JCO_CLSS_Try, jcBlockKeywordPrint, jcNodeSExpr, "try", "try"},
+ { JCO_CLSS_Catch, jcBlockHdrPrint, jcNodeSExpr, "catch", "catch"},
+ { JCO_CLSS_Finally, jcBlockKeywordPrint, jcNodeSExpr, "finally", "finally"},
{ JCO_CLSS_ArrRef, jcARefPrint, jcNodeSExpr, "arrayref", 0, 20, JCO_NONE},
{ JCO_CLSS_MemRef, jcBinOpPrint, jcNodeSExpr, "memref", ".", 20, JCO_NONE},
@@ -1444,6 +1451,32 @@ jcCasePrint(JavaCodePContext ctxt, JavaCode code)
jcoPContextWrite(ctxt, ": ");
}
+JavaCode
+jcTryCatch(JavaCode body, JavaCode catch, JavaCode finally)
+{
+ return jcTry(body, listSingleton(JavaCode)(catch), finally);
+}
+
+JavaCode
+jcTry(JavaCode body, JavaCodeList catches, JavaCode finally)
+{
+ JavaCodeList lst = listNil(JavaCode);
+ lst = listCons(JavaCode)(jcoNew(jc0ClassObj(JCO_CLSS_Try), 1, body), lst);
+ lst = listNConcat(JavaCode)(lst, catches);
+ if (finally != NULL) {
+ lst = listNConcat(JavaCode)(lst,
+ listSingleton(JavaCode)(jcoNew(jc0ClassObj(JCO_CLSS_Finally),
+ 1, finally)));
+ }
+ return jcNLSeq(lst);
+}
+
+JavaCode
+jcCatch(JavaCode decl, JavaCode body)
+{
+ return jcoNew(jc0ClassObj(JCO_CLSS_Catch), 2, decl, body);
+}
+
/*
* :: Import, Package
*/
@@ -1512,6 +1545,23 @@ jcBlockHdrPrint(JavaCodePContext ctxt, JavaCode code)
}
+local void
+jcBlockKeywordPrint(JavaCodePContext ctxt, JavaCode code)
+{
+ Bool needsIndent;
+ char *key = (char *) jcoClass(code)->txt;
+ jcoPContextWrite(ctxt, key);
+ jcoPContextWrite(ctxt, " ");
+
+ needsIndent = jcBlockHdrIndent(jcoArgv(code)[0]);
+ if (needsIndent)
+ jcoPContextNewlineIndent(ctxt);
+ jcoWrite(ctxt, jcoArgv(code)[0]);
+ if (needsIndent)
+ jcoPContextNewlineUnindent(ctxt);
+
+}
+
local Bool
jcBlockHdrIndent(JavaCode code)
{
diff --git a/aldor/aldor/src/java/javacode.h b/aldor/aldor/src/java/javacode.h
index 52be58b21..897dd3e3f 100644
--- a/aldor/aldor/src/java/javacode.h
+++ b/aldor/aldor/src/java/javacode.h
@@ -111,6 +111,9 @@ extern JavaCode jcWhile(JavaCode test, JavaCode stmt);
extern JavaCode jcSwitch(JavaCode test, JavaCodeList body);
extern JavaCode jcCaseLabel(JavaCode arg);
extern JavaCode jcThrow(JavaCode arg);
+extern JavaCode jcTry(JavaCode body, JavaCodeList catchers, JavaCode finally);
+extern JavaCode jcTryCatch(JavaCode body, JavaCode catch, JavaCode finally);
+extern JavaCode jcCatch(JavaCode decl, JavaCode body);
extern JavaCode jcOp(JcOperation op, JavaCodeList args);
extern JavaCode jcBinOp(JcOperation op, JavaCode e1, JavaCode e2);
From 06940a5b22bbc68239d3f2d54560b54a21c45399 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Fri, 1 Dec 2017 21:32:53 +0000
Subject: [PATCH 212/352] javacode.c: Support empty list of interfaces
---
aldor/aldor/src/java/javacode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index 6b972ec41..de8a6499c 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -353,7 +353,7 @@ jcClass(int modifiers, String comment,
5,
jcSpaceSeq(jcmods),
id, superclass,
- jcCommaSeq(extendList),
+ extendList == listNil(JavaCode) ? NULL : jcCommaSeq(extendList),
jcNLSeq(body));
if (comment == NULL)
return clss;
From b3ecb9b52bbea18181c30072680f4725883eb5f1 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 8 Oct 2017 19:43:10 +0100
Subject: [PATCH 213/352] java: Add jcLocal/Member/Param declarations
(instead of rolling them into one - they do the same thing really).
---
aldor/aldor/src/java/genjava.c | 4 ++--
aldor/aldor/src/java/javacode.c | 18 ++++++++++++++----
aldor/aldor/src/java/javacode.h | 2 ++
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/aldor/aldor/src/java/genjava.c b/aldor/aldor/src/java/genjava.c
index 67c86426e..cd7796c7d 100644
--- a/aldor/aldor/src/java/genjava.c
+++ b/aldor/aldor/src/java/genjava.c
@@ -3197,7 +3197,7 @@ gj0ClassFields()
int i;
/* private FoamContext ctxt;*/
- ctxtDecl = jcParamDecl(JCO_MOD_Private,
+ ctxtDecl = jcMemberDecl(JCO_MOD_Private,
gj0Id(GJ_FoamContext), gj0Id(GJ_ContextVar));
vars = listNil(JavaCode);
@@ -3206,7 +3206,7 @@ gj0ClassFields()
if (decl->foamGDecl.protocol != FOAM_Proto_Init)
continue;
- declJ = jcParamDecl(JCO_MOD_Private,
+ declJ = jcMemberDecl(JCO_MOD_Private,
gj0TypeFrFmt(FOAM_Clos, 0),
jcId(gj0InitVar(i)));
vars = listCons(JavaCode)(jcStatement(declJ), vars);
diff --git a/aldor/aldor/src/java/javacode.c b/aldor/aldor/src/java/javacode.c
index de8a6499c..3e39d1b43 100644
--- a/aldor/aldor/src/java/javacode.c
+++ b/aldor/aldor/src/java/javacode.c
@@ -466,10 +466,20 @@ jcDeclaration(int modifiers,
return jcoNewFrList(jc0ClassObj(JCO_CLSS_Declaration), l);
}
-JavaCode
-jcParamDecl(int modifiers,
- JavaCode type,
- JavaCode id)
+JavaCode
+jcMemberDecl(int modifiers, JavaCode type, JavaCode id)
+{
+ return jcDeclaration(modifiers, type, id, 0, 0, 0);
+}
+
+JavaCode
+jcParamDecl(int modifiers, JavaCode type, JavaCode id)
+{
+ return jcDeclaration(modifiers, type, id, 0, 0, 0);
+}
+
+JavaCode
+jcLocalDecl(int modifiers, JavaCode type, JavaCode id)
{
return jcDeclaration(modifiers, type, id, 0, 0, 0);
}
diff --git a/aldor/aldor/src/java/javacode.h b/aldor/aldor/src/java/javacode.h
index 897dd3e3f..c59721169 100644
--- a/aldor/aldor/src/java/javacode.h
+++ b/aldor/aldor/src/java/javacode.h
@@ -78,7 +78,9 @@ extern JavaCode jcDeclaration(int modifiers,
JavaCode id, JavaCodeList genArgs,
JavaCode args,
JavaCodeList exns);
+extern JavaCode jcMemberDecl(int modifiers, JavaCode type, JavaCode id);
extern JavaCode jcParamDecl(int modifiers, JavaCode type, JavaCode id);
+extern JavaCode jcLocalDecl(int modifiers, JavaCode type, JavaCode id);
extern JavaCode jcInitialisation(int modifiers, JavaCode type,
JavaCode id, JavaCode value);
From 84d7b56e2eded3be91d81e2be18844511186484a Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 31 Dec 2017 14:56:00 +0000
Subject: [PATCH 214/352] src/formatters.c: Add JavaCode to printable objects
---
aldor/aldor/src/formatters.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/aldor/aldor/src/formatters.c b/aldor/aldor/src/formatters.c
index 9e10954af..b5e2ba572 100644
--- a/aldor/aldor/src/formatters.c
+++ b/aldor/aldor/src/formatters.c
@@ -5,6 +5,7 @@
#include "symeset.h"
#include "freevar.h"
#include "bigint.h"
+#include "java/javacode.h"
#include "ostream.h"
#include "format.h"
#include "sefo.h"
@@ -42,6 +43,7 @@ local int bintFormatter(OStream stream, Pointer p);
local int symbolFormatter(OStream stream, Pointer p);
local int errorSetFormatter(OStream stream, Pointer p);
+local int javaCodeFormatter(OStream stream, Pointer p);
void
@@ -76,6 +78,7 @@ fmttsInit()
fmtRegister("Symbol", symbolFormatter);
fmtRegister("ErrorSet", errorSetFormatter);
+ fmtRegister("JavaCode", javaCodeFormatter);
}
@@ -201,6 +204,16 @@ errorSetFormatter(OStream ostream, Pointer p)
return i;
}
+local int
+javaCodeFormatter(OStream ostream, Pointer p)
+{
+ JavaCode jco = (JavaCode) p;
+ int c;
+
+ c = ostreamPrintf(ostream, "%pSExpr", jcoSExpr(jco));
+
+ return c;
+}
local int
tconstFormatter(OStream ostream, Pointer p)
{
From 0103330804bf177fa57716ab58dde0e8fe85f1b4 Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Sun, 8 Oct 2017 20:44:33 +0100
Subject: [PATCH 215/352] gf_java.c: Use base type of domain when building java
signatures
---
aldor/aldor/src/gf_java.c | 41 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/aldor/aldor/src/gf_java.c b/aldor/aldor/src/gf_java.c
index 86050035c..72eb433cd 100644
--- a/aldor/aldor/src/gf_java.c
+++ b/aldor/aldor/src/gf_java.c
@@ -8,6 +8,7 @@
#include "strops.h"
#include "symbol.h"
#include "spesym.h"
+#include "util.h"
local AInt gfjFindConst(Syme syme);
local Foam gfjImportApply(Syme syme);
@@ -16,6 +17,8 @@ local Foam gfjImportConstructor(Syme syme);
local Foam gfjImportStaticCall(Syme syme);
local FoamList gfjProgAddParams(TForm tf);
+local TForm gfjPCallArgBaseJavaType(TForm tf);
+local TForm gfjPCallRetBaseJavaType(TForm tf);
local FoamTag gfjPCallFoamType(TForm tf, AInt *pfmt);
local Foam gfjPCallFoamToJava(TForm tf, Foam foam);
local Foam gfjPCallJavaToFoam(TForm tf, Foam foam);
@@ -344,7 +347,7 @@ gfjPCallDecl(TForm tf)
decls = listNil(Foam);
for (i=0; i
Date: Tue, 10 Oct 2017 22:35:51 +0100
Subject: [PATCH 216/352] of_inlin.c: Look through cast a bit better. Fix up
transformation of
(EElt n (Env m) a b) --> (Lex (m+a) b)
---
aldor/aldor/src/inlutil.c | 27 ++++++++++++++++++++++++++-
aldor/aldor/src/of_inlin.c | 8 +++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/aldor/aldor/src/inlutil.c b/aldor/aldor/src/inlutil.c
index 097758817..297174b50 100644
--- a/aldor/aldor/src/inlutil.c
+++ b/aldor/aldor/src/inlutil.c
@@ -32,6 +32,8 @@ Bool inuProgDebug = false;
#define inuReachingDef(foam) ((Foam) udReachingDefs(foam))
+local Foam inuDereferencePeep(Foam orig);
+
/* Make one step through the use/def chain. */
local Foam
inuDereference(Foam foam)
@@ -73,12 +75,35 @@ inuDereferenceSyme(Foam foam)
local Foam
inuDereferenceClos(Foam foam)
{
- while (foam && foamTag(foam) != FOAM_Clos && inuIsVar(foam))
+ while (foam && foamTag(foam) != FOAM_Clos && inuIsVar(foam)) {
foam = inuDereference(foam);
+ foam = inuDereferencePeep(foam);
+ }
return (foam && foamTag(foam) == FOAM_Clos) ? foam : NULL;
}
+local Foam
+inuDereferencePeep(Foam orig)
+{
+ Foam foam = orig;
+ Foam ret = orig;
+
+ if (foam && foamTag(foam) == FOAM_Cast &&
+ foam->foamCast.type == FOAM_Clos) {
+ foam = foam->foamCast.expr;
+ while (foamTag(foam) == FOAM_Cast) {
+ foam = foam->foamCast.expr;
+ }
+ if (foamTag(foam) == FOAM_Clos) {
+ ret = foam;
+ }
+ }
+
+ return ret;
+}
+
+
/*****************************************************************************
*
* :: inuGetClos
diff --git a/aldor/aldor/src/of_inlin.c b/aldor/aldor/src/of_inlin.c
index e97451777..13fc868a8 100644
--- a/aldor/aldor/src/of_inlin.c
+++ b/aldor/aldor/src/of_inlin.c
@@ -3235,6 +3235,12 @@ inlTransformExpr(Foam expr, Foam *paramArgv, Foam *localArgv)
/* Fall through and transform as before */
}
+ if (foamTag(expr) == FOAM_EElt &&
+ foamTag(expr->foamEElt.ref) == FOAM_Env) {
+ expr = foamNewLex(expr->foamEElt.level + expr->foamEElt.ref->foamEnv.level,
+ expr->foamEElt.lex);
+ tag = FOAM_Lex;
+ }
/* Recursive depth-first transformation of the expression */
foamIter(expr, arg, *arg = inlTransformExpr(*arg,paramArgv,localArgv));
@@ -3250,7 +3256,7 @@ inlTransformExpr(Foam expr, Foam *paramArgv, Foam *localArgv)
localArgv[expr->foamLoc.index]->foamLoc.index;
break;
case FOAM_Lex:
- nexpr = inlLex(nexpr);
+ nexpr = inlLex(expr);
break;
case FOAM_Env:
nexpr = inlEnv(nexpr);
From 710f0fdcb0601b6d6c5e2e2ee6700b068a7139ec Mon Sep 17 00:00:00 2001
From: Peter Broadbery
Date: Tue, 10 Oct 2017 22:39:28 +0100
Subject: [PATCH 217/352] gf_java: Java PCalls need an explicit "this" in their
format
Otherwise it just gets too confusing.
---
aldor/aldor/src/foam.c | 4 +---
aldor/aldor/src/gf_java.c | 29 ++++++++++++++++++++---------
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/aldor/aldor/src/foam.c b/aldor/aldor/src/foam.c
index 2227884d3..7e3d67ecf 100644
--- a/aldor/aldor/src/foam.c
+++ b/aldor/aldor/src/foam.c
@@ -1151,10 +1151,8 @@ foamAuditPCallJava(Foam foam)
glo = faGlobalsv[op->foamGlo.index];
ddecl = faFormats->foamDFmt.argv[glo->foamGDecl.format];
- /* Methods have an implicit argument. */
- extra = foam->foamPCall.protocol == FOAM_Proto_JavaMethod ? 1 : 0;
/* dock one for return type */
- if (foamDDeclArgc(ddecl) + extra - 1 != foamPCallArgc(foam))
+ if (foamDDeclArgc(ddecl) - 1 != foamPCallArgc(foam))
foamAuditBadType(foam);
}
diff --git a/aldor/aldor/src/gf_java.c b/aldor/aldor/src/gf_java.c
index 72eb433cd..fcfb3c3c3 100644
--- a/aldor/aldor/src/gf_java.c
+++ b/aldor/aldor/src/gf_java.c
@@ -2,6 +2,7 @@
#include "gf_util.h"
#include "gf_prog.h"
#include "gf_java.h"
+#include "gf_syme.h"
#include "of_inlin.h"
#include "tform.h"
#include "sefo.h"
@@ -22,7 +23,7 @@ local TForm gfjPCallRetBaseJavaType(TForm tf);
local FoamTag gfjPCallFoamType(TForm tf, AInt *pfmt);
local Foam gfjPCallFoamToJava(TForm tf, Foam foam);
local Foam gfjPCallJavaToFoam(TForm tf, Foam foam);
-local AInt gfjPCallDecl(TForm tf);
+local AInt gfjPCallDecl(TForm tf, TForm this);
local Foam gfjPCallDeclArg(TForm tf);
local AInt gj0ClassDDecl(ForeignOrigin origin, String clsName);
@@ -86,7 +87,7 @@ gfjImportApply(Syme syme)
gen0ProgFiniEmpty(prog, FOAM_Word, emptyFormatSlot);
foamOptInfo(prog) = inlInfoNew(NULL, prog, NULL, false);
gen0ProgRestoreState(saved);
-
+ genSetConstNum(syme, -1, constNum, true);
return foamNewClos(foamNewEnv(int0), foamNewConst(constNum));
}
@@ -116,7 +117,8 @@ gfjImportApplyInner(Syme syme, AInt fmtNum)
globName = (forg->file ? strPrintf("%s.%s.%s",
forg->file, symeString(esyme), symeJavaApplyName(syme))
: strPrintf("%s.%s", symeString(esyme), symeJavaApplyName(syme)));
- gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(innerTf),
+ gdecl = foamNewGDecl(FOAM_Word, globName,
+ gfjPCallDecl(innerTf, tfMapArgN(symeType(syme), 0)),
FOAM_GDecl_Import, FOAM_Proto_JavaMethod);
gnum = gen0AddGlobal(gdecl);
fnName = strPrintf("%s-inner", symeJavaApplyName(syme));
@@ -179,7 +181,7 @@ gfjImportConstructor(Syme syme)
symString(tfIdSym(exporter)));
constNum = gen0NumProgs;
- gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme)),
+ gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme), NULL),
FOAM_GDecl_Import, FOAM_Proto_JavaConstructor);
gnum = gen0AddGlobal(gdecl);
@@ -201,6 +203,7 @@ gfjImportConstructor(Syme syme)
foamOptInfo(prog) = inlInfoNew(NULL, prog, NULL, false);
gen0ProgRestoreState(saved);
+ genSetConstNum(syme, -1, constNum, true);
return foamNewClos(foamNewEnv(int0), foamNewConst(constNum));
}
@@ -232,7 +235,7 @@ gfjImportStaticCall(Syme syme)
constNum = gen0NumProgs;
- gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme)),
+ gdecl = foamNewGDecl(FOAM_Word, globName, gfjPCallDecl(symeType(syme), NULL),
FOAM_GDecl_Import, FOAM_Proto_Java);
gnum = gen0AddGlobal(gdecl);
@@ -253,6 +256,7 @@ gfjImportStaticCall(Syme syme)
foamOptInfo(prog) = inlInfoNew(NULL, prog, NULL, false);
gen0ProgRestoreState(saved);
+ genSetConstNum(syme, -1, constNum, true);
return foamNewClos(foamNewEnv(int0), foamNewConst(constNum));
}
@@ -338,7 +342,7 @@ gfjPCallJavaToFoam(TForm tf, Foam foam)
}
local AInt
-gfjPCallDecl(TForm tf)
+gfjPCallDecl(TForm tf, TForm this)
{
FoamList decls;
Foam ddecl, retdecl;
@@ -346,6 +350,12 @@ gfjPCallDecl(TForm tf)
decls = listNil(Foam);
+ if (this != NULL) {
+ TForm tfThis = gfjPCallArgBaseJavaType(this);
+ Foam decl = gfjPCallDeclArg(tfThis);
+ decls = listCons(Foam)(decl, decls);
+ }
+
for (i=0; i