Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: linker.c 8042 2007-06-07 17:43:29Z twisti $
-
*/
}
+/* primitive_type_get_by_wrapperclass ******************************************
+
+ Returns the primitive type of the given wrapper-class.
+
+*******************************************************************************/
+
+int primitive_type_get_by_wrapperclass(classinfo *c)
+{
+ int i;
+
+ /* Search primitive table. */
+
+ for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
+ if (primitivetype_table[i].class_wrap == c)
+ return i;
+
+ /* Invalid primitive wrapper-class. */
+
+ return -1;
+}
+
+
/* primitive_box ***************************************************************
- Box a primitive of the given type.
+ Box a primitive of the given type. If the type is an object,
+ simply return it.
*******************************************************************************/
-java_objectheader *primitive_box(int type, imm_union value)
+java_handle_t *primitive_box(int type, imm_union value)
{
- java_objectheader *o;
+ java_handle_t *o;
switch (type) {
case PRIMITIVETYPE_BOOLEAN:
case PRIMITIVETYPE_DOUBLE:
o = primitive_box_double(value.d);
break;
+ case PRIMITIVETYPE_VOID:
+ o = value.a;
+ break;
default:
vm_abort("primitive_box: invalid primitive type %d", type);
}
/* primitive_unbox *************************************************************
- Unbox a primitive of the given type.
+ Unbox a primitive of the given type. If the type is an object,
+ simply return it.
*******************************************************************************/
-imm_union primitive_unbox(int type, java_objectheader *o)
+imm_union primitive_unbox(java_handle_t *o)
{
- imm_union value;
+ classinfo *c;
+ int type;
+ imm_union value;
+
+ c = o->vftbl->class;
+
+ type = primitive_type_get_by_wrapperclass(c);
switch (type) {
case PRIMITIVETYPE_BOOLEAN:
case PRIMITIVETYPE_DOUBLE:
value.d = primitive_unbox_double(o);
break;
+ case -1:
+ /* If type is -1 the object is not a primitive box but a
+ normal object. */
+ value.a = o;
+ break;
default:
vm_abort("primitive_unbox: invalid primitive type %d", type);
}
*******************************************************************************/
#define PRIMITIVE_BOX_TYPE(name, object, type) \
-java_objectheader *primitive_box_##name(type value) \
+java_handle_t *primitive_box_##name(type value) \
{ \
- java_objectheader *o; \
+ java_handle_t *o; \
java_lang_##object *jo; \
\
o = builtin_new(class_java_lang_##object); \
*******************************************************************************/
#define PRIMITIVE_UNBOX_TYPE(name, object, type) \
-type primitive_unbox_##name(java_objectheader *o) \
+type primitive_unbox_##name(java_handle_t *o) \
{ \
java_lang_##object *jo; \
type value; \