diff options
-rw-r--r-- | sources/scala/runtime/types/TypeBoolean.java | 9 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeByte.java | 9 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeChar.java | 9 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeDouble.java | 9 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeFloat.java | 9 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeInt.java | 9 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeLong.java | 9 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeShort.java | 9 |
8 files changed, 64 insertions, 8 deletions
diff --git a/sources/scala/runtime/types/TypeBoolean.java b/sources/scala/runtime/types/TypeBoolean.java index 743a00d648..3d938040ad 100644 --- a/sources/scala/runtime/types/TypeBoolean.java +++ b/sources/scala/runtime/types/TypeBoolean.java @@ -15,10 +15,17 @@ import scala.Type; import scala.Array; import scala.Boolean; -public class TypeBoolean extends BasicType { +public class TypeBoolean extends ValueType { private final Boolean ZERO = RunTime.box_zvalue(false); public Array newArray(int size) { return RunTime.box_zarray(new boolean[size]); } + public Object checkCastability(Object o) { + if (! (o == null || o instanceof scala.Boolean)) + throw new ClassCastException(); // TODO error message + return o; + } public Object defaultValue() { return ZERO; } + public String toString() { return "scala.Boolean"; } + public int hashCode() { return 0x88888888; } }; diff --git a/sources/scala/runtime/types/TypeByte.java b/sources/scala/runtime/types/TypeByte.java index 68723ce0af..a3941d771d 100644 --- a/sources/scala/runtime/types/TypeByte.java +++ b/sources/scala/runtime/types/TypeByte.java @@ -15,10 +15,17 @@ import scala.Type; import scala.Array; import scala.Byte; -public class TypeByte extends BasicType { +public class TypeByte extends ValueType { private final Byte ZERO = RunTime.box_bvalue((byte)0); public Array newArray(int size) { return RunTime.box_barray(new byte[size]); } + public Object checkCastability(Object o) { + if (! (o == null || o instanceof scala.Byte)) + throw new ClassCastException(); // TODO error message + return o; + } public Object defaultValue() { return ZERO; } + public String toString() { return "scala.Byte"; } + public int hashCode() { return 0x77777777; } }; diff --git a/sources/scala/runtime/types/TypeChar.java b/sources/scala/runtime/types/TypeChar.java index 1bafbcb232..c4436aeedc 100644 --- a/sources/scala/runtime/types/TypeChar.java +++ b/sources/scala/runtime/types/TypeChar.java @@ -15,10 +15,17 @@ import scala.Type; import scala.Array; import scala.Char; -public class TypeChar extends BasicType { +public class TypeChar extends ValueType { private final Char ZERO = RunTime.box_cvalue((char)0); public Array newArray(int size) { return RunTime.box_carray(new char[size]); } + public Object checkCastability(Object o) { + if (! (o == null || o instanceof scala.Char)) + throw new ClassCastException(); // TODO error message + return o; + } public Object defaultValue() { return ZERO; } + public String toString() { return "scala.Char"; } + public int hashCode() { return 0x66666666; } }; diff --git a/sources/scala/runtime/types/TypeDouble.java b/sources/scala/runtime/types/TypeDouble.java index cb82677a76..67ba67994a 100644 --- a/sources/scala/runtime/types/TypeDouble.java +++ b/sources/scala/runtime/types/TypeDouble.java @@ -14,11 +14,18 @@ import scala.runtime.RunTime; import scala.Type; import scala.Array; -public public class TypeDouble extends BasicType { +public public class TypeDouble extends ValueType { private final scala.Double ZERO = RunTime.box_dvalue(0.0); public Array newArray(int size) { return RunTime.box_darray(new double[size]); } + public Object checkCastability(Object o) { + if (! (o == null || o instanceof scala.Double)) + throw new ClassCastException(); // TODO error message + return o; + } public Object defaultValue() { return ZERO; } + public String toString() { return "scala.Double"; } + public int hashCode() { return 0x11111111; } }; diff --git a/sources/scala/runtime/types/TypeFloat.java b/sources/scala/runtime/types/TypeFloat.java index 426e577229..570cc2df43 100644 --- a/sources/scala/runtime/types/TypeFloat.java +++ b/sources/scala/runtime/types/TypeFloat.java @@ -14,11 +14,18 @@ import scala.runtime.RunTime; import scala.Type; import scala.Array; -public class TypeFloat extends BasicType { +public class TypeFloat extends ValueType { private final scala.Float ZERO = RunTime.box_fvalue(0.0f); public Array newArray(int size) { return RunTime.box_farray(new float[size]); } + public Object checkCastability(Object o) { + if (! (o == null || o instanceof scala.Float)) + throw new ClassCastException(); // TODO error message + return o; + } public Object defaultValue() { return ZERO; } + public String toString() { return "scala.Float"; } + public int hashCode() { return 0x22222222; } }; diff --git a/sources/scala/runtime/types/TypeInt.java b/sources/scala/runtime/types/TypeInt.java index 602ba8bafd..84f042eab3 100644 --- a/sources/scala/runtime/types/TypeInt.java +++ b/sources/scala/runtime/types/TypeInt.java @@ -15,10 +15,17 @@ import scala.Type; import scala.Array; import scala.Int; -public class TypeInt extends BasicType { +public class TypeInt extends ValueType { private final Int ZERO = RunTime.box_ivalue(0); public Array newArray(int size) { return RunTime.box_iarray(new int[size]); } + public Object checkCastability(Object o) { + if (! (o == null || o instanceof scala.Int)) + throw new ClassCastException(); // TODO error message + return o; + } public Object defaultValue() { return ZERO; } + public String toString() { return "scala.Int"; } + public int hashCode() { return 0x44444444; } }; diff --git a/sources/scala/runtime/types/TypeLong.java b/sources/scala/runtime/types/TypeLong.java index dbc2c8d980..33ec7bb6ff 100644 --- a/sources/scala/runtime/types/TypeLong.java +++ b/sources/scala/runtime/types/TypeLong.java @@ -14,10 +14,17 @@ import scala.runtime.RunTime; import scala.Type; import scala.Array; -public class TypeLong extends BasicType { +public class TypeLong extends ValueType { private final scala.Long ZERO = RunTime.box_lvalue(0l); public Array newArray(int size) { return RunTime.box_larray(new long[size]); } + public Object checkCastability(Object o) { + if (! (o == null || o instanceof scala.Long)) + throw new ClassCastException(); // TODO error message + return o; + } public Object defaultValue() { return ZERO; } + public String toString() { return "scala.Long"; } + public int hashCode() { return 0x33333333; } }; diff --git a/sources/scala/runtime/types/TypeShort.java b/sources/scala/runtime/types/TypeShort.java index 7f0df98b75..a28c24b0eb 100644 --- a/sources/scala/runtime/types/TypeShort.java +++ b/sources/scala/runtime/types/TypeShort.java @@ -14,10 +14,17 @@ import scala.runtime.RunTime; import scala.Type; import scala.Array; -public class TypeShort extends BasicType { +public class TypeShort extends ValueType { private final scala.Short ZERO = RunTime.box_svalue((short)0); public Array newArray(int size) { return RunTime.box_sarray(new short[size]); } + public Object checkCastability(Object o) { + if (! (o == null || o instanceof scala.Short)) + throw new ClassCastException(); // TODO error message + return o; + } public Object defaultValue() { return ZERO; } + public String toString() { return "scala.Short"; } + public int hashCode() { return 0x55555555; } }; |