summaryrefslogtreecommitdiff
path: root/sources/scalac/atree
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2005-12-18 18:33:03 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2005-12-18 18:33:03 +0000
commitd3819b93ab8b2de3d5cc35c33b8258ccdb5a931a (patch)
treedfc6f7f497e58ea3321e6f687b11313d2afa86b5 /sources/scalac/atree
parent0e82079908655682e5140ad521cef0572cb6d2a4 (diff)
downloadscala-d3819b93ab8b2de3d5cc35c33b8258ccdb5a931a.tar.gz
scala-d3819b93ab8b2de3d5cc35c33b8258ccdb5a931a.tar.bz2
scala-d3819b93ab8b2de3d5cc35c33b8258ccdb5a931a.zip
Removed old Scalac code in sources and various ...
Removed old Scalac code in sources and various other obsolete elements.
Diffstat (limited to 'sources/scalac/atree')
-rw-r--r--sources/scalac/atree/AArithmeticOp.java50
-rw-r--r--sources/scalac/atree/AClass.java139
-rw-r--r--sources/scalac/atree/ACode.java98
-rw-r--r--sources/scalac/atree/AComparisonOp.java42
-rw-r--r--sources/scalac/atree/AConstant.java404
-rw-r--r--sources/scalac/atree/AField.java54
-rw-r--r--sources/scalac/atree/AFunction.java33
-rw-r--r--sources/scalac/atree/AInvokeStyle.java91
-rw-r--r--sources/scalac/atree/ALocation.java33
-rw-r--r--sources/scalac/atree/ALogicalOp.java42
-rw-r--r--sources/scalac/atree/AMember.java87
-rw-r--r--sources/scalac/atree/AMethod.java79
-rw-r--r--sources/scalac/atree/APrimitive.java72
-rw-r--r--sources/scalac/atree/ARepository.java51
-rw-r--r--sources/scalac/atree/AShiftOp.java42
-rw-r--r--sources/scalac/atree/ATestOp.java67
-rw-r--r--sources/scalac/atree/ATreeFactory.java531
-rw-r--r--sources/scalac/atree/ATreeFromSTree.java553
-rw-r--r--sources/scalac/atree/ATreePrinter.java557
-rw-r--r--sources/scalac/atree/ATreeTyper.java314
-rw-r--r--sources/scalac/atree/ATypeKind.java94
21 files changed, 0 insertions, 3433 deletions
diff --git a/sources/scalac/atree/AArithmeticOp.java b/sources/scalac/atree/AArithmeticOp.java
deleted file mode 100644
index 1627ca1ad9..0000000000
--- a/sources/scalac/atree/AArithmeticOp.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.util.Debug;
-
-/** This class represents an arithmetic operation. */
-public class AArithmeticOp {
-
- //########################################################################
- // Public Cases
-
- /** An arithmetic addition operation */
- public case ADD;
-
- /** An arithmetic subtraction operation */
- public case SUB;
-
- /** An arithmetic multiplication operation */
- public case MUL;
-
- /** An arithmetic division operation */
- public case DIV;
-
- /** An arithmetic remainder operation */
- public case REM;
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this operation. */
- public String toString() {
- switch (this) {
- case ADD: return "ADD";
- case SUB: return "SUB";
- case MUL: return "MUL";
- case DIV: return "DIV";
- case REM: return "REM";
- default : throw Debug.abort("unknown case", this);
- }
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AClass.java b/sources/scalac/atree/AClass.java
deleted file mode 100644
index 66cf4693e1..0000000000
--- a/sources/scalac/atree/AClass.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import java.util.Map;
-import java.util.LinkedHashMap;
-
-import scalac.symtab.Symbol;
-import scalac.symtab.Type;
-import scalac.util.Debug;
-
-/** This class represents an attributed class. */
-public class AClass extends ARepository {
-
- //########################################################################
- // Private Fields
-
- /** The class symbol */
- private final Symbol symbol;
-
- /** The symbol to field map */
- private final Map/*<Symbol,AField>*/ fields;
-
- /** The symbol to method map */
- private final Map/*Symbol,AMethod*/ methods;
-
- //########################################################################
- // Public Constructors
-
- /** Initializes this instance. */
- public AClass(Symbol symbol) {
- this.symbol = symbol;
- this.fields = new LinkedHashMap();
- this.methods = new LinkedHashMap();
- }
-
- //########################################################################
- // Public Methods
-
- /** Returns the symbol of this class. */
- public Symbol symbol() {
- return symbol;
- }
-
- /** Is this class public? */
- public boolean isPublic() {
- return symbol().isPublic();
- }
-
- /** Is this class private? */
- public boolean isPrivate() {
- return symbol().isPrivate();
- }
-
- /** Is this class protected? */
- public boolean isProtected() {
- return symbol().isProtected();
- }
-
- /** Is this class final? */
- public boolean isFinal() {
- return false; // !!!
- }
-
- /** Is this class abstract? */
- public boolean isAbstract() {
- return symbol.isAbstractClass();
- }
-
- /** Is this class an interface? */
- public boolean isInterface() {
- return symbol.isInterface();
- }
-
- /** Is this class deprecated? */
- public boolean isDeprecated() {
- return false; // !!!
- }
-
- /** Is this class synthetic? */
- public boolean isSynthetic() {
- return symbol().isSynthetic();
- }
-
- /** Adds the given field to this class. */
- public void addField(AField field) {
- assert !fields.containsKey(field.symbol()): field;
- fields.put(field.symbol(), field);
- }
-
- /** Adds the given method to this class. */
- public void addMethod(AMethod method) {
- assert !methods.containsKey(method.symbol()): method;
- methods.put(method.symbol(), method);
- }
-
- /** Returns the fields of this class. */
- public AField[] fields() {
- return (AField[])fields.values().toArray(new AField[fields.size()]);
- }
-
- /** Returns the methods of this class. */
- public AMethod[] methods() {
- return(AMethod[])methods.values().toArray(new AMethod[methods.size()]);
- }
-
- /** Returns the type parameters of this class. */
- public Symbol[] tparams() {
- return symbol.typeParams();
- }
-
- /** Returns the value parameters of this class. */
- public Symbol[] vparams() {
- return symbol.valueParams();
- }
-
- /** Returns the parent types of this class. */
- public Type[] parents() {
- switch (symbol.info()) {
- case CompoundType(Type[] parts, _):
- return parts;
- default:
- throw Debug.abort("illegal case", symbol.info());
- }
- }
-
- /** Returns a string representation of this class. */
- public String toString() {
- return new ATreePrinter().printClass(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ACode.java b/sources/scalac/atree/ACode.java
deleted file mode 100644
index 3e65d41829..0000000000
--- a/sources/scalac/atree/ACode.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.symtab.Symbol;
-import scalac.symtab.Type;
-
-/** This class represents attributed code. */
-public class ACode {
-
- //########################################################################
- // Public Constants
-
- public static final ACode[] EMPTY_ARRAY = new ACode[0];
-
- //########################################################################
- // Public Cases
-
- // jvm : -
- public case Void;
-
- // jvm : aload_0
- public case This(Symbol clasz);
-
- // jvm : {b, s}ipush, ldc{ ,_w, 2_w}, aconst_null
- // jvm : iconst_{m1, 2, 3, 4, 5}, {i, l, f, d}const_{0, 1}, fconst_2
- public case Constant(AConstant constant);
-
- // jvm : get{static, field}
- // jvm : {i, l, f, d, a}load{, _0, _1, _2, _3}
- // jvm : {i, l, f, d, a, b, c, s}aload
- public case Load(ALocation location);
-
- // jvm : put{static, field}
- // jvm : {i, l, f, d, a}store{, _0, _1, _2, _3}
- // jvm : {i, l, f, d, a, b, c, s}store
- public case Store(ALocation location, ACode value);
-
- // jvm : new, invoke{static, virtual, interface, special}, {, a}newarray
- // jvm : <see also in APrimitive>
- public case Apply(AFunction function, Type[] targs, ACode[] vargs);
-
- // jvm : instanceof, checkcast
- public case IsAs(ACode value, Type type, boolean cast);
-
- // jvm : -
- public case If(ACode test, ACode success, ACode failure);
-
- // jvm : {tables, lookup}switch
- public case Switch(ACode test, int[][] tags, ACode[] bodies);
-
- // jvm : monitor{enter, exit}
- public case Synchronized(ACode lock, ACode value);
-
- // jvm : -
- public case Block(Symbol[] locals, ACode[] statements, ACode value);
-
- // jvm : -
- public case Label(Symbol label, Symbol[] locals, ACode value);
-
- // jvm : goto, goto_w
- public case Goto(Symbol label, ACode[] vargs);
-
- // jvm : {i, l, f, d, a, }return
- public case Return(Symbol function, ACode value);
-
- // jvm : athrow
- public case Throw(ACode value);
-
- // jvm : pop, pop2
- public case Drop(ACode value, Type type);
-
- // jvm : nop, dup{, _x1, _x2, 2, 2_x1, 2_x2}, swap
- // jvm : multianewarray, iinc, jsr{, _w}, ret, wide
- // NOT MAPPED
-
- //########################################################################
- // Public Fields
-
- /** The source file position */
- public int pos;
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this code. */
- public String toString() {
- return new ATreePrinter().printCode(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AComparisonOp.java b/sources/scalac/atree/AComparisonOp.java
deleted file mode 100644
index 1e7bcf1bcd..0000000000
--- a/sources/scalac/atree/AComparisonOp.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.util.Debug;
-
-/** This class represents a comparison operation. */
-public class AComparisonOp {
-
- //########################################################################
- // Public Cases
-
- /** A comparison operation with -1 default for NaNs */
- public case CMPL;
-
- /** A comparison operation with no default for NaNs */
- public case CMP;
-
- /** A comparison operation with +1 default for NaNs */
- public case CMPG;
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this operation. */
- public String toString() {
- switch (this) {
- case CMPL: return "CMPL";
- case CMP : return "CMP";
- case CMPG: return "CMPG";
- default : throw Debug.abort("unknown case", this);
- }
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AConstant.java b/sources/scalac/atree/AConstant.java
deleted file mode 100644
index 12c58d5889..0000000000
--- a/sources/scalac/atree/AConstant.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.util.Debug;
-import scalac.symtab.Symbol;
-
-/** This class represents a constant. */
-public class AConstant {
-
- public static final AConstant[] EMPTY_ARRAY = new AConstant[0];
-
- //########################################################################
- // Public Cases
-
- public case UNIT;
- public case BOOLEAN(boolean value);
- public case BYTE(byte value);
- public case SHORT(short value);
- public case CHAR(char value);
- public case INT(int value);
- public case LONG(long value);
- public case FLOAT(float value);
- public case DOUBLE(double value);
- public case STRING(String value);
- public case SYMBOL_NAME(Symbol value);
- public case NULL;
- public case ZERO;
-
- //########################################################################
- // Public Methods
-
- /** Returns the type kind of this constant. */
- public ATypeKind kind() {
- switch (this) {
- case UNIT:
- return ATypeKind.UNIT;
- case BOOLEAN(_):
- return ATypeKind.BOOL;
- case BYTE(_):
- return ATypeKind.I1;
- case SHORT(_):
- return ATypeKind.I2;
- case CHAR(_):
- return ATypeKind.U2;
- case INT(_):
- return ATypeKind.I4;
- case LONG(_):
- return ATypeKind.I8;
- case FLOAT(_):
- return ATypeKind.R4;
- case DOUBLE(_):
- return ATypeKind.R8;
- case STRING(_):
- case SYMBOL_NAME(_):
- return ATypeKind.STR;
- case NULL:
- return ATypeKind.NULL;
- case ZERO:
- return ATypeKind.ZERO;
- default:
- throw Debug.abort("unknown case", this);
- }
- }
-
-
- /** Converts this constant to a boolean value. */
- public boolean booleanValue() {
- switch (this) {
- case BOOLEAN(boolean value):
- return value;
- default:
- throw Debug.abort("not convertible to boolean", this);
- }
- }
-
- /** Converts this constant to a byte value. */
- public byte byteValue() {
- switch (this) {
- case BYTE(byte value):
- return (byte)value;
- case SHORT(short value):
- return (byte)value;
- case CHAR(char value):
- return (byte)value;
- case INT(int value):
- return (byte)value;
- case LONG(long value):
- return (byte)value;
- case FLOAT(float value):
- return (byte)value;
- case DOUBLE(double value):
- return (byte)value;
- default:
- throw Debug.abort("not convertible to byte", this);
- }
- }
-
- /** Converts this constant to a short value. */
- public short shortValue() {
- switch (this) {
- case BYTE(byte value):
- return (short)value;
- case SHORT(short value):
- return (short)value;
- case CHAR(char value):
- return (short)value;
- case INT(int value):
- return (short)value;
- case LONG(long value):
- return (short)value;
- case FLOAT(float value):
- return (short)value;
- case DOUBLE(double value):
- return (short)value;
- default:
- throw Debug.abort("not convertible to short", this);
- }
- }
-
- /** Converts this constant to a char value. */
- public char charValue() {
- switch (this) {
- case BYTE(byte value):
- return (char)value;
- case SHORT(short value):
- return (char)value;
- case CHAR(char value):
- return (char)value;
- case INT(int value):
- return (char)value;
- case LONG(long value):
- return (char)value;
- case FLOAT(float value):
- return (char)value;
- case DOUBLE(double value):
- return (char)value;
- default:
- throw Debug.abort("not convertible to char", this);
- }
- }
-
- /** Converts this constant to a int value. */
- public int intValue() {
- switch (this) {
- case BYTE(byte value):
- return (int)value;
- case SHORT(short value):
- return (int)value;
- case CHAR(char value):
- return (int)value;
- case INT(int value):
- return (int)value;
- case LONG(long value):
- return (int)value;
- case FLOAT(float value):
- return (int)value;
- case DOUBLE(double value):
- return (int)value;
- default:
- throw Debug.abort("not convertible to int", this);
- }
- }
-
- /** Converts this constant to a long value. */
- public long longValue() {
- switch (this) {
- case BYTE(byte value):
- return (long)value;
- case SHORT(short value):
- return (long)value;
- case CHAR(char value):
- return (long)value;
- case INT(int value):
- return (long)value;
- case LONG(long value):
- return (long)value;
- case FLOAT(float value):
- return (long)value;
- case DOUBLE(double value):
- return (long)value;
- default:
- throw Debug.abort("not convertible to long", this);
- }
- }
-
- /** Converts this constant to a float value. */
- public float floatValue() {
- switch (this) {
- case BYTE(byte value):
- return (float)value;
- case SHORT(short value):
- return (float)value;
- case CHAR(char value):
- return (float)value;
- case INT(int value):
- return (float)value;
- case LONG(long value):
- return (float)value;
- case FLOAT(float value):
- return (float)value;
- case DOUBLE(double value):
- return (float)value;
- default:
- throw Debug.abort("not convertible to float", this);
- }
- }
-
- /** Converts this constant to a double value. */
- public double doubleValue() {
- switch (this) {
- case BYTE(byte value):
- return (double)value;
- case SHORT(short value):
- return (double)value;
- case CHAR(char value):
- return (double)value;
- case INT(int value):
- return (double)value;
- case LONG(long value):
- return (double)value;
- case FLOAT(float value):
- return (double)value;
- case DOUBLE(double value):
- return (double)value;
- default:
- throw Debug.abort("not convertible to double", this);
- }
- }
-
- /** Converts this constant to a String value. */
- public String stringValue() {
- switch (this) {
- case UNIT:
- return "()";
- case BOOLEAN(boolean value):
- return String.valueOf(value);
- case BYTE(byte value):
- return String.valueOf(value);
- case SHORT(short value):
- return String.valueOf(value);
- case CHAR(char value):
- return String.valueOf(value);
- case INT(int value):
- return String.valueOf(value);
- case LONG(long value):
- return String.valueOf(value);
- case FLOAT(float value):
- return String.valueOf(value);
- case DOUBLE(double value):
- return String.valueOf(value);
- case STRING(String value):
- return value;
- case SYMBOL_NAME(Symbol value):
- return value.name.toString();
- case NULL:
- return String.valueOf(null);
- default:
- throw Debug.abort("not convertible to String", this);
- }
- }
-
- /** Tests whether this constant equals given Object. */
- public boolean equals(Object that) {
- if (this == that) return true;
- return (that instanceof AConstant) && this.equals((AConstant)that);
- }
-
- /** Tests whether this constant equals given one. */
- public boolean equals(AConstant that) {
- if (this == that) return true;
- if (null == that) return false;
- switch (this) {
- case UNIT:
- return false;
- case BOOLEAN(boolean ivalue):
- switch (that) {
- case BOOLEAN(boolean avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case BYTE(byte ivalue):
- switch (that) {
- case BYTE(byte avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case SHORT(short ivalue):
- switch (that) {
- case SHORT(short avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case CHAR(char ivalue):
- switch (that) {
- case CHAR(char avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case INT(int ivalue):
- switch (that) {
- case INT(int avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case LONG(long ivalue):
- switch (that) {
- case LONG(long avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case FLOAT(float ivalue):
- switch (that) {
- case FLOAT(float avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case DOUBLE(double ivalue):
- switch (that) {
- case DOUBLE(double avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case STRING(String ivalue):
- switch (that) {
- case STRING(String avalue):
- return ivalue.equals(avalue);
- default:
- return false;
- }
- case SYMBOL_NAME(Symbol ivalue):
- switch (that) {
- case SYMBOL_NAME(Symbol avalue):
- return ivalue == avalue;
- default:
- return false;
- }
- case NULL:
- return false;
- case ZERO:
- return false;
- default:
- throw Debug.abort("unknown case", this);
- }
- }
-
- /** Returns the hash code of this constant. */
- public int hashCode() {
- switch (this) {
- case UNIT:
- return 4041;
- case BOOLEAN(boolean value):
- return value ? 1231 : 1237;
- case BYTE(byte value):
- return value;
- case SHORT(short value):
- return value;
- case CHAR(char value):
- return value;
- case INT(int value):
- return value;
- case LONG(long value):
- long bits = value;
- return (int)(bits ^ (bits >>> 32));
- case FLOAT(float value):
- int bits = java.lang.Float.floatToIntBits(value);
- return bits;
- case DOUBLE(double value):
- long bits = java.lang.Double.doubleToLongBits(value);
- return (int)(bits ^ (bits >>> 32));
- case STRING(String value):
- return value.hashCode();
- case SYMBOL_NAME(Symbol value):
- return value.hashCode();
- case NULL:
- return 0;
- case ZERO:
- return 0;
- default:
- throw Debug.abort("unknown case", this);
- }
- }
-
- /** Returns a string representation of this constant. */
- public String toString() {
- return new ATreePrinter().printConstant(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AField.java b/sources/scalac/atree/AField.java
deleted file mode 100644
index bbc27f7063..0000000000
--- a/sources/scalac/atree/AField.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.symtab.Symbol;
-import scalac.symtab.Type;
-
-/** This class represents an attributed field. */
-public class AField extends AMember {
-
- //########################################################################
- // Public Constructors
-
- /** Initializes this instance. */
- public AField(Symbol symbol, boolean isStatic) {
- super(symbol, isStatic);
- }
-
- //########################################################################
- // Public Methods
-
- /** Is this field final? */
- public boolean isFinal() {
- return false; // !!!
- }
-
- /** Is this field volatile? */
- public boolean isVolatile() {
- return false; // !!!
- }
-
- /** Is this field transient? */
- public boolean isTransient() {
- return false; // !!!
- }
-
- /** Returns the type of this field. */
- public Type type() {
- return symbol().type();
- }
-
- /** Returns a string representation of this field. */
- public String toString() {
- return new ATreePrinter().printField(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AFunction.java b/sources/scalac/atree/AFunction.java
deleted file mode 100644
index 2970222a2c..0000000000
--- a/sources/scalac/atree/AFunction.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.symtab.Type;
-import scalac.symtab.Symbol;
-
-/** This class represents an attributed function reference. */
-public class AFunction {
-
- //########################################################################
- // Public Cases
-
- public case Method(ACode object, Symbol method, AInvokeStyle style);
- public case Primitive(APrimitive primitive);
- public case NewArray(Type element);
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this function. */
- public String toString() {
- return new ATreePrinter().printFunction(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AInvokeStyle.java b/sources/scalac/atree/AInvokeStyle.java
deleted file mode 100644
index f833aad2f0..0000000000
--- a/sources/scalac/atree/AInvokeStyle.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.util.Debug;
-
-/** This class represents a method invocation style. */
-public class AInvokeStyle {
-
- //########################################################################
- // Public Cases
-
- public case New;
- public case Dynamic;
- public case Static(boolean onInstance);
-
- //########################################################################
- // Public Constants
-
- public static final AInvokeStyle StaticClass = Static(false);
- public static final AInvokeStyle StaticInstance = Static(true);
-
- //########################################################################
- // Public Methods
-
- /** Is this a new object creation? */
- public boolean isNew() {
- switch (this) {
- case New:
- return true;
- default:
- return false;
- }
- }
-
- /** Is this a dynamic method call? */
- public boolean isDynamic() {
- switch (this) {
- case Dynamic:
- return true;
- default:
- return false;
- }
- }
-
- /** Is this a static method call? */
- public boolean isStatic() {
- switch (this) {
- case Static(_):
- return true;
- default:
- return false;
- }
- }
-
- /** Is this an instance method call? */
- public boolean hasInstance() {
- switch (this) {
- case Dynamic:
- return true;
- case Static(boolean onInstance):
- return onInstance;
- default:
- return false;
- }
- }
-
- /** Returns a string representation of this style. */
- public String toString() {
- switch (this) {
- case New:
- return "new";
- case Dynamic:
- return "dynamic";
- case Static(false):
- return "static-class";
- case Static(true):
- return "static-instance";
- default:
- throw Debug.abort("unknown case", this);
- }
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ALocation.java b/sources/scalac/atree/ALocation.java
deleted file mode 100644
index 0a9c440df2..0000000000
--- a/sources/scalac/atree/ALocation.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.symtab.Symbol;
-
-/** This class represents an attributed value location. */
-public class ALocation {
-
- //########################################################################
- // Public Cases
-
- public case Module(Symbol module); // !!! remove ?
- public case Field(ACode object, Symbol field, boolean isStatic);
- public case Local(Symbol local, boolean isArgument);
- public case ArrayItem(ACode array, ACode index);
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this location. */
- public String toString() {
- return new ATreePrinter().printLocation(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ALogicalOp.java b/sources/scalac/atree/ALogicalOp.java
deleted file mode 100644
index 85010ae4f0..0000000000
--- a/sources/scalac/atree/ALogicalOp.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.util.Debug;
-
-/** This class represents a logical operation. */
-public class ALogicalOp {
-
- //########################################################################
- // Public Cases
-
- /** A bitwise AND operation */
- public case AND;
-
- /** A bitwise OR operation */
- public case OR;
-
- /** A bitwise XOR operation */
- public case XOR;
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this operation. */
- public String toString() {
- switch (this) {
- case AND: return "AND";
- case OR : return "OR";
- case XOR: return "XOR";
- default : throw Debug.abort("unknown case", this);
- }
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AMember.java b/sources/scalac/atree/AMember.java
deleted file mode 100644
index 4275180a4d..0000000000
--- a/sources/scalac/atree/AMember.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.symtab.Symbol;
-
-/** This class represents an attributed class member. */
-public abstract class AMember {
-
- //########################################################################
- // Private Fields
-
- /** The member symbol */
- private final Symbol symbol;
-
- /** The static flag */
- private final boolean isStatic;
-
- /** The member code */
- private ACode code;
-
- //########################################################################
- // Public Constructors
-
- /** Initializes this instance. */
- public AMember(Symbol symbol, boolean isStatic) {
- this.symbol = symbol;
- this.isStatic = isStatic;
- this.code = ACode.Void;
- }
-
- //########################################################################
- // Public Methods
-
- /** Returns the symbol of this member. */
- public Symbol symbol() {
- return symbol;
- }
-
- /** Is this member public? */
- public boolean isPublic() {
- return symbol().isPublic();
- }
-
- /** Is this member private? */
- public boolean isPrivate() {
- return symbol().isPrivate();
- }
-
- /** Is this member protected? */
- public boolean isProtected() {
- return symbol().isProtected();
- }
-
- /** Is this member static? */
- public boolean isStatic() {
- return isStatic;
- }
-
- /** Is this member deprecated? */
- public boolean isDeprecated() {
- return false; // !!!
- }
-
- /** Is this member synthetic? */
- public boolean isSynthetic() {
- return symbol().isSynthetic();
- }
-
- /** Returns the member code. */
- public ACode code() {
- return code;
- }
-
- /** Sets the member code. */
- public void setCode(ACode code) {
- this.code = code;
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AMethod.java b/sources/scalac/atree/AMethod.java
deleted file mode 100644
index f904fa6b92..0000000000
--- a/sources/scalac/atree/AMethod.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.symtab.Symbol;
-import scalac.symtab.Type;
-
-/** This class represents an attributed method. */
-public class AMethod extends AMember {
- //########################################################################
- // Public Fields
-
- /** Contains the Intermediate code of this Method */
- public Object icode = null;
-
- //########################################################################
- // Public Constructors
-
- /** Initializes this instance. */
- public AMethod(Symbol symbol, boolean isStatic) {
- super(symbol, isStatic);
- }
-
- //########################################################################
- // Public Methods
-
- /** Is this method final? */
- public boolean isFinal() {
- return symbol().isMethodFinal();
- }
-
- /** Is this method synchronized? */
- public boolean isSynchronized() {
- return false; // !!!
- }
-
- /** Is this method native? */
- public boolean isNative() {
- return false; // !!!
- }
-
- /** Is this method abstract? */
- public boolean isAbstract() {
- return symbol().isDeferred();
- }
-
- /** Is this method FP-strict? */
- public boolean isStrictFP() {
- return false; // !!!
- }
-
- /** Returns the type parameters of this method. */
- public Symbol[] tparams() {
- return symbol().type().typeParams();
- }
-
- /** Returns the value parameters of this method. */
- public Symbol[] vparams() {
- return symbol().type().valueParams();
- }
-
- /** Returns the result type of this method. */
- public Type result() {
- return symbol().type().resultType();
- }
-
- /** Returns a string representation of this method. */
- public String toString() {
- return new ATreePrinter().printMethod(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/APrimitive.java b/sources/scalac/atree/APrimitive.java
deleted file mode 100644
index 034a9f4d19..0000000000
--- a/sources/scalac/atree/APrimitive.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-/** This class represents a primitive operation. */
-public class APrimitive {
-
- //########################################################################
- // Public Cases
-
- // type : (type) => type
- // range: type <- { BOOL, Ix, Ux, Rx }
- // jvm : {i, l, f, d}neg
- public case Negation(ATypeKind kind);
-
- // type : zero ? (type) => BOOL : (type,type) => BOOL
- // range: type <- { BOOL, Ix, Ux, Rx, REF }
- // jvm : if{eq, ne, lt, ge, le, gt}, if{null, nonnull}
- // if_icmp{eq, ne, lt, ge, le, gt}, if_acmp{eq,ne}
- public case Test(ATestOp op, ATypeKind kind, boolean zero);
-
- // type : (type,type) => I4
- // range: type <- { Ix, Ux, Rx }
- // jvm : lcmp, {f, d}cmp{l, g}
- public case Comparison(AComparisonOp op, ATypeKind kind);
-
- // type : (type,type) => type
- // range: type <- { Ix, Ux, Rx }
- // jvm : {i, l, f, d}{add, sub, mul, div, rem}
- public case Arithmetic(AArithmeticOp op, ATypeKind kind);
-
- // type : (type,type) => type
- // range: type <- { BOOL, Ix, Ux }
- // jvm : {i, l}{and, or, xor}
- public case Logical(ALogicalOp op, ATypeKind kind);
-
- // type : (type,I4) => type
- // range: type <- { Ix, Ux }
- // jvm : {i, l}{shl, ushl, shr}
- public case Shift(AShiftOp op, ATypeKind kind);
-
- // type : (src) => dst
- // range: src,dst <- { Ix, Ux, Rx }
- // jvm : i2{l, f, d}, l2{i, f, d}, f2{i, l, d}, d2{i, l, f}, i2{b, c, s}
- public case Conversion(ATypeKind src, ATypeKind dst);
-
- // type : (Array[REF]) => I4
- // range: type <- { BOOL, Ix, Ux, Rx, REF }
- // jvm : arraylength
- public case ArrayLength(ATypeKind kind);
-
- // type : (lf,rg) => STR
- // range: lf,rg <- { BOOL, Ix, Ux, Rx, REF, STR }
- // jvm : -
- public case StringConcat(ATypeKind lf, ATypeKind rg);
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this primitive. */
- public String toString() {
- return new ATreePrinter().printPrimitive(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ARepository.java b/sources/scalac/atree/ARepository.java
deleted file mode 100644
index c1468a85a8..0000000000
--- a/sources/scalac/atree/ARepository.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import java.util.Map;
-import java.util.LinkedHashMap;
-
-/** This class represents a repository of attributed classes. */
-public class ARepository {
-
- //########################################################################
- // Private Fields
-
- /** The symbol to class map */
- private final Map/*<Symbol,AClass>*/ classes;
-
- //########################################################################
- // Public Constructors
-
- /** Initializes this instance. */
- public ARepository() {
- this.classes = new LinkedHashMap();
- }
-
- //########################################################################
- // Public Methods
-
- /** Adds the given class to this repository. */
- public void addClass(AClass clasz) {
- assert !classes.containsKey(clasz.symbol()): clasz;
- classes.put(clasz.symbol(), clasz);
- }
-
- /** Returns the classes of this repository. */
- public AClass[] classes() {
- return (AClass[])classes.values().toArray(new AClass[classes.size()]);
- }
-
- /** Returns a string representation of this repository. */
- public String toString() {
- return new ATreePrinter().printRepository(this).toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/AShiftOp.java b/sources/scalac/atree/AShiftOp.java
deleted file mode 100644
index 791ce54328..0000000000
--- a/sources/scalac/atree/AShiftOp.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.util.Debug;
-
-/** This class represents a shift operation. */
-public class AShiftOp {
-
- //########################################################################
- // Public Cases
-
- /** A logical shift to the left */
- public case LSL;
-
- /** An arithmetic shift to the right */
- public case ASR;
-
- /** A logical shift to the right */
- public case LSR;
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this operation. */
- public String toString() {
- switch (this) {
- case LSL: return "LSL";
- case ASR: return "ASR";
- case LSR: return "LSR";
- default: throw Debug.abort("unknown case", this);
- }
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ATestOp.java b/sources/scalac/atree/ATestOp.java
deleted file mode 100644
index 1d90f5ba0e..0000000000
--- a/sources/scalac/atree/ATestOp.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.util.Debug;
-
-/** This class represents a test operation. */
-public class ATestOp {
-
- //########################################################################
- // Public Cases
-
- /** An equality test */
- public case EQ;
-
- /** A non-equality test */
- public case NE;
-
- /** A less-than test */
- public case LT;
-
- /** A greater-than-or-equal test */
- public case GE;
-
- /** A less-than-or-equal test */
- public case LE;
-
- /** A greater-than test */
- public case GT;
-
- //########################################################################
- // Public Methods
-
- /** Returns the negation of this operation. */
- public ATestOp negate() {
- switch (this) {
- case EQ: return NE;
- case NE: return EQ;
- case LT: return GE;
- case GE: return LT;
- case LE: return GT;
- case GT: return LE;
- default: throw Debug.abort("unknown case", this);
- }
- }
-
- /** Returns a string representation of this operation. */
- public String toString() {
- switch (this) {
- case EQ: return "EQ";
- case NE: return "NE";
- case LT: return "LT";
- case GE: return "GE";
- case LE: return "LE";
- case GT: return "GT";
- default: throw Debug.abort("unknown case", this);
- }
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ATreeFactory.java b/sources/scalac/atree/ATreeFactory.java
deleted file mode 100644
index 0c09650a16..0000000000
--- a/sources/scalac/atree/ATreeFactory.java
+++ /dev/null
@@ -1,531 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.ast.Tree;
-import scalac.symtab.Symbol;
-import scalac.symtab.Type;
-
-/** This class implements an attributed tree factory. */
-public class ATreeFactory {
-
- //########################################################################
- // Public Fields
-
- /** The unique Void node */
- public final ACode Void = ACode.Void;
-
- /** The unique UNIT constant */
- public final AConstant UNIT = AConstant.UNIT;
-
- /** The unique NULL constant */
- public final AConstant NULL = AConstant.NULL;
-
- /** The unique ZERO constant */
- public final AConstant ZERO = AConstant.ZERO;
-
- //########################################################################
- // Public Methods - Building code
-
- /** Builds a This node. */
- public ACode This(Tree t, Symbol clasz) {
- ACode.This code = ACode.This(clasz);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Constant node. */
- public ACode Constant(Tree t, AConstant constant) {
- ACode.Constant code = ACode.Constant(constant);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Load node. */
- public ACode Load(Tree t, ALocation location) {
- ACode.Load code = ACode.Load(location);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Store node. */
- public ACode Store(Tree t, ALocation location, ACode value) {
- ACode.Store code = ACode.Store(location, value);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds an Apply node. */
- public ACode Apply(Tree t, AFunction function, Type[] ts, ACode[] vs) {
- ACode.Apply code = ACode.Apply(function, ts, vs);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds an Apply node. */
- public ACode Apply(Tree t, AFunction function, Type[] ts) {
- return Apply(t, function, ts, ACode.EMPTY_ARRAY);
- }
-
- /** Builds an Apply node. */
- public ACode Apply(Tree t, AFunction function, ACode[] vs) {
- return Apply(t, function, Type.EMPTY_ARRAY, vs);
- }
-
- /** Builds an Apply node. */
- public ACode Apply(Tree t, AFunction function) {
- return Apply(t, function, Type.EMPTY_ARRAY, ACode.EMPTY_ARRAY);
- }
-
- /** Builds an Apply node. */
- public ACode Apply(Tree t, APrimitive primitive, ACode v0) {
- return Apply(t, AFunction.Primitive(primitive), new ACode[] {v0});
- }
-
- /** Builds an Apply node. */
- public ACode Apply(Tree t, APrimitive primitive, ACode v0, ACode v1) {
- return Apply(t, AFunction.Primitive(primitive), new ACode[] {v0,v1});
- }
-
- /** Builds an IsAs node. */
- public ACode IsAs(Tree t, ACode value, Type type, boolean cast) {
- ACode.IsAs code = ACode.IsAs(value, type, cast);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds an If node. */
- public ACode If(Tree t, ACode test, ACode success, ACode failure) {
- ACode.If code = ACode.If(test, success, failure);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Switch node. */
- public ACode Switch(Tree t, ACode test, int[][] tags, ACode[] bodies) {
- ACode.Switch code = ACode.Switch(test, tags, bodies);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Synchronized node. */
- public ACode Synchronized(Tree t, ACode lock, ACode value) {
- ACode.Synchronized code = ACode.Synchronized(lock, value);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Block node. */
- public ACode Block(Tree t, Symbol[] locals,ACode[] statements,ACode value){
- ACode.Block code = ACode.Block(locals, statements, value);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Label node. */
- public ACode Label(Tree t, Symbol label, Symbol[] locals, ACode value) {
- ACode.Label code = ACode.Label(label, locals, value);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Goto node. */
- public ACode Goto(Tree t, Symbol label, ACode[] vargs) {
- ACode.Goto code = ACode.Goto(label, vargs);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Return node. */
- public ACode Return(Tree t, Symbol function, ACode value) {
- ACode.Return code = ACode.Return(function, value);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Throw node. */
- public ACode Throw(Tree t, ACode value) {
- ACode.Throw code = ACode.Throw(value);
- code.pos = t.pos;
- return code;
- }
-
- /** Builds a Drop node. */
- public ACode Drop(Tree t, ACode value, Type type) {
- ACode.Drop code = ACode.Drop(value, type);
- code.pos = t.pos;
- return code;
- }
-
- //########################################################################
- // Public Methods - Building primitive operations
-
- /** Builds a negation operation */
- public ACode NOT(Tree t, ATypeKind kind, ACode v0) {
- return Apply(t, NOT(kind), v0);
- }
-
- /** Builds an EQ operation */
- public ACode EQ(Tree t, ATypeKind kind, ACode v0) {
- return Apply(t, EQ(kind, true), v0);
- }
-
- /** Builds a NE operation */
- public ACode NE(Tree t, ATypeKind kind, ACode v0) {
- return Apply(t, NE(kind, true), v0);
- }
-
- /** Builds a LT operation */
- public ACode LT(Tree t, ATypeKind kind, ACode v0) {
- return Apply(t, LT(kind, true), v0);
- }
-
- /** Builds a GE operation */
- public ACode GE(Tree t, ATypeKind kind, ACode v0) {
- return Apply(t, GE(kind, true), v0);
- }
-
- /** Builds a LE operation */
- public ACode LE(Tree t, ATypeKind kind, ACode v0) {
- return Apply(t, LE(kind, true), v0);
- }
-
- /** Builds a GT operation */
- public ACode GT(Tree t, ATypeKind kind, ACode v0) {
- return Apply(t, GT(kind, true), v0);
- }
-
- /** Builds an EQ operation */
- public ACode EQ(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, EQ(kind, false), v0, v1);
- }
-
- /** Builds a NE operation */
- public ACode NE(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, NE(kind, false), v0, v1);
- }
-
- /** Builds a LT operation */
- public ACode LT(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, LT(kind, false), v0, v1);
- }
-
- /** Builds a GE operation */
- public ACode GE(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, GE(kind, false), v0, v1);
- }
-
- /** Builds a LE operation */
- public ACode LE(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, LE(kind, false), v0, v1);
- }
-
- /** Builds a GT operation */
- public ACode GT(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, GT(kind, false), v0, v1);
- }
-
- /** Builds a CMPL operation */
- public ACode CMPL(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, CMPL(kind), v0, v1);
- }
-
- /** Builds a CMP operation */
- public ACode CMP(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, CMP(kind), v0, v1);
- }
-
- /** Builds a CMPG operation */
- public ACode CMPG(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, CMPG(kind), v0, v1);
- }
-
- /** Builds an ADD operation */
- public ACode ADD(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, ADD(kind), v0, v1);
- }
-
- /** Builds a SUB operation */
- public ACode SUB(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, SUB(kind), v0, v1);
- }
-
- /** Builds a MUL operation */
- public ACode MUL(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, MUL(kind), v0, v1);
- }
-
- /** Builds a DIV operation */
- public ACode DIV(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, DIV(kind), v0, v1);
- }
-
- /** Builds a REM operation */
- public ACode REM(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, REM(kind), v0, v1);
- }
-
- /** Builds an AND operation. */
- public ACode AND(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, AND(kind), v0, v1);
- }
-
- /** Builds an OR operation. */
- public ACode OR(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, OR(kind), v0, v1);
- }
-
- /** Builds an XOR operation. */
- public ACode XOR(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, XOR(kind), v0, v1);
- }
-
- /** Builds a LSL operation. */
- public ACode LSL(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, LSL(kind), v0, v1);
- }
-
- /** Builds a LSR operation. */
- public ACode LSR(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, LSR(kind), v0, v1);
- }
-
- /** Builds an ASR operation. */
- public ACode ASR(Tree t, ATypeKind kind, ACode v0, ACode v1) {
- return Apply(t, ASR(kind), v0, v1);
- }
-
- /** Builds a value conversion operation. */
- public ACode CONVERT(Tree t, ATypeKind src, ATypeKind dst, ACode v0) {
- return Apply(t, CONVERT(src, dst), v0);
- }
-
- /** Builds an array length operation. */
- public ACode LENGTH(Tree t, ATypeKind kind, ACode v0) {
- return Apply(t, LENGTH(kind), v0);
- }
-
- /** Builds a string concatenation operation. */
- public ACode CONCAT(Tree t, ATypeKind lf, ATypeKind rg, ACode v0,ACode v1){
- return Apply(t, CONCAT(lf, rg), v0, v1);
- }
-
- //########################################################################
- // Public Methods - Building primitives
-
- /** Builds a negation primitive */
- public APrimitive NOT(ATypeKind kind) {
- return APrimitive.Negation(kind);
- }
-
- /** Builds an EQ primitive */
- public APrimitive EQ(ATypeKind kind, boolean zero) {
- return APrimitive.Test(ATestOp.EQ, kind, zero);
- }
-
- /** Builds a NE primitive */
- public APrimitive NE(ATypeKind kind, boolean zero) {
- return APrimitive.Test(ATestOp.NE, kind, zero);
- }
-
- /** Builds a LT primitive */
- public APrimitive LT(ATypeKind kind, boolean zero) {
- return APrimitive.Test(ATestOp.LT, kind, zero);
- }
-
- /** Builds a GE primitive */
- public APrimitive GE(ATypeKind kind, boolean zero) {
- return APrimitive.Test(ATestOp.GE, kind, zero);
- }
-
- /** Builds a LE primitive */
- public APrimitive LE(ATypeKind kind, boolean zero) {
- return APrimitive.Test(ATestOp.LE, kind, zero);
- }
-
- /** Builds a GT primitive */
- public APrimitive GT(ATypeKind kind, boolean zero) {
- return APrimitive.Test(ATestOp.GT, kind, zero);
- }
-
- /** Builds a CMPL primitive */
- public APrimitive CMPL(ATypeKind kind) {
- return APrimitive.Comparison(AComparisonOp.CMPL, kind);
- }
-
- /** Builds a CMP primitive */
- public APrimitive CMP(ATypeKind kind) {
- return APrimitive.Comparison(AComparisonOp.CMP, kind);
- }
-
- /** Builds a CMPG primitive */
- public APrimitive CMPG(ATypeKind kind) {
- return APrimitive.Comparison(AComparisonOp.CMPG, kind);
- }
-
- /** Builds an ADD primitive */
- public APrimitive ADD(ATypeKind kind) {
- return APrimitive.Arithmetic(AArithmeticOp.ADD, kind);
- }
-
- /** Builds a SUB primitive */
- public APrimitive SUB(ATypeKind kind) {
- return APrimitive.Arithmetic(AArithmeticOp.SUB, kind);
- }
-
- /** Builds a MUL primitive */
- public APrimitive MUL(ATypeKind kind) {
- return APrimitive.Arithmetic(AArithmeticOp.MUL, kind);
- }
-
- /** Builds a DIV primitive */
- public APrimitive DIV(ATypeKind kind) {
- return APrimitive.Arithmetic(AArithmeticOp.DIV, kind);
- }
-
- /** Builds a REM primitive */
- public APrimitive REM(ATypeKind kind) {
- return APrimitive.Arithmetic(AArithmeticOp.REM, kind);
- }
-
- /** Builds an AND primitive. */
- public APrimitive AND(ATypeKind kind) {
- return APrimitive.Logical(ALogicalOp.AND, kind);
- }
-
- /** Builds an OR primitive. */
- public APrimitive OR(ATypeKind kind) {
- return APrimitive.Logical(ALogicalOp.OR, kind);
- }
-
- /** Builds an XOR primitive. */
- public APrimitive XOR(ATypeKind kind) {
- return APrimitive.Logical(ALogicalOp.XOR, kind);
- }
-
- /** Builds a LSL primitive. */
- public APrimitive LSL(ATypeKind kind) {
- return APrimitive.Shift(AShiftOp.LSL, kind);
- }
-
- /** Builds a LSR primitive. */
- public APrimitive LSR(ATypeKind kind) {
- return APrimitive.Shift(AShiftOp.LSR, kind);
- }
-
- /** Builds an ASR primitive. */
- public APrimitive ASR(ATypeKind kind) {
- return APrimitive.Shift(AShiftOp.ASR, kind);
- }
-
- /** Builds a value conversion primitive. */
- public APrimitive CONVERT(ATypeKind src, ATypeKind dst) {
- return APrimitive.Conversion(src, dst);
- }
-
- /** Builds an array length primitive. */
- public APrimitive LENGTH(ATypeKind kind) {
- return APrimitive.ArrayLength(kind);
- }
-
- /** Builds a string concatenation primitive. */
- public APrimitive CONCAT(ATypeKind lf, ATypeKind rg) {
- return APrimitive.StringConcat(lf, rg);
- }
-
- //########################################################################
- // Public Methods - Building constants
-
- /** Builds a BOOLEAN constant of given value. */
- public AConstant BOOLEAN(Boolean value) {
- return BOOLEAN(value.booleanValue());
- }
-
- /** Builds a BOOLEAN constant of given value. */
- public AConstant BOOLEAN(boolean value) {
- return AConstant.BOOLEAN(value);
- }
-
- /** Builds a BYTE constant of given value. */
- public AConstant BYTE(Byte value) {
- return BYTE(value.byteValue());
- }
-
- /** Builds a BYTE constant of given value. */
- public AConstant BYTE(byte value) {
- return AConstant.BYTE(value);
- }
-
- /** Builds a SHORT constant of given value. */
- public AConstant SHORT(Short value) {
- return SHORT(value.shortValue());
- }
-
- /** Builds a SHORT constant of given value. */
- public AConstant SHORT(short value) {
- return AConstant.SHORT(value);
- }
-
- /** Builds a CHAR constant of given value. */
- public AConstant CHAR(Character value) {
- return CHAR(value.charValue());
- }
-
- /** Builds a CHAR constant of given value. */
- public AConstant CHAR(char value) {
- return AConstant.CHAR(value);
- }
-
- /** Builds an INT constant of given value. */
- public AConstant INT(Integer value) {
- return INT(value.intValue());
- }
-
- /** Builds an INT constant of given value. */
- public AConstant INT(int value) {
- return AConstant.INT(value);
- }
-
- /** Builds a LONG constant of given value. */
- public AConstant LONG(Long value) {
- return LONG(value.longValue());
- }
-
- /** Builds a LONG constant of given value. */
- public AConstant LONG(long value) {
- return AConstant.LONG(value);
- }
-
- /** Builds a FLOAT constant of given value. */
- public AConstant FLOAT(Float value) {
- return FLOAT(value.floatValue());
- }
-
- /** Builds a FLOAT constant of given value. */
- public AConstant FLOAT(float value) {
- return AConstant.FLOAT(value);
- }
-
- /** Builds a DOUBLE constant of given value. */
- public AConstant DOUBLE(Double value) {
- return DOUBLE(value.doubleValue());
- }
-
- /** Builds a DOUBLE constant of given value. */
- public AConstant DOUBLE(double value) {
- return AConstant.DOUBLE(value);
- }
-
- /** Builds a STRING constant of given value. */
- public AConstant STRING(String value) {
- return AConstant.STRING(value);
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ATreeFromSTree.java b/sources/scalac/atree/ATreeFromSTree.java
deleted file mode 100644
index 83e50eb7e1..0000000000
--- a/sources/scalac/atree/ATreeFromSTree.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-
-import scalac.CompilationUnit;
-import scalac.ast.Tree;
-import scalac.ast.Tree.Ident;
-import scalac.ast.Tree.Template;
-import scalac.symtab.Definitions;
-import scalac.symtab.Symbol;
-import scalac.symtab.Type;
-import scalac.util.Debug;
-import scalac.util.Name;
-
-/** This class translates syntax trees into attributed trees. */
-public class ATreeFromSTree {
-
- //########################################################################
- // Private Fields
-
- /** The global definitions */
- private final Definitions definitions;
-
- /** The attributed tree factory */
- private final ATreeFactory make;
-
- /** A mapping from primitive classes to initialization state */
- private final Map/*<Symbol,Boolean>*/ states;
-
- /** A mapping from primitive methods to generators */
- private final Map/*<Symbol,Generator>*/ generators;
-
- //########################################################################
- // Public Constructors
-
- /** Initializes this instance. */
- public ATreeFromSTree(Definitions definitions) {
- this.definitions = definitions;
- this.make = new ATreeFactory();
- this.states = new HashMap();
- this.generators = new HashMap();
- Symbol[] classes = {
- definitions.ANY_CLASS,
- definitions.OBJECT_CLASS,
- definitions.STRING_CLASS,
- definitions.THROWABLE_CLASS,
- definitions.ARRAY_CLASS,
- definitions.UNIT_CLASS,
- definitions.BOOLEAN_CLASS,
- definitions.BYTE_CLASS,
- definitions.SHORT_CLASS,
- definitions.CHAR_CLASS,
- definitions.INT_CLASS,
- definitions.LONG_CLASS,
- definitions.FLOAT_CLASS,
- definitions.DOUBLE_CLASS,
- };
- for (int i = 0; i < classes.length; i++)
- states.put(classes[i], Boolean.FALSE);
- }
-
- //########################################################################
- // Public Methods - Translating units
-
- /** Translates the unit's body and stores the result in it. */
- public void translate(CompilationUnit unit) {
- template(unit.repository = new ARepository(), unit.body);
- }
-
- //########################################################################
- // Private Methods - Translating templates
-
- /** Translates the templates and adds them to the repository. */
- private void template(ARepository repository, Tree[] trees) {
- for (int i = 0; i < trees.length; i++) template(repository, trees[i]);
- }
-
- /** Translates the template and adds it to the repository. */
- private void template(ARepository repository, Tree tree) {
- switch (tree) {
-
- case Empty:
- return;
-
- case ClassDef(_, _, _, _, _, Template(_, Tree[] body)):
- AClass clasz = new AClass(tree.symbol());
- // !!! add static field to global modules
- repository.addClass(clasz);
- member(clasz, body);
- return;
-
- case PackageDef(_, Template(_, Tree[] body)):
- template(repository, body);
- return;
-
- default:
- throw Debug.abort("illegal case", tree);
- }
- }
-
- //########################################################################
- // Private Methods - Translating members
-
- /** Translates the members and adds them to the class. */
- private void member(AClass clasz, Tree[] trees) {
- for (int i = 0; i < trees.length; i++) member(clasz, trees[i]);
- }
-
- /** Translates the member and adds it to the class. */
- private void member(AClass clasz, Tree tree) {
- switch (tree) {
-
- case Empty:
- return;
-
- case ClassDef(_, _, _, _, _, _):
- template(clasz, tree);
- return;
-
- case ValDef(_, _, _, Tree rhs):
- AField field = new AField(tree.symbol(), false);
- clasz.addField(field);
- return;
-
- case DefDef(_, _, _, _, _, Tree rhs):
- AMethod method = new AMethod(tree.symbol(), false);
- clasz.addMethod(method);
- if (!method.isAbstract()) method.setCode(expression(rhs));
- return;
-
- default:
- throw Debug.abort("illegal case", tree);
- }
- }
-
- //########################################################################
- // Private Methods - Translating statements
-
- /** Translates the statements. */
- private ACode[] statement(List locals, Tree[] trees) {
- List codes = new ArrayList();
- for (int i = 0; i < trees.length; i++) {
- ACode code = statement(locals, trees[i]);
- if (code != ACode.Void) codes.add(code);
- }
- return (ACode[])codes.toArray(new ACode[codes.size()]);
- }
-
- /** Translates the statement. */
- private ACode statement(List locals, Tree tree) {
- switch (tree) {
-
- case Empty:
- return make.Void;
-
- case ValDef(_, _, _, Tree rhs):
- Symbol symbol = tree.symbol();
- locals.add(symbol);
- ALocation location = ALocation.Local(symbol, false);
- return make.Store(tree, location, expression(rhs));
-
- default:
- return ACode.Drop(expression(tree), tree.type());
- }
- }
-
- //########################################################################
- // Private Methods - Translating expressions
-
- /** Translates the expressions. */
- private ACode[] expression(Tree[] trees) {
- ACode[] codes = new ACode[trees.length];
- for (int i = 0; i < codes.length; i++) codes[i] = expression(trees[i]);
- return codes;
- }
-
- /** Translates the expression. */
- private ACode expression(Tree tree) {
- switch (tree) {
-
- case LabelDef(_, Ident[] idents, Tree rhs):
- Symbol[] locals = Tree.symbolOf(idents);
- return make.Label(tree, tree.symbol(), locals, expression(rhs));
-
- case Block(Tree[] stats, Tree value):
- List locals = new ArrayList();
- ACode[] codes = statement(locals, stats);
- ACode code = expression(value);
- if (locals.size() == 0 && codes.length == 0) return code;
- Symbol[] symbols =
- (Symbol[])locals.toArray(new Symbol[locals.size()]);
- return make.Block(tree, symbols, codes, code);
-
- case Assign(Tree lhs, Tree rhs):
- return make.Block(tree, Symbol.EMPTY_ARRAY, new ACode[] {
- make.Store(tree, location(lhs), expression(rhs))},
- make.Void);
-
- case If(Tree cond, Tree thenp, Tree elsep):
- ACode test = expression(cond);
- return make.If(tree, test, expression(thenp), expression(elsep));
-
- case Switch(Tree test, int[] tags, Tree[] bodies, Tree otherwise):
- int[][] tagss = new int[tags.length][];
- for (int i = 0; i < tagss.length; i++)
- tagss[i] = new int[] {tags[i]};
- ACode[] codes = new ACode[bodies.length + 1];
- for (int i = 0; i < bodies.length; i++)
- codes[i] = expression(bodies[i]);
- codes[tags.length] = expression(otherwise);
- return make.Switch(tree, expression(test), tagss, codes);
-
- case Return(Tree value):
- return make.Return(tree, tree.symbol(), expression(value));
-
- case Throw(Tree value):
- return make.Throw(tree, expression(value));
-
- case New(Apply(Tree fun, Tree[] vargs)):
- switch (fun) {
- case Select(Create(_, Tree[] targs), _):
- return apply(tree, fun, targs, vargs);
- default:
- throw Debug.abort("illegal case", tree);
- }
-
- case Apply(TypeApply(Tree fun, Tree[] targs), Tree[] vargs):
- return apply(tree, fun, targs, vargs);
- case Apply(Tree fun, Tree[] vargs):
- return apply(tree, fun, Tree.EMPTY_ARRAY, vargs);
-
- case Super(_, _):
- case This(_):
- return make.This(tree, tree.symbol());
-
- case Select(_, _):
- case Ident(_):
- return make.Load(tree, location(tree));
-
- case Literal(AConstant value):
- return make.Constant(tree, value);
-
- default:
- throw Debug.abort("illegal case", tree);
- }
- }
-
- /** Translates the application. */
- private ACode apply(Tree tree, Tree fun, Tree[] targs, Tree[] vargs) {
- Symbol symbol = fun.symbol();
- ACode[] codes = expression(vargs);
- if (symbol.isLabel()) return make.Goto(tree, symbol, codes);
- Type[] types = Tree.typeOf(targs);
- AFunction function = function(fun);
- switch (function) {
- case Method(ACode object, Symbol method, AInvokeStyle style):
- if (!style.isDynamic()) break;
- Symbol clasz = method.owner();
- Object state = states.get(clasz);
- if (state == null) break;
- if (state != Boolean.TRUE) addGeneratorsOf(clasz);
- Object generator = generators.get(method);
- if (generator == null) break;
- return generate((Generator)generator, tree, object, types, vargs);
- }
- return make.Apply(tree, function, types, codes);
- }
-
- //########################################################################
- // Private Methods - Translating functions
-
- /** Translates the method. */
- private AFunction function(Tree tree) {
- Symbol symbol = tree.symbol();
- switch (tree) {
-
- case Select(Create(_, _), _):
- AInvokeStyle style = AInvokeStyle.New;
- return AFunction.Method(make.Void, symbol, style);
-
- case Select(Tree qualifier, _):
- AInvokeStyle style = invokeStyle(qualifier);
- return AFunction.Method(expression(qualifier), symbol, style);
-
- case Ident(_):
- AInvokeStyle style = AInvokeStyle.StaticClass;
- return AFunction.Method(make.Void, symbol, style);
-
- default:
- throw Debug.abort("illegal case", tree);
- }
- }
-
- /** Returns the InvokeStyle to use for the qualifier. */
- private AInvokeStyle invokeStyle(Tree qualifier) {
- switch (qualifier) {
- case Super(_, _):
- return AInvokeStyle.StaticInstance;
- default:
- return AInvokeStyle.Dynamic;
- }
- }
-
- //########################################################################
- // Private Methods - Translating locations
-
- /** Translates the location. */
- private ALocation location(Tree tree) {
- Symbol symbol = tree.symbol();
- switch (tree) {
-
- case Select(Tree qualifier, _):
- return ALocation.Field(expression(qualifier), symbol, false);
-
- case Ident(_):
- if (symbol.isModule()) return ALocation.Module(symbol);
- return symbol.owner().isClass()
- ? ALocation.Field(make.Void, symbol, true)
- : ALocation.Local(symbol, symbol.isParameter());
-
- default:
- throw Debug.abort("illegal case", tree);
- }
- }
-
- //########################################################################
- // Private Methods - Translating constants
-
- /** Translates the constant. */
- private AConstant constant(Object value) {
- if (value instanceof Boolean ) return make.BOOLEAN((Boolean )value);
- if (value instanceof Byte ) return make.BYTE (((Byte )value));
- if (value instanceof Short ) return make.SHORT ((Short )value);
- if (value instanceof Character) return make.CHAR ((Character)value);
- if (value instanceof Integer ) return make.INT ((Integer )value);
- if (value instanceof Long ) return make.LONG ((Long )value);
- if (value instanceof Float ) return make.FLOAT ((Float )value);
- if (value instanceof Double ) return make.DOUBLE ((Double )value);
- if (value instanceof String ) return make.STRING ((String )value);
- throw Debug.abort("illegal constant", value +" -- "+ value.getClass());
- }
-
- //########################################################################
- // Private Methods - Generating code for primitive methods
-
- /** Applies generator to given object and arguments. */
- private ACode generate(Generator generator, Tree tree, ACode object,
- Type[] targs, Tree[] vargs)
- {
- switch (generator) {
-
- case ANYID:
- assert targs.length == 0 && vargs.length == 1: tree;
- return make.EQ(tree, ATypeKind.REF, object, expression(vargs[0]));
-
- case ANYNI:
- assert targs.length == 0 && vargs.length == 1: tree;
- return make.NE(tree, ATypeKind.REF, object, expression(vargs[0]));
-
- case ANYEQ:
- Symbol lf = newLocal(tree, definitions.ANY_TYPE());
- Symbol rg = newLocal(tree, definitions.ANY_TYPE());
- return make.Block(tree,
- new Symbol[] {lf, rg},
- new ACode[] {
- store(tree, lf, object),
- store(tree, rg, expression(vargs[0]))},
- make.If(tree,
- make.EQ(tree, ATypeKind.REF, load(tree, lf)),
- make.EQ(tree, ATypeKind.REF, load(tree, rg)),
- make.Apply(tree,
- AFunction.Method(
- load(tree, lf),
- definitions.ANY_EQUALS,
- AInvokeStyle.Dynamic),
- Type.EMPTY_ARRAY,
- new ACode[] {load(tree, rg)})));
-
- case ANYNE:
- Symbol lf = newLocal(tree, definitions.ANY_TYPE());
- Symbol rg = newLocal(tree, definitions.ANY_TYPE());
- return make.Block(tree,
- new Symbol[] {lf, rg},
- new ACode[] {
- store(tree, lf, object),
- store(tree, rg, expression(vargs[0]))},
- make.If(tree,
- make.EQ(tree, ATypeKind.REF, load(tree, lf)),
- make.NE(tree, ATypeKind.REF, load(tree, rg)),
- make.NOT(tree,
- ATypeKind.BOOL,
- make.Apply(tree,
- AFunction.Method(
- load(tree, lf),
- definitions.ANY_EQUALS,
- AInvokeStyle.Dynamic),
- Type.EMPTY_ARRAY,
- new ACode[] {load(tree, rg)}))));
-
- case ISAS(boolean cast):
- assert targs.length == 1 && vargs.length == 0: tree;
- return make.IsAs(tree, object, targs[0], cast);
-
- case SYNCHRONIZED:
- assert targs.length == 1 && vargs.length == 1: tree;
- return make.Synchronized(tree, object, expression(vargs[0]));
-
- case THROW:
- assert targs.length == 0 && vargs.length == 0: tree;
- return make.Throw(tree, object);
-
- case CONCAT(ATypeKind prefix):
- assert targs.length == 0 && vargs.length == 1: tree;
- ATypeKind suffix = kind(vargs[0].type());
- ACode argument = expression(vargs[0]);
- return make.CONCAT(tree, prefix, suffix, object, argument);
-
- default:
- throw Debug.abort("unknown case", generator);
- }
- }
-
- /** Generates a load operation with given variable. */
- private ACode load(Tree tree, Symbol local) {
- assert local.owner().isNone(): Debug.show(local);
- return make.Load(tree, ALocation.Local(local, false));
- }
-
- /** Generates a store operation with given variable and value. */
- private ACode store(Tree tree, Symbol local, ACode value) {
- assert local.owner().isNone(): Debug.show(local);
- return make.Store(tree, ALocation.Local(local, false), value);
- }
-
- /** Creates a variable with tree's position and given type. */
- private Symbol newLocal(Tree tree, Type type) {
- Symbol owner = Symbol.NONE; // !!!
- Name name = Name.fromString("local"); // !!!
- return owner.newTerm(tree.pos, 0, name).setType(type);
- }
-
- /** Returns the type kind of given type. */
- private ATypeKind kind(Type type) {
- switch (type) {
- case SingleType(_, _):
- case ConstantType(_, _):
- return kind(type.singleDeref());
- case TypeRef(_, Symbol clasz, _):
- if (clasz == definitions.BOOLEAN_CLASS) return ATypeKind.BOOL;
- if (clasz == definitions.BYTE_CLASS) return ATypeKind.I1;
- if (clasz == definitions.SHORT_CLASS) return ATypeKind.I2;
- if (clasz == definitions.CHAR_CLASS) return ATypeKind.U2;
- if (clasz == definitions.INT_CLASS) return ATypeKind.I4;
- if (clasz == definitions.LONG_CLASS) return ATypeKind.I8;
- if (clasz == definitions.FLOAT_CLASS) return ATypeKind.R4;
- if (clasz == definitions.DOUBLE_CLASS) return ATypeKind.R8;
- if (clasz == definitions.STRING_CLASS) return ATypeKind.STR;
- return ATypeKind.REF;
- default:
- return ATypeKind.REF;
- }
- }
-
- //########################################################################
- // Private Methods - Collecting primitive methods
-
- /** Associates generators to primitive methods of given class. */
- private void addGeneratorsOf(Symbol clasz) {
- if (clasz == definitions.ANY_CLASS) {
- addGenerator(definitions.ANY_EQEQ, Generator.ANYEQ);
- addGenerator(definitions.ANY_BANGEQ, Generator.ANYNE);
- addGenerator(definitions.ANY_IS_ERASED, Generator.ISAS(false));
- addGenerator(definitions.ANY_AS_ERASED, Generator.ISAS(true));
- }
- if (clasz == definitions.OBJECT_CLASS) {
- addGenerator(definitions.OBJECT_EQ, Generator.ANYID);
- addGenerator(definitions.OBJECT_NE, Generator.ANYNI);
- addGenerator(definitions.OBJECT_SYNCHRONIZED, Generator.SYNCHRONIZED);
- }
- if (clasz == definitions.STRING_CLASS) {
- addGenerator(definitions.STRING_PLUS, Generator.CONCAT(ATypeKind.STR));
- }
- if (clasz == definitions.THROWABLE_CLASS) {
- addGenerator(definitions.THROWABLE_THROW, Generator.THROW);
- }
- if (clasz == definitions.ARRAY_CLASS) {
- // !!! addAll(defs.ARRAY_CLASS, Names.length, Primitive.LENGTH, 1);
- // !!! addAll(defs.ARRAY_CLASS, Names.apply, Primitive.APPLY, 2);
- // !!! addAll(defs.ARRAY_CLASS, Names.update, Primitive.UPDATE, 1);
- }
- if (clasz == definitions.UNIT_CLASS) {
- // !!!
- }
- if (clasz == definitions.BOOLEAN_CLASS) {
- // !!!
- }
- if (clasz == definitions.BYTE_CLASS) {
- // !!!
- }
- if (clasz == definitions.SHORT_CLASS) {
- // !!!
- }
- if (clasz == definitions.CHAR_CLASS) {
- // !!!
- }
- if (clasz == definitions.INT_CLASS) {
- // !!!
- }
- if (clasz == definitions.LONG_CLASS) {
- // !!!
- }
- if (clasz == definitions.FLOAT_CLASS) {
- // !!!
- }
- if (clasz == definitions.DOUBLE_CLASS) {
- // !!!
- }
- states.put(clasz, Boolean.TRUE);
- }
-
- /** Associates given generator to given primitive method. */
- private void addGenerator(Symbol method, Generator generator) {
- generators.put(method, generator);
- }
-
- //########################################################################
- // Private Class - Code generators
-
- /** Code generators for primitive methods. */
- private static class Generator {
- case ANYID;
- case ANYNI;
- case ANYEQ;
- case ANYNE;
- case ISAS(boolean cast);
- case SYNCHRONIZED;
- case THROW;
- case CONCAT(ATypeKind prefix);
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ATreePrinter.java b/sources/scalac/atree/ATreePrinter.java
deleted file mode 100644
index fb0a108a99..0000000000
--- a/sources/scalac/atree/ATreePrinter.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import ch.epfl.lamp.util.CodePrinter;
-
-import scalac.Global;
-import scalac.Phase;
-import scalac.CompilationUnit;
-import scalac.symtab.Type;
-import scalac.symtab.Symbol;
-import scalac.symtab.SymbolTablePrinter;
-import scalac.util.Debug;
-import scalac.util.SourceRepresentation;
-
-/** This class provides methods to print attributed trees. */
-public class ATreePrinter {
-
- //########################################################################
- // Private Fields
-
- /** The global environment */
- private final Global global;
-
- /** The underlying code printer */
- private final CodePrinter printer;
-
- /** The underlying symbol table printer */
- private final SymbolTablePrinter symtab;
-
- //########################################################################
- // Public Constructors
-
- /** Initalizes this instance */
- public ATreePrinter() {
- this(new CodePrinter());
- }
-
- /** Initalizes this instance */
- public ATreePrinter(String step) {
- this(Global.instance, new CodePrinter(step));
- }
-
- /** Initalizes this instance */
- public ATreePrinter(CodePrinter printer) {
- this(Global.instance, printer);
- }
-
- /** Initalizes this instance */
- public ATreePrinter(Global global, CodePrinter printer) {
- this.global = global;
- this.printer = printer;
- this.symtab = new SymbolTablePrinter(global, printer);
- }
-
- //########################################################################
- // Public Methods - Getting & Setting
-
- /** Returns the underlying code printer. */
- public CodePrinter getCodePrinter() {
- return printer;
- }
-
- //########################################################################
- // Public Methods - Formatting
-
- /** Increases the indentation level by one. */
- public ATreePrinter indent() {
- printer.indent();
- return this;
- }
-
- /** Decreases the indentation level by one. */
- public ATreePrinter undent() {
- printer.undent();
- return this;
- }
-
- /** Inserts a new line. */
- public ATreePrinter line() {
- printer.line();
- return this;
- }
-
- /** Inserts a white space. */
- public ATreePrinter space() {
- printer.space();
- return this;
- }
-
- /** Prints an opening brace followed by a new line. */
- public ATreePrinter lbrace() {
- return space().println('{').indent();
- }
-
- /** Prints a closing brace followed by a new line. */
- public ATreePrinter rbrace() {
- return undent().space().println('}');
- }
-
- //########################################################################
- // Public Methods - Printing simple values
-
- /** Prints a new line. */
- public ATreePrinter println() {
- printer.println();
- return this;
- }
-
- /** Prints the boolean value followed by a new line. */
- public ATreePrinter println(boolean value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the byte value followed by a new line. */
- public ATreePrinter println(byte value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the short value followed by a new line. */
- public ATreePrinter println(short value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the char value followed by a new line. */
- public ATreePrinter println(char value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the int value followed by a new line. */
- public ATreePrinter println(int value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the long value followed by a new line. */
- public ATreePrinter println(long value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the float value followed by a new line. */
- public ATreePrinter println(float value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the double value followed by a new line. */
- public ATreePrinter println(double value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the string followed by a new line. */
- public ATreePrinter println(String value) {
- printer.println(value);
- return this;
- }
-
- /** Prints the boolean value. */
- public ATreePrinter print(boolean value) {
- printer.print(value);
- return this;
- }
-
- /** Prints the byte value. */
- public ATreePrinter print(byte value) {
- printer.print(value);
- return this;
- }
-
- /** Prints the short value. */
- public ATreePrinter print(short value) {
- printer.print(value);
- return this;
- }
-
- /** Prints the char value. */
- public ATreePrinter print(char value) {
- printer.print(value);
- return this;
- }
-
- /** Prints the int value. */
- public ATreePrinter print(int value) {
- printer.print(value);
- return this;
- }
-
- /** Prints the long value. */
- public ATreePrinter print(long value) {
- printer.print(value);
- return this;
- }
-
- /** Prints the float value. */
- public ATreePrinter print(float value) {
- printer.print(value);
- return this;
- }
-
- /** Prints the long value. */
- public ATreePrinter print(double value) {
- printer.print(value);
- return this;
- }
-
- /** Prints the string. */
- public ATreePrinter print(String value) {
- printer.print(value);
- return this;
- }
-
- //########################################################################
- // Public Methods - Printing types and symbols
-
- /** Prints the symbol. */
- public ATreePrinter printSymbol(Symbol symbol) {
- symtab.printSymbolName(symbol);
- return this;
- }
-
- /** Prints the type. */
- public ATreePrinter printType(Type type) {
- symtab.printType(type);
- return this;
- }
-
- //########################################################################
- // Public Methods - Printing trees
-
- /** Prints the units. */
- public ATreePrinter printUnits(CompilationUnit[] units) {
- Phase phase = global.currentPhase;
- println("[[attributed trees at "+phase+" (after "+phase.prev+")]]");
- for (int i = 0; i < units.length; i++) printUnit(units[i]);
- return this;
- }
-
- /** Prints the unit. */
- public ATreePrinter printUnit(CompilationUnit unit) {
- println("// Scala source: " + unit.source);
- return printRepository(unit.repository);
- }
-
- /** Prints the repository. */
- public ATreePrinter printRepository(ARepository repository) {
- AClass[] classes = repository.classes();
- for (int i = 0; i < classes.length; i++) printClass(classes[i]);
- return this;
- }
-
- /** Prints the class. */
- public ATreePrinter printClass(AClass clasz) {
- printClassModifiers(clasz);
- print(clasz.isInterface() ? "interface" : "class").space();
- printSymbol(clasz.symbol());
- Symbol[] tparams = clasz.tparams();
- if (tparams.length != 0) symtab.printTypeParams(tparams);
- Symbol[] vparams = clasz.vparams();
- if (vparams.length != 0) symtab.printValueParams(vparams);
- if (clasz.symbol().typeOfThis() != clasz.symbol().thisType())
- space().print(':').printType(clasz.symbol().typeOfThis());
- space().print("extends").space();
- symtab.printTypes(clasz.parents()," with ");
- lbrace();
- printRepository(clasz);
- AField[] fields = clasz.fields();
- for (int i = 0; i < fields.length; i++) printField(fields[i]);
- AMethod[] methods = clasz.methods();
- for (int i = 0; i < methods.length; i++) printMethod(methods[i]);
- return rbrace();
- }
-
- /** Prints the class modifiers. */
- public ATreePrinter printClassModifiers(AClass clasz) {
- if (clasz.isDeprecated()) print("deprecated").space();
- if (clasz.isSynthetic()) print("synthetic").space();
- if (clasz.isPublic()) print("public").space();
- if (clasz.isPrivate()) print("private").space();
- if (clasz.isProtected()) print("protected").space();
- if (clasz.isFinal()) print("final").space();
- if (clasz.isAbstract()) print("abstract").space();
- return this;
- }
-
- /** Prints the member modifiers. */
- public ATreePrinter printMemberModifiers(AMember member) {
- if (member.isDeprecated()) print("deprecated").space();
- if (member.isSynthetic()) print("synthetic").space();
- if (member.isPublic()) print("public").space();
- if (member.isPrivate()) print("private").space();
- if (member.isProtected()) print("protected").space();
- if (member.isStatic()) print("static").space();
- return this;
- }
-
- /** Prints the member code. */
- public ATreePrinter printMemberCode(AMember member) {
- if (member.code() == ACode.Void) return this;
- return print('=').space().printCode(member.code());
- }
-
- /** Prints the field. */
- public ATreePrinter printField(AField field) {
- printFieldModifiers(field);
- symtab.printSignature(field.symbol()).space();
- return printMemberCode(field).line();
- }
-
- /** Prints the field modifiers. */
- public ATreePrinter printFieldModifiers(AField field) {
- printMemberModifiers(field);
- if (field.isFinal()) print("final").space();
- if (field.isVolatile()) print("volatile").space();
- if (field.isTransient()) print("transient").space();
- return this;
- }
-
- /** Prints the method. */
- public ATreePrinter printMethod(AMethod method) {
- printMethodModifiers(method);
- symtab.printSignature(method.symbol()).space();
- return printMemberCode(method).line();
- }
-
- /** Prints the method modifiers. */
- public ATreePrinter printMethodModifiers(AMethod method) {
- printMemberModifiers(method);
- if (method.isFinal()) print("final").space();
- if (method.isSynchronized()) print("synchronized").space();
- if (method.isNative()) print("native").space();
- if (method.isAbstract()) print("abstract").space();
- return this;
- }
-
- /** Prints the code. */
- public ATreePrinter printCode(ACode code) {
- switch (code) {
- case Void:
- return print("<void>");
- case This(Symbol clasz):
- return printSymbol(clasz).print('.').print("this");
- case Constant(AConstant constant):
- return printConstant(constant);
- case Load(ALocation location):
- return printLocation(location);
- case Store(ALocation location, ACode value):
- printLocation(location).space().print('=').space();
- return printCode(value);
- case Apply(AFunction function, Type[] targs, ACode[] vargs):
- printFunction(function);
- if (targs.length > 0){
- print('[');
- for (int i = 0; i < targs.length; i++)
- (i == 0 ? this : print(',').space()).printType(targs[i]);
- print(']');
- }
- print('(');
- for (int i = 0; i < vargs.length; i++)
- (i == 0 ? this : print(',').space()).printCode(vargs[i]);
- print(')');
- return this;
- case IsAs(ACode value, Type type, boolean cast):
- printCode(value).print('.').print(cast ? "as" : "is");
- return print('[').printType(type).print(']');
- case If(ACode test, ACode success, ACode failure):
- print("if").space().print('(').printCode(test).print(')').lbrace();
- printCode(success).line();
- rbrace().space().print("else").space().lbrace();
- printCode(failure).line();
- return rbrace();
- case Switch(ACode test, int[][] tags, ACode[] bodies):
- print("switch").space().print('(').printCode(test).print(')');
- lbrace();
- for (int i = 0; i < tags.length; i++) {
- for (int j = 0; j < tags[i].length; j++)
- print("case").space().print(tags[i][j]).print(':').line();
- indent().printCode(bodies[i]).undent().line();
- }
- print("case").space().print('_').print(':').line();
- indent().printCode(bodies[tags.length]).undent();
- return rbrace();
- case Synchronized(ACode lock, ACode value):
- print("synchronized").space();
- print('(').printCode(lock).print(')');
- return lbrace().printCode(value).rbrace();
- case Block(Symbol[] locals, ACode[] statements, ACode value):
- lbrace();
- for (int i = 0; i < locals.length; i++) {
- print("var").space().printSymbol(locals[i]);
- print(":").space().printType(locals[i].type());
- println(";");
- }
- for (int i = 0; i < statements.length; i++)
- printCode(statements[i]).println(';');
- return printCode(value).line().rbrace();
- case Label(Symbol label, Symbol[] locals, ACode value):
- print("label").space().printSymbol(label).print('(');
- for (int i = 0; i < locals.length; i++)
- (i == 0 ? this : print(',').space()).printSymbol(locals[i]);
- print(')').space().print('=').lbrace();
- return printCode(value).rbrace();
- case Goto(Symbol label, ACode[] vargs):
- print("goto").space().printSymbol(label).print('(');
- for (int i = 0; i < vargs.length; i++)
- (i == 0 ? this : print(',').space()).printCode(vargs[i]);
- return print(')');
- case Return(Symbol function, ACode value):
- print("return").symtab.printSymbolUniqueId(function).space();
- return printCode(value);
- case Throw(ACode value):
- return print("throw").space().printCode(value);
- case Drop(ACode value, Type type):
- print("drop").print('[').printType(type).print(']').space();
- return printCode(value);
- default:
- throw Debug.abort("unknown case", code);
- }
- }
-
- /** Prints the location. */
- public ATreePrinter printLocation(ALocation location) {
- switch (location) {
- case Module(Symbol module):
- return printSymbol(module);
- case Field(Void, Symbol field, true):
- return printSymbol(field.owner()).print('.').printSymbol(field);
- case Field(ACode object, Symbol field, boolean isStatic):
- printCode(object).print('.');
- if (isStatic) print("<static>").space();
- return printSymbol(field);
- case Local(Symbol local, _):
- return printSymbol(local);
- case ArrayItem(ACode array, ACode index):
- return printCode(array).print('(').printCode(index).print(')');
- default:
- throw Debug.abort("unknown case", location);
- }
- }
-
- /** Prints the function. */
- public ATreePrinter printFunction(AFunction function) {
- switch (function) {
- case Method(Void, Symbol method, AInvokeStyle.New):
- return print("new").space().printSymbol(method);
- case Method(Void, Symbol method, AInvokeStyle.Static(false)):
- return printSymbol(method.owner()).print('.').printSymbol(method);
- case Method(This(Symbol c), Symbol method, AInvokeStyle.Static(true)):
- printSymbol(c).print('.').print("super").print('.');
- return printSymbol(method);
- case Method(ACode object, Symbol method, AInvokeStyle style):
- printCode(object).print('.');
- if (style != AInvokeStyle.Dynamic) print("<" +style+ ">").space();
- return printSymbol(method);
- case Primitive(APrimitive primitive):
- return printPrimitive(primitive);
- case NewArray(Type element):
- return print("new").space().printType(element).print("[]");
- default:
- throw Debug.abort("unknown case", function);
- }
- }
-
- /** Prints the primitive. */
- public ATreePrinter printPrimitive(APrimitive primitive) {
- switch (primitive) {
- case Negation(ATypeKind kind):
- return printPrimitiveOp("NEG", kind);
- case Test(ATestOp op, ATypeKind kind, boolean zero):
- return printPrimitiveOp(op.toString() + (zero ? "Z" : ""), kind);
- case Comparison(AComparisonOp op, ATypeKind kind):
- return printPrimitiveOp(op.toString(), kind);
- case Arithmetic(AArithmeticOp op, ATypeKind kind):
- return printPrimitiveOp(op.toString(), kind);
- case Logical(ALogicalOp op, ATypeKind kind):
- return printPrimitiveOp(op.toString(), kind);
- case Shift(AShiftOp op, ATypeKind kind):
- return printPrimitiveOp(op.toString(), kind);
- case Conversion(ATypeKind src, ATypeKind dst):
- return printPrimitiveOp("CONV", src, dst);
- case ArrayLength(ATypeKind kind):
- return printPrimitiveOp("LENGTH", kind);
- case StringConcat(ATypeKind lf, ATypeKind rg):
- return printPrimitiveOp("CONCAT", lf, rg);
- default:
- throw Debug.abort("unknown case", primitive);
- }
- }
-
- /** Prints the primitive operation of given type kind. */
- public ATreePrinter printPrimitiveOp(String op, ATypeKind kind) {
- return printPrimitiveOp(op, kind, null);
- }
-
- /** Prints the primitive operation of given types. */
- public ATreePrinter printPrimitiveOp(String op, ATypeKind k1,ATypeKind k2){
- print('<').print(op).print('>');
- if (k1 != null && global.uniqid) print('#').print(k1.toString());
- if (k2 != null && global.uniqid) print(',').print(k2.toString());
- return this;
- }
-
- /** Prints the constant. */
- public ATreePrinter printConstant(AConstant constant) {
- switch (constant) {
- case UNIT:
- return print("()");
- case BOOLEAN(boolean value):
- return print(value);
- case BYTE(byte value):
- return print(value);
- case SHORT(short value):
- return print(value);
- case CHAR(char value):
- return print('\'').print(value).print('\'');
- case INT(int value):
- return print(value);
- case LONG(long value):
- return print(value);
- case FLOAT(float value):
- return print(value);
- case DOUBLE(double value):
- return print(value);
- case STRING(String value):
- return print('\"').print(SourceRepresentation.escape(value)).print('\"');
- case SYMBOL_NAME(Symbol value):
- return print('\"').print(SourceRepresentation.escape(value.name.toString())).print('\"');
- case NULL:
- return print("null");
- case ZERO:
- return print("<zero>");
- default:
- throw Debug.abort("unknown case", constant);
- }
- }
-
- //########################################################################
- // Public Methods - Converting
-
- /** Returns the string representation of this printer. */
- public String toString() {
- return printer.toString();
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ATreeTyper.java b/sources/scalac/atree/ATreeTyper.java
deleted file mode 100644
index 06133db15f..0000000000
--- a/sources/scalac/atree/ATreeTyper.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scala.tools.util.Position;
-
-import scalac.Global;
-import scalac.symtab.Definitions;
-import scalac.symtab.Modifiers;
-import scalac.symtab.Symbol;
-import scalac.symtab.Type;
-import scalac.util.Debug;
-import scalac.util.Name;
-
-/** This class implements an attributed tree typer. */
-public class ATreeTyper {
-
- //########################################################################
- // Private Fields
-
- /** The global environment */
- public final Global global;
-
- /** The global definitions */
- private final Definitions definitions;
-
- //########################################################################
- // Public Constructors
-
- /** Initializes this instance. */
- public ATreeTyper(Global global, Definitions definitions) {
- this.global = global;
- this.definitions = definitions;
- }
-
- //########################################################################
- // Public Methods - Typing code
-
- /** Returns the types of the given codes. */
- public Type[] type(ACode[] codes) {
- Type[] types = new Type[codes.length];
- for (int i = 0; i < types.length; i++) types[i] = type(codes[i]);
- return types;
- }
-
- /** Returns the type of the given code. */
- public Type type(ACode code) {
- switch (code) {
- case Void:
- return definitions.void_TYPE();
- case This(Symbol clasz):
- return clasz.thisType();
- case Constant(AConstant constant):
- return type(constant);
- case Load(ALocation location):
- return type(location);
- case Store(_, _):
- return Type.NoType;
- case Apply(AFunction function, Type[] targs, _):
- return apply(type(function), targs).resultType();
- case IsAs(_, Type type, boolean cast):
- return cast ? type : definitions.boolean_TYPE();
- case If(_, ACode success, ACode failure):
- return Type.lub(new Type[]{type(success), type(failure)});
- case Switch(_, _, ACode[] bodies):
- return Type.lub(type(bodies));
- case Synchronized(_, ACode value):
- return type(value);
- case Block(_, _, ACode value):
- return type(value);
- case Label(Symbol label, _, _):
- return label.type().resultType();
- case Goto(_, _):
- return Type.NoType;
- case Return(_, _):
- return Type.NoType;
- case Throw(_):
- return Type.NoType;
- case Drop(_, _):
- return Type.NoType;
- default:
- throw Debug.abort("unknown case", code);
- }
- }
-
- //########################################################################
- // Public Methods - Typing value locations
-
- /** Returns the type of the given value location. */
- public Type type(ALocation location) {
- switch (location) {
- case Module(Symbol module):
- return module.thisType();
- case Field(Void, Symbol field, _):
- return field.owner().thisType().memberStabilizedType(field);
- case Field(ACode object, Symbol field, _):
- return type(object).memberStabilizedType(field);
- case Local(Symbol local, _):
- return local.type();
- case ArrayItem(ACode array, _):
- return getArrayElementType(type(array));
- default:
- throw Debug.abort("unknown case", location);
- }
- }
-
- //########################################################################
- // Public Methods - Typing function references
-
- /** Returns the type of the given function reference. */
- public Type type(AFunction function) {
- switch (function) {
- case Method(Void, Symbol method, AInvokeStyle style):
- Type type = method.owner().thisType().memberStabilizedType(method);
- if (style == AInvokeStyle.New) {
- assert method.isInitializer(): function;
- Symbol[] tparams = method.owner().typeParams();
- if (tparams.length != 0) type = Type.PolyType(tparams, type);
- }
- return type;
- case Method(ACode object, Symbol method, _):
- return type(object).memberStabilizedType(method);
- case Primitive(APrimitive primitive):
- return type(primitive);
- case NewArray(Type element):
- return definitions.array_TYPE(element);
- default:
- throw Debug.abort("unknown case", function);
- }
- }
-
- //########################################################################
- // Public Methods - Typing primitives
-
- /** Returns the type of the given primitive. */
- public Type type(APrimitive primitive) {
- switch (primitive) {
- case Negation(ATypeKind kind):
- Type type = type(kind);
- return getMethodType(type, type);
- case Test(_, ATypeKind kind, true):
- Type type = type(kind);
- return getMethodType(type, type(ATypeKind.BOOL));
- case Test(_, ATypeKind kind, false):
- Type type = type(kind);
- return getMethodType(type, type, type(ATypeKind.BOOL));
- case Comparison(_, ATypeKind kind):
- Type type = type(kind);
- return getMethodType(type, type, type(ATypeKind.I4));
- case Arithmetic(_, ATypeKind kind):
- Type type = type(kind);
- return getMethodType(type, type, type);
- case Logical(_, ATypeKind kind):
- Type type = type(kind);
- return getMethodType(type, type, type);
- case Shift(_, ATypeKind kind):
- Type type = type(kind);
- return getMethodType(type, type(ATypeKind.I4), type);
- case Conversion(ATypeKind src, ATypeKind dst):
- return getMethodType(type(src), type(dst));
- case ArrayLength(ATypeKind kind):
- Type type = definitions.array_TYPE(type(kind));
- return getMethodType(type, type(ATypeKind.I4));
- case StringConcat(ATypeKind lf, ATypeKind rg):
- return getMethodType(type(lf), type(rg), type(ATypeKind.STR));
- default:
- throw Debug.abort("unknown case", primitive);
- }
- }
-
- //########################################################################
- // Public Methods - Typing constants
-
- /** Returns the type of the given constant. */
- public Type type(AConstant constant) {
- Type base = basetype(constant);
- if (global.currentPhase.id > global.PHASE.ERASURE.id()) return base;
- return Type.ConstantType(base, constant);
- }
-
- /** Returns the base type of the given constant. */
- public Type basetype(AConstant constant) {
- switch (constant) {
- case UNIT : return definitions.void_TYPE(); // !!! -> UNIT_TYPE()
- case BOOLEAN(_): return definitions.boolean_TYPE();
- case BYTE(_) : return definitions.byte_TYPE();
- case SHORT(_) : return definitions.short_TYPE();
- case CHAR(_) : return definitions.char_TYPE();
- case INT(_) : return definitions.int_TYPE();
- case LONG(_) : return definitions.long_TYPE();
- case FLOAT(_) : return definitions.float_TYPE();
- case DOUBLE(_) : return definitions.double_TYPE();
- case SYMBOL_NAME(_):
- case STRING(_) : return definitions.STRING_TYPE();
- case NULL : return definitions.ALLREF_TYPE();
- case ZERO : return definitions.ALL_TYPE();
- default : throw Debug.abort("unknown case", constant);
- }
- }
-
- //########################################################################
- // Public Methods - Typing type kinds
-
- /** Returns the type of the given type kind. */
- public Type type(ATypeKind kind) {
- switch (kind) {
- case UNIT: return definitions.void_TYPE(); // !!! -> UNIT_TYPE()
- case BOOL: return definitions.boolean_TYPE();
- // !!! case U1 : return ?;
- case U2 : return definitions.char_TYPE();
- // !!! case U4 : return ?;
- // !!! case U8 : return ?;
- case I1 : return definitions.byte_TYPE();
- case I2 : return definitions.short_TYPE();
- case I4 : return definitions.int_TYPE();
- case I8 : return definitions.long_TYPE();
- case R4 : return definitions.float_TYPE();
- case R8 : return definitions.double_TYPE();
- case REF : return definitions.ANYREF_TYPE();
- case STR : return definitions.STRING_TYPE();
- case NULL: return definitions.ALLREF_TYPE();
- case ZERO: return definitions.ALL_TYPE();
- default : throw Debug.abort("unknown case", kind);
- }
- }
-
- //########################################################################
- // Public Methods - Aliases for scala
-
- public Type[] computeType(ACode[] codes) {
- return type(codes);
- }
-
- public Type computeType(ACode code) {
- return type(code);
- }
-
- public Type computeType(ALocation location) {
- return type(location);
- }
-
- public Type computeType(AFunction function) {
- return type(function);
- }
-
- public Type computeType(APrimitive primitive) {
- return type(primitive);
- }
-
- public Type computeType(AConstant constant) {
- return type(constant);
- }
-
- public Type computeType(ATypeKind kind) {
- return type(kind);
- }
-
- //########################################################################
- // Private Methods
-
- /** Returns the application of given arguments to given type. */
- private Type apply(Type type, Type[] targs) {
- switch (type) {
- case PolyType(Symbol[] tparams, Type result):
- return result.subst(tparams, targs);
- default:
- assert targs.length == 0: type + " -- " + Debug.show(targs);
- return type;
- }
- }
-
- /** Returns the element type of the given array type. */
- public Type getArrayElementType(Type type) { // !!! public / private
- switch (type) {
- case TypeRef(_, Symbol symbol, Type[] args):
- assert symbol == definitions.ARRAY_CLASS && args.length == 1: type;
- return args[0];
- case UnboxedArrayType(Type element):
- return element;
- default:
- throw Debug.abort("non-array type", type);
- }
- }
-
- /** Returns a method type with given argument and result types. */
- private Type getMethodType(Type targ1, Type result) {
- return getMethodType(new Type[]{targ1}, result);
- }
-
- /** Returns a method type with given argument and result types. */
- private Type getMethodType(Type targ1, Type targ2, Type result) {
- return getMethodType(new Type[]{targ1, targ2}, result);
- }
-
- /** Returns a method type with given argument and result types. */
- private Type getMethodType(Type[] targs, Type result) {
- Symbol[] tparams = new Symbol[targs.length];
- for (int i = 0; i < tparams.length; i++) {
- Name name = Name.fromString("v" + i);
- tparams[i] = Symbol.NONE.newTerm( // !!! should be newVParam
- Position.NOPOS, Modifiers.PARAM, name);
- tparams[i].setType(targs[i]);
- }
- return Type.MethodType(tparams, result);
- }
-
- //########################################################################
-}
diff --git a/sources/scalac/atree/ATypeKind.java b/sources/scalac/atree/ATypeKind.java
deleted file mode 100644
index 1be2eb540d..0000000000
--- a/sources/scalac/atree/ATypeKind.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
-// $Id$
-
-package scalac.atree;
-
-import scalac.util.Debug;
-
-/** This class represents a type kind. */
-public class ATypeKind {
-
- //########################################################################
- // Public Cases
-
- /** The unit value */
- public case UNIT;
-
- /** A boolean value */
- public case BOOL;
-
- /** A 1-byte unsigned integer */
- public case U1;
-
- /** A 2-byte unsigned integer */
- public case U2;
-
- /** A 4-byte unsigned integer */
- public case U4;
-
- /** An 8-byte unsigned integer */
- public case U8;
-
- /** A 1-byte signed integer */
- public case I1;
-
- /** A 2-byte signed integer */
- public case I2;
-
- /** A 4-byte signed integer */
- public case I4;
-
- /** An 8-byte signed integer */
- public case I8;
-
- /** A 4-byte floating point number */
- public case R4;
-
- /** An 8-byte floating point number */
- public case R8;
-
- /** An object reference */
- public case REF;
-
- /** A string reference */
- public case STR;
-
- /** The null reference */
- public case NULL;
-
- /** The zero value */
- public case ZERO;
-
- //########################################################################
- // Public Methods
-
- /** Returns a string representation of this type kind. */
- public String toString() {
- switch (this) {
- case UNIT: return "UNIT";
- case BOOL: return "BOOL";
- case U1 : return "U1";
- case U2 : return "U2";
- case U4 : return "U4";
- case U8 : return "U8";
- case I1 : return "I1";
- case I2 : return "I2";
- case I4 : return "I4";
- case I8 : return "I8";
- case R4 : return "R4";
- case R8 : return "R8";
- case REF : return "REF";
- case STR : return "STR";
- case NULL: return "NULL";
- case ZERO: return "ZERO";
- default : throw Debug.abort("unknown case", this);
- }
- }
-
- //########################################################################
-}