diff options
-rw-r--r-- | sources/scala/Byte.java | 109 | ||||
-rw-r--r-- | sources/scala/Char.java | 136 | ||||
-rw-r--r-- | sources/scala/Double.java | 4 | ||||
-rw-r--r-- | sources/scala/Float.java | 4 | ||||
-rw-r--r-- | sources/scala/Int.java | 6 | ||||
-rw-r--r-- | sources/scala/Long.java | 6 | ||||
-rw-r--r-- | sources/scala/Short.java | 108 | ||||
-rw-r--r-- | test/files/run/arrays.scala | 20 | ||||
-rw-r--r-- | test/files/run/iq.scala | 6 |
9 files changed, 363 insertions, 36 deletions
diff --git a/sources/scala/Byte.java b/sources/scala/Byte.java index 1a7e7a3190..13dc8bd036 100644 --- a/sources/scala/Byte.java +++ b/sources/scala/Byte.java @@ -6,10 +6,115 @@ ** |/ ** \* */ -// $OldId: Byte.java,v 1.9 2002/04/15 16:21:39 paltherr Exp $ // $Id$ package scala; -public abstract class Byte extends Short { +public abstract class Byte extends AnyVal { + + /** @meta method []scala.Short ; */ + public short coerce() { return asShort (); } + /** @meta method []scala.Int ; */ + public int coerce() { return asInt (); } + /** @meta method []scala.Long ; */ + public long coerce() { return asLong (); } + /** @meta method []scala.Float ; */ + public float coerce() { return asFloat (); } + /** @meta method []scala.Double; */ + public double coerce() { return asDouble(); } + + public abstract double asDouble(); + public abstract float asFloat(); + public abstract long asLong(); + public abstract int asInt(); + public abstract char asChar(); + public abstract short asShort(); + public abstract byte asByte(); + + public boolean equals(java.lang.Object other) { + return other instanceof Byte && $eq$eq(((Byte )other).asByte ()); + } + public int hashCode() { + int bits = asByte (); + return bits; + } + public String toString() { + return String.valueOf(asByte ()); + } + + /** @meta method (scala.Any)scala.Boolean; */ + public boolean $eq$eq (java.lang.Object other) { return equals(other); } + /** @meta method (scala.Any)scala.Boolean; */ + public boolean $bang$eq(java.lang.Object other) { return !equals(other); } + + /** @meta method []scala.Int ; */ + public int $plus () { return +asInt () ; } + /** @meta method []scala.Int ; */ + public int $minus () { return -asInt () ; } + /** @meta method []scala.Int ; */ + public int $tilde () { return ~asInt () ; } + + public String $plus (String that) { return asInt () + that; } + + public double $plus (double that) { return asDouble() + that; } + public double $minus (double that) { return asDouble() - that; } + public double $times (double that) { return asDouble() * that; } + public double $div (double that) { return asDouble() / that; } + public double $percent (double that) { return asDouble() % that; } + public boolean $eq$eq (double that) { return asDouble() == that; } + public boolean $bang$eq (double that) { return asDouble() != that; } + public boolean $less (double that) { return asDouble() < that; } + public boolean $greater (double that) { return asDouble() > that; } + public boolean $less$eq (double that) { return asDouble() <= that; } + public boolean $greater$eq(double that) { return asDouble() >= that; } + + public float $plus (float that) { return asFloat () + that; } + public float $minus (float that) { return asFloat () - that; } + public float $times (float that) { return asFloat () * that; } + public float $div (float that) { return asFloat () / that; } + public float $percent (float that) { return asFloat () % that; } + public boolean $eq$eq (float that) { return asFloat () == that; } + public boolean $bang$eq (float that) { return asFloat () != that; } + public boolean $less (float that) { return asFloat () < that; } + public boolean $greater (float that) { return asFloat () > that; } + public boolean $less$eq (float that) { return asFloat () <= that; } + public boolean $greater$eq(float that) { return asFloat () >= that; } + + public int $less$less (int that) { return asInt () << that; } + public int $less$less (long that) { return asInt () << that; } + public int $greater$greater(int that) { return asInt () >> that; } + public int $greater$greater(long that) { return asInt () >> that; } + public int $greater$greater$greater(int that) { return asInt () >>>that; } + public int $greater$greater$greater(long that) { return asInt () >>>that; } + + public long $amp (long that) { return asLong () & that; } + public long $bar (long that) { return asLong () | that; } + public long $up (long that) { return asLong () ^ that; } + public long $plus (long that) { return asLong () + that; } + public long $minus (long that) { return asLong () - that; } + public long $times (long that) { return asLong () * that; } + public long $div (long that) { return asLong () / that; } + public long $percent (long that) { return asLong () % that; } + public boolean $eq$eq (long that) { return asLong () == that; } + public boolean $bang$eq (long that) { return asLong () != that; } + public boolean $less (long that) { return asLong () < that; } + public boolean $greater (long that) { return asLong () > that; } + public boolean $less$eq (long that) { return asLong () <= that; } + public boolean $greater$eq(long that) { return asLong () >= that; } + + public int $amp (int that) { return asInt () & that; } + public int $bar (int that) { return asInt () | that; } + public int $up (int that) { return asInt () ^ that; } + public int $plus (int that) { return asInt () + that; } + public int $minus (int that) { return asInt () - that; } + public int $times (int that) { return asInt () * that; } + public int $div (int that) { return asInt () / that; } + public int $percent (int that) { return asInt () % that; } + public boolean $eq$eq (int that) { return asInt () == that; } + public boolean $bang$eq (int that) { return asInt () != that; } + public boolean $less (int that) { return asInt () < that; } + public boolean $greater (int that) { return asInt () > that; } + public boolean $less$eq (int that) { return asInt () <= that; } + public boolean $greater$eq(int that) { return asInt () >= that; } + } diff --git a/sources/scala/Char.java b/sources/scala/Char.java index 74516ab3af..f28be85f8e 100644 --- a/sources/scala/Char.java +++ b/sources/scala/Char.java @@ -6,29 +6,135 @@ ** |/ ** \* */ -// $OldId: Char.java,v 1.11 2002/05/15 15:03:38 roeckl Exp $ // $Id$ package scala; +public abstract class Char extends AnyVal { -public abstract class Char extends Int { - public String toString() { return String.valueOf((char)asInt()); } - /** @meta method scala.Boolean; - */ - public boolean isDigit() { return Character.isDigit((char)asInt()); } + /** @meta method []scala.Int ; */ + public int coerce() { return asInt (); } + /** @meta method []scala.Long ; */ + public long coerce() { return asLong (); } + /** @meta method []scala.Float ; */ + public float coerce() { return asFloat (); } + /** @meta method []scala.Double; */ + public double coerce() { return asDouble(); } - /** @meta method scala.Boolean; - */ - public boolean isLetter() { return Character.isLetter((char)asInt()); } + public abstract double asDouble(); + public abstract float asFloat(); + public abstract long asLong(); + public abstract int asInt(); + public abstract char asChar(); + public abstract short asShort(); + public abstract byte asByte(); - /** @meta method scala.Boolean; - */ - public boolean isLetterOrDigit() { return Character.isLetterOrDigit((char)asInt()); } + public boolean equals(java.lang.Object other) { + return other instanceof Char && $eq$eq(((Char )other).asChar ()); + } + public int hashCode() { + int bits = asChar (); + return bits; + } + public String toString() { + return String.valueOf(asChar ()); + } + + /** @meta method (scala.Any)scala.Boolean; */ + public boolean $eq$eq (java.lang.Object other) { return equals(other); } + /** @meta method (scala.Any)scala.Boolean; */ + public boolean $bang$eq(java.lang.Object other) { return !equals(other); } + + /** @meta method []scala.Int ; */ + public int $plus () { return +asInt () ; } + /** @meta method []scala.Int ; */ + public int $minus () { return -asInt () ; } + /** @meta method []scala.Int ; */ + public int $tilde () { return ~asInt () ; } + + public String $plus (String that) { return asInt () + that; } + + public double $plus (double that) { return asDouble() + that; } + public double $minus (double that) { return asDouble() - that; } + public double $times (double that) { return asDouble() * that; } + public double $div (double that) { return asDouble() / that; } + public double $percent (double that) { return asDouble() % that; } + public boolean $eq$eq (double that) { return asDouble() == that; } + public boolean $bang$eq (double that) { return asDouble() != that; } + public boolean $less (double that) { return asDouble() < that; } + public boolean $greater (double that) { return asDouble() > that; } + public boolean $less$eq (double that) { return asDouble() <= that; } + public boolean $greater$eq(double that) { return asDouble() >= that; } + + public float $plus (float that) { return asFloat () + that; } + public float $minus (float that) { return asFloat () - that; } + public float $times (float that) { return asFloat () * that; } + public float $div (float that) { return asFloat () / that; } + public float $percent (float that) { return asFloat () % that; } + public boolean $eq$eq (float that) { return asFloat () == that; } + public boolean $bang$eq (float that) { return asFloat () != that; } + public boolean $less (float that) { return asFloat () < that; } + public boolean $greater (float that) { return asFloat () > that; } + public boolean $less$eq (float that) { return asFloat () <= that; } + public boolean $greater$eq(float that) { return asFloat () >= that; } + + public int $less$less (int that) { return asInt () << that; } + public int $less$less (long that) { return asInt () << that; } + public int $greater$greater(int that) { return asInt () >> that; } + public int $greater$greater(long that) { return asInt () >> that; } + public int $greater$greater$greater(int that) { return asInt () >>>that; } + public int $greater$greater$greater(long that) { return asInt () >>>that; } + + public long $amp (long that) { return asLong () & that; } + public long $bar (long that) { return asLong () | that; } + public long $up (long that) { return asLong () ^ that; } + public long $plus (long that) { return asLong () + that; } + public long $minus (long that) { return asLong () - that; } + public long $times (long that) { return asLong () * that; } + public long $div (long that) { return asLong () / that; } + public long $percent (long that) { return asLong () % that; } + public boolean $eq$eq (long that) { return asLong () == that; } + public boolean $bang$eq (long that) { return asLong () != that; } + public boolean $less (long that) { return asLong () < that; } + public boolean $greater (long that) { return asLong () > that; } + public boolean $less$eq (long that) { return asLong () <= that; } + public boolean $greater$eq(long that) { return asLong () >= that; } + + public int $amp (int that) { return asInt () & that; } + public int $bar (int that) { return asInt () | that; } + public int $up (int that) { return asInt () ^ that; } + public int $plus (int that) { return asInt () + that; } + public int $minus (int that) { return asInt () - that; } + public int $times (int that) { return asInt () * that; } + public int $div (int that) { return asInt () / that; } + public int $percent (int that) { return asInt () % that; } + public boolean $eq$eq (int that) { return asInt () == that; } + public boolean $bang$eq (int that) { return asInt () != that; } + public boolean $less (int that) { return asInt () < that; } + public boolean $greater (int that) { return asInt () > that; } + public boolean $less$eq (int that) { return asInt () <= that; } + public boolean $greater$eq(int that) { return asInt () >= that; } + + /** @meta method scala.Boolean; */ + public boolean isDigit() { + return Character.isDigit((char)asChar()); + } + + /** @meta method scala.Boolean; */ + public boolean isLetter() { + return Character.isLetter((char)asChar()); + } + + /** @meta method scala.Boolean; */ + public boolean isLetterOrDigit() { + return Character.isLetterOrDigit((char)asChar()); + } + + /** @meta method scala.Boolean; */ + public boolean isWhitespace() { + return Character.isWhitespace((char)asChar()); + } - /** @meta method scala.Boolean; - */ - public boolean isWhitespace() { return Character.isWhitespace((char)asInt()); } } diff --git a/sources/scala/Double.java b/sources/scala/Double.java index 727dfabf40..3a990e4970 100644 --- a/sources/scala/Double.java +++ b/sources/scala/Double.java @@ -19,6 +19,10 @@ public abstract class Double extends AnyVal { + + + + public abstract double asDouble(); public abstract float asFloat(); public abstract long asLong(); diff --git a/sources/scala/Float.java b/sources/scala/Float.java index 1633755d25..fae1b06130 100644 --- a/sources/scala/Float.java +++ b/sources/scala/Float.java @@ -16,6 +16,10 @@ public abstract class Float extends AnyVal { + + + + /** @meta method []scala.Double; */ public double coerce() { return asDouble(); } diff --git a/sources/scala/Int.java b/sources/scala/Int.java index 2ee3adaf2c..c77d818464 100644 --- a/sources/scala/Int.java +++ b/sources/scala/Int.java @@ -12,6 +12,10 @@ package scala; public abstract class Int extends AnyVal { + + + + /** @meta method []scala.Long ; */ public long coerce() { return asLong (); } /** @meta method []scala.Float ; */ @@ -31,7 +35,7 @@ public abstract class Int extends AnyVal { return other instanceof Int && $eq$eq(((Int )other).asInt ()); } public int hashCode() { - int bits = asInt (); + int bits = asInt (); return bits; } public String toString() { diff --git a/sources/scala/Long.java b/sources/scala/Long.java index 8fb5518b56..a4ab6302a3 100644 --- a/sources/scala/Long.java +++ b/sources/scala/Long.java @@ -14,6 +14,10 @@ public abstract class Long extends AnyVal { + + + + /** @meta method []scala.Float ; */ public float coerce() { return asFloat (); } /** @meta method []scala.Double; */ @@ -31,7 +35,7 @@ public abstract class Long extends AnyVal { return other instanceof Long && $eq$eq(((Long )other).asLong ()); } public int hashCode() { - long bits = asLong(); + long bits = asLong (); return (int)(bits ^ (bits >>> 32)); } public String toString() { diff --git a/sources/scala/Short.java b/sources/scala/Short.java index 24d019eb77..4f69ddbaa5 100644 --- a/sources/scala/Short.java +++ b/sources/scala/Short.java @@ -6,11 +6,115 @@ ** |/ ** \* */ -// $OldId: Short.java,v 1.9 2002/04/15 16:21:39 paltherr Exp $ // $Id$ package scala; +public abstract class Short extends AnyVal { + + + + /** @meta method []scala.Int ; */ + public int coerce() { return asInt (); } + /** @meta method []scala.Long ; */ + public long coerce() { return asLong (); } + /** @meta method []scala.Float ; */ + public float coerce() { return asFloat (); } + /** @meta method []scala.Double; */ + public double coerce() { return asDouble(); } + + public abstract double asDouble(); + public abstract float asFloat(); + public abstract long asLong(); + public abstract int asInt(); + public abstract char asChar(); + public abstract short asShort(); + public abstract byte asByte(); + + public boolean equals(java.lang.Object other) { + return other instanceof Short && $eq$eq(((Short )other).asShort ()); + } + public int hashCode() { + int bits = asShort (); + return bits; + } + public String toString() { + return String.valueOf(asShort ()); + } + + /** @meta method (scala.Any)scala.Boolean; */ + public boolean $eq$eq (java.lang.Object other) { return equals(other); } + /** @meta method (scala.Any)scala.Boolean; */ + public boolean $bang$eq(java.lang.Object other) { return !equals(other); } + + /** @meta method []scala.Int ; */ + public int $plus () { return +asInt () ; } + /** @meta method []scala.Int ; */ + public int $minus () { return -asInt () ; } + /** @meta method []scala.Int ; */ + public int $tilde () { return ~asInt () ; } + + public String $plus (String that) { return asInt () + that; } + + public double $plus (double that) { return asDouble() + that; } + public double $minus (double that) { return asDouble() - that; } + public double $times (double that) { return asDouble() * that; } + public double $div (double that) { return asDouble() / that; } + public double $percent (double that) { return asDouble() % that; } + public boolean $eq$eq (double that) { return asDouble() == that; } + public boolean $bang$eq (double that) { return asDouble() != that; } + public boolean $less (double that) { return asDouble() < that; } + public boolean $greater (double that) { return asDouble() > that; } + public boolean $less$eq (double that) { return asDouble() <= that; } + public boolean $greater$eq(double that) { return asDouble() >= that; } + + public float $plus (float that) { return asFloat () + that; } + public float $minus (float that) { return asFloat () - that; } + public float $times (float that) { return asFloat () * that; } + public float $div (float that) { return asFloat () / that; } + public float $percent (float that) { return asFloat () % that; } + public boolean $eq$eq (float that) { return asFloat () == that; } + public boolean $bang$eq (float that) { return asFloat () != that; } + public boolean $less (float that) { return asFloat () < that; } + public boolean $greater (float that) { return asFloat () > that; } + public boolean $less$eq (float that) { return asFloat () <= that; } + public boolean $greater$eq(float that) { return asFloat () >= that; } + + public int $less$less (int that) { return asInt () << that; } + public int $less$less (long that) { return asInt () << that; } + public int $greater$greater(int that) { return asInt () >> that; } + public int $greater$greater(long that) { return asInt () >> that; } + public int $greater$greater$greater(int that) { return asInt () >>>that; } + public int $greater$greater$greater(long that) { return asInt () >>>that; } + + public long $amp (long that) { return asLong () & that; } + public long $bar (long that) { return asLong () | that; } + public long $up (long that) { return asLong () ^ that; } + public long $plus (long that) { return asLong () + that; } + public long $minus (long that) { return asLong () - that; } + public long $times (long that) { return asLong () * that; } + public long $div (long that) { return asLong () / that; } + public long $percent (long that) { return asLong () % that; } + public boolean $eq$eq (long that) { return asLong () == that; } + public boolean $bang$eq (long that) { return asLong () != that; } + public boolean $less (long that) { return asLong () < that; } + public boolean $greater (long that) { return asLong () > that; } + public boolean $less$eq (long that) { return asLong () <= that; } + public boolean $greater$eq(long that) { return asLong () >= that; } + + public int $amp (int that) { return asInt () & that; } + public int $bar (int that) { return asInt () | that; } + public int $up (int that) { return asInt () ^ that; } + public int $plus (int that) { return asInt () + that; } + public int $minus (int that) { return asInt () - that; } + public int $times (int that) { return asInt () * that; } + public int $div (int that) { return asInt () / that; } + public int $percent (int that) { return asInt () % that; } + public boolean $eq$eq (int that) { return asInt () == that; } + public boolean $bang$eq (int that) { return asInt () != that; } + public boolean $less (int that) { return asInt () < that; } + public boolean $greater (int that) { return asInt () > that; } + public boolean $less$eq (int that) { return asInt () <= that; } + public boolean $greater$eq(int that) { return asInt () >= that; } -public abstract class Short extends Int { } diff --git a/test/files/run/arrays.scala b/test/files/run/arrays.scala index 048e067b2b..02add14a46 100644 --- a/test/files/run/arrays.scala +++ b/test/files/run/arrays.scala @@ -74,9 +74,9 @@ object arrays { System.out.println(); check("zarray(0)", zarray(0), false); - check("barray(0)", barray(0), 0); - check("sarray(0)", sarray(0), 0); - check("carray(0)", carray(0), 0); + check("barray(0)", barray(0), 0: byte); + check("sarray(0)", sarray(0), 0: short); + check("carray(0)", carray(0), '\u0000'); check("iarray(0)", iarray(0), 0); check("larray(0)", larray(0), 0l); check("farray(0)", farray(0), 0f); @@ -85,9 +85,9 @@ object arrays { System.out.println(); check("zarray(1)", zarray(1), false); - check("barray(1)", barray(1), 0); - check("sarray(1)", sarray(1), 0); - check("carray(1)", carray(1), 0); + check("barray(1)", barray(1), 0: byte); + check("sarray(1)", sarray(1), 0: short); + check("carray(1)", carray(1), '\u0000'); check("iarray(1)", iarray(1), 0); check("larray(1)", larray(1), 0l); check("farray(1)", farray(1), 0f); @@ -116,8 +116,8 @@ object arrays { rarray(1) ="9"; check("zarray(0)", zarray(0), false); - check("barray(0)", barray(0), 1); - check("sarray(0)", sarray(0), 2); + check("barray(0)", barray(0), 1: byte); + check("sarray(0)", sarray(0), 2: short); check("carray(0)", carray(0),'3'); check("iarray(0)", iarray(0), 4); check("larray(0)", larray(0), 5l); @@ -127,8 +127,8 @@ object arrays { System.out.println(); check("zarray(1)", zarray(1), true); - check("barray(1)", barray(1), 2); - check("sarray(1)", sarray(1), 3); + check("barray(1)", barray(1), 2: byte); + check("sarray(1)", sarray(1), 3: short); check("carray(1)", carray(1),'4'); check("iarray(1)", iarray(1), 5); check("larray(1)", larray(1), 6l); diff --git a/test/files/run/iq.scala b/test/files/run/iq.scala index a02a79a53b..dd0ce3f3d2 100644 --- a/test/files/run/iq.scala +++ b/test/files/run/iq.scala @@ -45,11 +45,7 @@ object iq { - val q5c:Queue[char] = Queue.Empty.enqueue(0: char, 1: char, - 2: char, 3: char, - 4: char, 5: char, - 6: char, 7: char, - 8: char, 9: char); + val q5c:Queue[int] = Queue.Empty.enqueue(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); /* Testing == * Expected: q5 == q9: true |