summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-12-04 12:53:15 +0000
committerpaltherr <paltherr@epfl.ch>2003-12-04 12:53:15 +0000
commit7a4b5c10726f1bcc1851252b03d7c362ee51a210 (patch)
tree9d9ba576cdbe128c6b32ef8beb2ff85dc45b55dc /sources
parent1e1222b7079aaa154cf22f5952b6e2f97df89f39 (diff)
downloadscala-7a4b5c10726f1bcc1851252b03d7c362ee51a210.tar.gz
scala-7a4b5c10726f1bcc1851252b03d7c362ee51a210.tar.bz2
scala-7a4b5c10726f1bcc1851252b03d7c362ee51a210.zip
- Changed name of unbox primitives
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/runtime/RunTime.java38
-rw-r--r--sources/scalac/backend/Primitive.java2
-rw-r--r--sources/scalac/backend/Primitives.java78
3 files changed, 60 insertions, 58 deletions
diff --git a/sources/scala/runtime/RunTime.java b/sources/scala/runtime/RunTime.java
index 855883b815..8207653827 100644
--- a/sources/scala/runtime/RunTime.java
+++ b/sources/scala/runtime/RunTime.java
@@ -181,54 +181,54 @@ public abstract class RunTime {
//########################################################################
// Public Functions - Unboxing primitives
- public static void unbox(Unit x) { x.asUnit (); }
- public static boolean unbox(Boolean x) { return x.asBoolean(); }
- public static byte unbox(Byte x) { return x.asByte (); }
- public static short unbox(Short x) { return x.asShort (); }
- public static char unbox(Char x) { return x.asChar (); }
- public static int unbox(Int x) { return x.asInt (); }
- public static long unbox(Long x) { return x.asLong (); }
- public static float unbox(Float x) { return x.asFloat (); }
- public static double unbox(Double x) { return x.asDouble (); }
+ public static void unbox_uvalue(Unit x) { x.asUnit (); }
+ public static boolean unbox_zvalue(Boolean x) { return x.asBoolean(); }
+ public static byte unbox_bvalue(Byte x) { return x.asByte (); }
+ public static short unbox_svalue(Short x) { return x.asShort (); }
+ public static char unbox_cvalue(Char x) { return x.asChar (); }
+ public static int unbox_ivalue(Int x) { return x.asInt (); }
+ public static long unbox_lvalue(Long x) { return x.asLong (); }
+ public static float unbox_fvalue(Float x) { return x.asFloat (); }
+ public static double unbox_dvalue(Double x) { return x.asDouble (); }
/** @meta method (scala.Array[scala.Boolean]) scala.Array[scala.Boolean];*/
- public static boolean[] unbox(Array xs) {
+ public static boolean[] unbox_zarray(Array xs) {
return xs == null ? null : xs.asBooleanArray();
}
/** @meta method (scala.Array[scala.Byte]) scala.Array[scala.Byte]; */
- public static byte [] unbox(Array xs) {
+ public static byte [] unbox_barray(Array xs) {
return xs == null ? null : xs.asByteArray ();
}
/** @meta method (scala.Array[scala.Short]) scala.Array[scala.Short]; */
- public static short [] unbox(Array xs) {
+ public static short [] unbox_sarray(Array xs) {
return xs == null ? null : xs.asShortArray ();
}
/** @meta method (scala.Array[scala.Char]) scala.Array[scala.Char]; */
- public static char [] unbox(Array xs) {
+ public static char [] unbox_carray(Array xs) {
return xs == null ? null : xs.asCharArray ();
}
/** @meta method (scala.Array[scala.Int]) scala.Array[scala.Int]; */
- public static int [] unbox(Array xs) {
+ public static int [] unbox_iarray(Array xs) {
return xs == null ? null : xs.asIntArray ();
}
/** @meta method (scala.Array[scala.Long]) scala.Array[scala.Long]; */
- public static long [] unbox(Array xs) {
+ public static long [] unbox_larray(Array xs) {
return xs == null ? null : xs.asLongArray ();
}
/** @meta method (scala.Array[scala.Float]) scala.Array[scala.Float]; */
- public static float [] unbox(Array xs) {
+ public static float [] unbox_farray(Array xs) {
return xs == null ? null : xs.asFloatArray ();
}
/** @meta method (scala.Array[scala.Double]) scala.Array[scala.Double]; */
- public static double [] unbox(Array xs) {
+ public static double [] unbox_darray(Array xs) {
return xs == null ? null : xs.asDoubleArray ();
}
/** @meta method [?T < scala.AnyRef](scala.Array[?T]) scala.Array[?T]; */
- public static Object [] unbox(Array xs) {
+ public static Object [] unbox_oarray(Array xs) {
return xs == null ? null : xs.asObjectArray ();
}
/** @meta method [?T](scala.Array[?T]) scala.Array[?T]; */
- public static Object unbox(Array xs) {
+ public static Object unbox__array(Array xs) {
return xs == null ? null : xs.asArray ();
}
diff --git a/sources/scalac/backend/Primitive.java b/sources/scalac/backend/Primitive.java
index 3eb9b07dcf..68debab73d 100644
--- a/sources/scalac/backend/Primitive.java
+++ b/sources/scalac/backend/Primitive.java
@@ -103,7 +103,7 @@ public class Primitive {
// RunTime operations
public case BOX { tag = 52; } // RunTime.box(x)
- public case UNBOX { tag = 53; } // RunTime.unbox(x)
+ public case UNBOX { tag = 53; } // RunTime.<X>_unbox(x)
public case NEW_ZARRAY { tag = 54; } // RunTime.zarray(x)
public case NEW_BARRAY { tag = 55; } // RunTime.barray(x)
public case NEW_SARRAY { tag = 56; } // RunTime.sarray(x)
diff --git a/sources/scalac/backend/Primitives.java b/sources/scalac/backend/Primitives.java
index 37a28b7ec2..77224d4ffa 100644
--- a/sources/scalac/backend/Primitives.java
+++ b/sources/scalac/backend/Primitives.java
@@ -76,7 +76,27 @@ public class Primitives {
private static final Name OARRAY_SET_N = Name.fromString("oarray_set");
private static final Name BOX_N = Name.fromString("box");
- private static final Name UNBOX_N = Name.fromString("unbox");
+
+ private static final Name UNBOX_UVALUE_N = Name.fromString("unbox_uvalue");
+ private static final Name UNBOX_ZVALUE_N = Name.fromString("unbox_zvalue");
+ private static final Name UNBOX_BVALUE_N = Name.fromString("unbox_bvalue");
+ private static final Name UNBOX_SVALUE_N = Name.fromString("unbox_svalue");
+ private static final Name UNBOX_CVALUE_N = Name.fromString("unbox_cvalue");
+ private static final Name UNBOX_IVALUE_N = Name.fromString("unbox_ivalue");
+ private static final Name UNBOX_LVALUE_N = Name.fromString("unbox_lvalue");
+ private static final Name UNBOX_FVALUE_N = Name.fromString("unbox_fvalue");
+ private static final Name UNBOX_DVALUE_N = Name.fromString("unbox_dvalue");
+
+ private static final Name UNBOX_ZARRAY_N = Name.fromString("unbox_zarray");
+ private static final Name UNBOX_BARRAY_N = Name.fromString("unbox_barray");
+ private static final Name UNBOX_SARRAY_N = Name.fromString("unbox_sarray");
+ private static final Name UNBOX_CARRAY_N = Name.fromString("unbox_carray");
+ private static final Name UNBOX_IARRAY_N = Name.fromString("unbox_iarray");
+ private static final Name UNBOX_LARRAY_N = Name.fromString("unbox_larray");
+ private static final Name UNBOX_FARRAY_N = Name.fromString("unbox_farray");
+ private static final Name UNBOX_DARRAY_N = Name.fromString("unbox_darray");
+ private static final Name UNBOX_OARRAY_N = Name.fromString("unbox_oarray");
+ private static final Name UNBOX__ARRAY_N = Name.fromString("unbox__array");
private static final Name AS_UVALUE_N = Name.fromString("asUnit");
private static final Name AS_ZVALUE_N = Name.fromString("asBoolean");
@@ -375,26 +395,25 @@ public class Primitives {
this.BOX_DARRAY = getBoxArray(boxes, definitions.DOUBLE_TYPE());
this.BOX_OARRAY = getBoxArray(boxes, definitions.JAVA_OBJECT_TYPE());
this.BOX__ARRAY = getBoxArray(boxes, definitions.ANY_TYPE());
- Symbol[] unboxes = getTerm(RUNTIME, UNBOX_N).alternativeSymbols();
- this.UNBOX_UVALUE = getUnboxValue(unboxes, definitions.UNIT_TYPE());
- this.UNBOX_ZVALUE = getUnboxValue(unboxes, definitions.BOOLEAN_TYPE());
- this.UNBOX_BVALUE = getUnboxValue(unboxes, definitions.BYTE_TYPE());
- this.UNBOX_SVALUE = getUnboxValue(unboxes, definitions.SHORT_TYPE());
- this.UNBOX_CVALUE = getUnboxValue(unboxes, definitions.CHAR_TYPE());
- this.UNBOX_IVALUE = getUnboxValue(unboxes, definitions.INT_TYPE());
- this.UNBOX_LVALUE = getUnboxValue(unboxes, definitions.LONG_TYPE());
- this.UNBOX_FVALUE = getUnboxValue(unboxes, definitions.FLOAT_TYPE());
- this.UNBOX_DVALUE = getUnboxValue(unboxes, definitions.DOUBLE_TYPE());
- this.UNBOX_ZARRAY = getUnboxArray(unboxes, definitions.BOOLEAN_TYPE());
- this.UNBOX_BARRAY = getUnboxArray(unboxes, definitions.BYTE_TYPE());
- this.UNBOX_SARRAY = getUnboxArray(unboxes, definitions.SHORT_TYPE());
- this.UNBOX_CARRAY = getUnboxArray(unboxes, definitions.CHAR_TYPE());
- this.UNBOX_IARRAY = getUnboxArray(unboxes, definitions.INT_TYPE());
- this.UNBOX_LARRAY = getUnboxArray(unboxes, definitions.LONG_TYPE());
- this.UNBOX_FARRAY = getUnboxArray(unboxes, definitions.FLOAT_TYPE());
- this.UNBOX_DARRAY = getUnboxArray(unboxes, definitions.DOUBLE_TYPE());
- this.UNBOX_OARRAY = getUnboxArray(unboxes, definitions.ANYREF_TYPE());
- this.UNBOX__ARRAY = getUnboxArray(unboxes, definitions.ANY_TYPE());
+ this.UNBOX_UVALUE = getUniqueTerm(RUNTIME, UNBOX_UVALUE_N);
+ this.UNBOX_ZVALUE = getUniqueTerm(RUNTIME, UNBOX_ZVALUE_N);
+ this.UNBOX_BVALUE = getUniqueTerm(RUNTIME, UNBOX_BVALUE_N);
+ this.UNBOX_SVALUE = getUniqueTerm(RUNTIME, UNBOX_SVALUE_N);
+ this.UNBOX_CVALUE = getUniqueTerm(RUNTIME, UNBOX_CVALUE_N);
+ this.UNBOX_IVALUE = getUniqueTerm(RUNTIME, UNBOX_IVALUE_N);
+ this.UNBOX_LVALUE = getUniqueTerm(RUNTIME, UNBOX_LVALUE_N);
+ this.UNBOX_FVALUE = getUniqueTerm(RUNTIME, UNBOX_FVALUE_N);
+ this.UNBOX_DVALUE = getUniqueTerm(RUNTIME, UNBOX_DVALUE_N);
+ this.UNBOX_ZARRAY = getUniqueTerm(RUNTIME, UNBOX_ZARRAY_N);
+ this.UNBOX_BARRAY = getUniqueTerm(RUNTIME, UNBOX_BARRAY_N);
+ this.UNBOX_SARRAY = getUniqueTerm(RUNTIME, UNBOX_SARRAY_N);
+ this.UNBOX_CARRAY = getUniqueTerm(RUNTIME, UNBOX_CARRAY_N);
+ this.UNBOX_IARRAY = getUniqueTerm(RUNTIME, UNBOX_IARRAY_N);
+ this.UNBOX_LARRAY = getUniqueTerm(RUNTIME, UNBOX_LARRAY_N);
+ this.UNBOX_FARRAY = getUniqueTerm(RUNTIME, UNBOX_FARRAY_N);
+ this.UNBOX_DARRAY = getUniqueTerm(RUNTIME, UNBOX_DARRAY_N);
+ this.UNBOX_OARRAY = getUniqueTerm(RUNTIME, UNBOX_OARRAY_N);
+ this.UNBOX__ARRAY = getUniqueTerm(RUNTIME, UNBOX__ARRAY_N);
this.B2B = getUniqueTerm(RUNTIME, B2B_N);
this.B2S = getUniqueTerm(RUNTIME, B2S_N);
this.B2C = getUniqueTerm(RUNTIME, B2C_N);
@@ -497,23 +516,6 @@ public class Primitives {
return getBoxValue(alts, Type.appliedType(array, new Type[]{type}));
}
- private Symbol getUnboxValue(Symbol[] alts, Type type) {
- for (int i = 0; i < alts.length; i++) {
- Type result = alts[i].type().resultType();
- switch (alts[i].type()) {
- case PolyType(Symbol[] tparams, _):
- result = result.subst(tparams, Symbol.info(tparams));
- }
- if (result.equals(type)) return alts[i];
- }
- throw Debug.abort("not found: def " +UNBOX_N+ "(" +type+ "): " +type);
- }
-
- private Symbol getUnboxArray(Symbol[] alts, Type type) {
- Type array = definitions.ARRAY_CLASS.type();
- return getUnboxValue(alts, Type.appliedType(array, new Type[]{type}));
- }
-
private Symbol getUniqueTerm(Symbol owner, Name name) {
Symbol symbol = getTerm(owner, name);
assert !symbol.isOverloaded() :