summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-10-21 07:25:55 +0000
committerpaltherr <paltherr@epfl.ch>2003-10-21 07:25:55 +0000
commitbbea46f3c364504e5a647cb13a66d76038ed4c88 (patch)
tree52d78410f93e1e9a5960e2d3abf4773c753cac1b /sources
parentafc36c22f41a120fb0bf3738e572cbe2dd9ce69a (diff)
downloadscala-bbea46f3c364504e5a647cb13a66d76038ed4c88.tar.gz
scala-bbea46f3c364504e5a647cb13a66d76038ed4c88.tar.bz2
scala-bbea46f3c364504e5a647cb13a66d76038ed4c88.zip
- Removed range checks from asX methods
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/runtime/RunTime.java204
1 files changed, 22 insertions, 182 deletions
diff --git a/sources/scala/runtime/RunTime.java b/sources/scala/runtime/RunTime.java
index d9f02392d3..467f178c49 100644
--- a/sources/scala/runtime/RunTime.java
+++ b/sources/scala/runtime/RunTime.java
@@ -109,24 +109,9 @@ public abstract class RunTime {
public float asFloat() { return (float)x; }
public long asLong() { return (long)x; }
public int asInt() { return (int)x; }
- public char asChar() {
- if (isChar()) return (char)x;
- else throw new ClassCastException();
- }
+ public char asChar() { return (char)x; }
public short asShort() { return (short)x; }
- public byte asByte() {
- if (isByte()) return (byte)x;
- else throw new ClassCastException();
- }
-
- public boolean isChar() {
- return (java.lang.Character.MIN_VALUE <= x)
- && (java.lang.Character.MAX_VALUE >= x);
- }
- public boolean isByte() {
- return (java.lang.Byte.MIN_VALUE <= x)
- && (java.lang.Byte.MAX_VALUE >= x);
- }
+ public byte asByte() { return (byte)x; }
};
}
@@ -142,23 +127,8 @@ public abstract class RunTime {
public long asLong() { return (long)x; }
public int asInt() { return (int)x; }
public char asChar() { return (char)x; }
- public short asShort() {
- if (isShort()) return (short)x;
- else throw new ClassCastException();
- }
- public byte asByte() {
- if (isByte()) return (byte)x;
- else throw new ClassCastException();
- }
-
- public boolean isShort() {
- return (java.lang.Short.MIN_VALUE <= x)
- && (java.lang.Short.MAX_VALUE >= x);
- }
- public boolean isByte() {
- return (java.lang.Byte.MIN_VALUE <= x)
- && (java.lang.Byte.MAX_VALUE >= x);
- }
+ public short asShort() { return (short)x; }
+ public byte asByte() { return (byte)x; }
};
}
@@ -173,31 +143,9 @@ public abstract class RunTime {
public float asFloat() { return (float)x; }
public long asLong() { return (long)x; }
public int asInt() { return (int)x; }
- public char asChar() {
- if (isChar()) return (char)x;
- else throw new ClassCastException();
- }
- public short asShort() {
- if (isShort()) return (short)x;
- else throw new ClassCastException();
- }
- public byte asByte() {
- if (isByte()) return (byte)x;
- else throw new ClassCastException();
- }
-
- public boolean isChar() {
- return (java.lang.Character.MIN_VALUE <= x)
- && (java.lang.Character.MAX_VALUE >= x);
- }
- public boolean isShort() {
- return (java.lang.Short.MIN_VALUE <= x)
- && (java.lang.Short.MAX_VALUE >= x);
- }
- public boolean isByte() {
- return (java.lang.Byte.MIN_VALUE <= x)
- && (java.lang.Byte.MAX_VALUE >= x);
- }
+ public char asChar() { return (char)x; }
+ public short asShort() { return (short)x; }
+ public byte asByte() { return (byte)x; }
};
}
@@ -211,39 +159,10 @@ public abstract class RunTime {
public double asDouble() { return (double)x; }
public float asFloat() { return (float)x; }
public long asLong() { return (long)x; }
- public int asInt() {
- if (isInt()) return (int)x;
- else throw new ClassCastException();
- }
- public char asChar() {
- if (isChar()) return (char)x;
- else throw new ClassCastException();
- }
- public short asShort() {
- if (isShort()) return (short)x;
- else throw new ClassCastException();
- }
- public byte asByte() {
- if (isByte()) return (byte)x;
- else throw new ClassCastException();
- }
-
- public boolean isInt() {
- return (java.lang.Integer.MIN_VALUE <= x)
- && (java.lang.Integer.MAX_VALUE >= x);
- }
- public boolean isChar() {
- return (java.lang.Character.MIN_VALUE <= x)
- && (java.lang.Character.MAX_VALUE >= x);
- }
- public boolean isShort() {
- return (java.lang.Short.MIN_VALUE <= x)
- && (java.lang.Short.MAX_VALUE >= x);
- }
- public boolean isByte() {
- return (java.lang.Byte.MIN_VALUE <= x)
- && (java.lang.Byte.MAX_VALUE >= x);
- }
+ public int asInt() { return (int)x; }
+ public char asChar() { return (char)x; }
+ public short asShort() { return (short)x; }
+ public byte asByte() { return (byte)x; }
};
}
@@ -251,102 +170,23 @@ public abstract class RunTime {
return new Float() {
public double asDouble() { return (double)x; }
public float asFloat() { return (float)x; }
- public long asLong() {
- if (isLong()) return (long)x;
- else throw new ClassCastException();
- }
- public int asInt() {
- if (isInt()) return (int)x;
- else throw new ClassCastException();
- }
- public char asChar() {
- if (isChar()) return (char)x;
- else throw new ClassCastException();
- }
- public short asShort() {
- if (isShort()) return (short)x;
- else throw new ClassCastException();
- }
- public byte asByte() {
- if (isByte()) return (byte)x;
- else throw new ClassCastException();
- }
-
- public boolean isLong() {
- return (java.lang.Long.MIN_VALUE <= x)
- && (java.lang.Long.MAX_VALUE >= x);
- }
- public boolean isInt() {
- return (java.lang.Integer.MIN_VALUE <= x)
- && (java.lang.Integer.MAX_VALUE >= x);
- }
- public boolean isChar() {
- return (java.lang.Character.MIN_VALUE <= x)
- && (java.lang.Character.MAX_VALUE >= x);
- }
- public boolean isShort() {
- return (java.lang.Short.MIN_VALUE <= x)
- && (java.lang.Short.MAX_VALUE >= x);
- }
- public boolean isByte() {
- return (java.lang.Byte.MIN_VALUE <= x)
- && (java.lang.Byte.MAX_VALUE >= x);
- }
+ public long asLong() { return (long)x; }
+ public int asInt() { return (int)x; }
+ public char asChar() { return (char)x; }
+ public short asShort() { return (short)x; }
+ public byte asByte() { return (byte)x; }
};
}
public static Double box(final double x) {
return new Double() {
public double asDouble() { return (double)x; }
- public float asFloat() {
- if (isFloat()) return (float)x;
- else throw new ClassCastException();
- }
- public long asLong() {
- if (isLong()) return (long)x;
- else throw new ClassCastException();
- }
- public int asInt() {
- if (isInt()) return (int)x;
- else throw new ClassCastException();
- }
- public char asChar() {
- if (isChar()) return (char)x;
- else throw new ClassCastException();
- }
- public short asShort() {
- if (isShort()) return (short)x;
- else throw new ClassCastException();
- }
- public byte asByte() {
- if (isByte()) return (byte)x;
- else throw new ClassCastException();
- }
-
- public boolean isFloat() {
- return (java.lang.Float.MIN_VALUE <= x)
- && (java.lang.Float.MAX_VALUE >= x);
- }
- public boolean isLong() {
- return (java.lang.Long.MIN_VALUE <= x)
- && (java.lang.Long.MAX_VALUE >= x);
- }
- public boolean isInt() {
- return (java.lang.Integer.MIN_VALUE <= x)
- && (java.lang.Integer.MAX_VALUE >= x);
- }
- public boolean isChar() {
- return (java.lang.Character.MIN_VALUE <= x)
- && (java.lang.Character.MAX_VALUE >= x);
- }
- public boolean isShort() {
- return (java.lang.Short.MIN_VALUE <= x)
- && (java.lang.Short.MAX_VALUE >= x);
- }
- public boolean isByte() {
- return (java.lang.Byte.MIN_VALUE <= x)
- && (java.lang.Byte.MAX_VALUE >= x);
- }
+ public float asFloat() { return (float)x; }
+ public long asLong() { return (long)x; }
+ public int asInt() { return (int)x; }
+ public char asChar() { return (char)x; }
+ public short asShort() { return (short)x; }
+ public byte asByte() { return (byte)x; }
};
}