[llvm-commits] [vmkit] r51255 - /vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon May 19 09:12:22 PDT 2008
Author: geoffray
Date: Mon May 19 11:12:21 2008
New Revision: 51255
URL: http://llvm.org/viewvc/llvm-project?rev=51255&view=rev
Log:
Switch on the numId of the field's AssessorDesc to know what to do.
Modified:
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp?rev=51255&r1=51254&r2=51255&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp Mon May 19 11:12:21 2008
@@ -46,15 +46,32 @@
jobject Field, jobject obj) {
JavaField* field = (JavaField*)Classpath::fieldSlot->getVirtualInt32Field((JavaObject*)Field);
const AssessorDesc* ass = field->signature->funcs;
- if (ass != AssessorDesc::dInt && ass != AssessorDesc::dChar && ass != AssessorDesc::dByte && ass != AssessorDesc::dShort)
- JavaThread::get()->isolate->illegalArgumentException("");
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
-
- return isStatic(field->access) ?
- (sint32)field->getStaticInt32Field() :
- (sint32)field->getVirtualInt32Field((JavaObject*)obj);
+
+ switch (ass->numId) {
+ case INT_ID :
+ return isStatic(field->access) ?
+ (sint32)field->getStaticInt32Field() :
+ (sint32)field->getVirtualInt32Field((JavaObject*)obj);
+ case CHAR_ID :
+ return isStatic(field->access) ?
+ (uint32)field->getStaticInt16Field() :
+ (uint32)field->getVirtualInt16Field((JavaObject*)obj);
+ case BYTE_ID :
+ return isStatic(field->access) ?
+ (sint32)field->getStaticInt8Field() :
+ (sint32)field->getVirtualInt8Field((JavaObject*)obj);
+ case SHORT_ID :
+ return isStatic(field->access) ?
+ (sint32)field->getStaticInt16Field() :
+ (sint32)field->getVirtualInt16Field((JavaObject*)obj);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
+ }
+ return 0;
+
}
JNIEXPORT jlong JNICALL Java_java_lang_reflect_Field_getLong(
@@ -64,16 +81,35 @@
jobject Field, jobject obj) {
JavaField* field = (JavaField*)Classpath::fieldSlot->getVirtualInt32Field((JavaObject*)Field);
const AssessorDesc* ass = field->signature->funcs;
- if (ass != AssessorDesc::dInt && ass != AssessorDesc::dChar && ass != AssessorDesc::dByte && ass != AssessorDesc::dShort &&
- ass != AssessorDesc::dLong)
- JavaThread::get()->isolate->illegalArgumentException("");
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- return isStatic(field->access) ?
- (sint64)field->getStaticLongField() :
- (sint64)field->getVirtualLongField((JavaObject*)obj);
+ switch (ass->numId) {
+ case INT_ID :
+ return isStatic(field->access) ?
+ (sint64)field->getStaticInt32Field() :
+ (sint64)field->getVirtualInt32Field((JavaObject*)obj);
+ case CHAR_ID :
+ return isStatic(field->access) ?
+ (uint64)field->getStaticInt16Field() :
+ (uint64)field->getVirtualInt16Field((JavaObject*)obj);
+ case BYTE_ID :
+ return isStatic(field->access) ?
+ (sint64)field->getStaticInt8Field() :
+ (sint64)field->getVirtualInt8Field((JavaObject*)obj);
+ case SHORT_ID :
+ return isStatic(field->access) ?
+ (sint64)field->getStaticInt16Field() :
+ (sint64)field->getVirtualInt16Field((JavaObject*)obj);
+ case LONG_ID :
+ return isStatic(field->access) ?
+ (sint64)field->getStaticLongField() :
+ (sint64)field->getVirtualLongField((JavaObject*)obj);
+ default:
+ JavaThread::get()->isolate->illegalArgumentException("");
+ }
+ return 0;
}
JNIEXPORT jboolean JNICALL Java_java_lang_reflect_Field_getBoolean(
@@ -84,15 +120,20 @@
JavaField* field = (JavaField*)Classpath::fieldSlot->getVirtualInt32Field((JavaObject*)Field);
const AssessorDesc* ass = field->signature->funcs;
- if (ass != AssessorDesc::dBool)
- JavaThread::get()->isolate->illegalArgumentException("");
-
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- return isStatic(field->access) ?
- (uint8)field->getStaticInt8Field() :
- (uint8)field->getVirtualInt8Field((JavaObject*)obj);
+ switch (ass->numId) {
+ case BOOL_ID :
+ return isStatic(field->access) ?
+ (uint8)field->getStaticInt8Field() :
+ (uint8)field->getVirtualInt8Field((JavaObject*)obj);
+ default:
+ JavaThread::get()->isolate->illegalArgumentException("");
+ }
+
+ return 0;
+
}
JNIEXPORT jfloat JNICALL Java_java_lang_reflect_Field_getFloat(
@@ -106,32 +147,34 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dByte) {
- return isStatic(field->access) ?
- (jfloat)field->getStaticInt8Field() :
- (jfloat)field->getVirtualInt8Field((JavaObject*)obj);
- } else if (ass == AssessorDesc::dInt) {
- return isStatic(field->access) ?
- (jfloat)field->getStaticInt32Field() :
- (jfloat)field->getVirtualInt32Field((JavaObject*)obj);
- } else if (ass == AssessorDesc::dShort) {
- return isStatic(field->access) ?
- (jfloat)field->getStaticInt16Field() :
- (jfloat)field->getVirtualInt16Field((JavaObject*)obj);
- } else if (ass == AssessorDesc::dLong) {
- return isStatic(field->access) ?
- (jfloat)field->getStaticLongField() :
- (jfloat)field->getVirtualLongField((JavaObject*)obj);
- } else if (ass == AssessorDesc::dChar) {
- return isStatic(field->access) ?
- (jfloat)(uint32)field->getStaticInt16Field() :
- (jfloat)(uint32)field->getVirtualInt16Field((JavaObject*)obj);
- } else if (ass == AssessorDesc::dFloat) {
- return isStatic(field->access) ?
- (jfloat)field->getStaticFloatField() :
- (jfloat)field->getVirtualFloatField((JavaObject*)obj);
+ switch (ass->numId) {
+ case BYTE_ID :
+ return isStatic(field->access) ?
+ (jfloat)field->getStaticInt8Field() :
+ (jfloat)field->getVirtualInt8Field((JavaObject*)obj);
+ case INT_ID :
+ return isStatic(field->access) ?
+ (jfloat)field->getStaticInt32Field() :
+ (jfloat)field->getVirtualInt32Field((JavaObject*)obj);
+ case SHORT_ID :
+ return isStatic(field->access) ?
+ (jfloat)field->getStaticInt16Field() :
+ (jfloat)field->getVirtualInt16Field((JavaObject*)obj);
+ case LONG_ID :
+ return isStatic(field->access) ?
+ (jfloat)field->getStaticLongField() :
+ (jfloat)field->getVirtualLongField((JavaObject*)obj);
+ case CHAR_ID :
+ return isStatic(field->access) ?
+ (jfloat)(uint32)field->getStaticInt16Field() :
+ (jfloat)(uint32)field->getVirtualInt16Field((JavaObject*)obj);
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ (jfloat)field->getStaticFloatField() :
+ (jfloat)field->getVirtualFloatField((JavaObject*)obj);
+ default:
+ JavaThread::get()->isolate->illegalArgumentException("");
}
- JavaThread::get()->isolate->illegalArgumentException("");
return 0.0;
}
@@ -142,15 +185,20 @@
jobject Field, jobject obj) {
JavaField* field = (JavaField*)Classpath::fieldSlot->getVirtualInt32Field((JavaObject*)Field);
const AssessorDesc* ass = field->signature->funcs;
- if (ass != AssessorDesc::dByte)
- JavaThread::get()->isolate->illegalArgumentException("");
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- return isStatic(field->access) ?
- (sint8)field->getStaticInt8Field() :
- (sint8)field->getVirtualInt8Field((JavaObject*)obj);
+ switch (ass->numId) {
+ case BYTE_ID :
+ return isStatic(field->access) ?
+ (sint8)field->getStaticInt8Field() :
+ (sint8)field->getVirtualInt8Field((JavaObject*)obj);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
+ }
+
+ return 0;
}
JNIEXPORT jchar JNICALL Java_java_lang_reflect_Field_getChar(
@@ -161,15 +209,20 @@
JavaField* field = (JavaField*)Classpath::fieldSlot->getVirtualInt32Field((JavaObject*)Field);
const AssessorDesc* ass = field->signature->funcs;
- if (ass != AssessorDesc::dChar)
- JavaThread::get()->isolate->illegalArgumentException("");
-
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- return isStatic(field->access) ?
- (uint16)field->getStaticInt16Field() :
- (uint16)field->getVirtualInt16Field((JavaObject*)obj);
+ switch (ass->numId) {
+ case CHAR_ID :
+ return isStatic(field->access) ?
+ (uint16)field->getStaticInt16Field() :
+ (uint16)field->getVirtualInt16Field((JavaObject*)obj);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
+ }
+
+ return 0;
+
}
JNIEXPORT jshort JNICALL Java_java_lang_reflect_Field_getShort(
@@ -180,15 +233,23 @@
JavaField* field = (JavaField*)Classpath::fieldSlot->getVirtualInt32Field((JavaObject*)Field);
const AssessorDesc* ass = field->signature->funcs;
- if (ass != AssessorDesc::dShort && ass != AssessorDesc::dByte)
- JavaThread::get()->isolate->illegalArgumentException("");
-
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- return isStatic(field->access) ?
- (sint16)field->getStaticInt16Field() :
- (sint16)field->getVirtualInt16Field((JavaObject*)obj);
+ switch (ass->numId) {
+ case SHORT_ID :
+ return isStatic(field->access) ?
+ (sint16)field->getStaticInt16Field() :
+ (sint16)field->getVirtualInt16Field((JavaObject*)obj);
+ case BYTE_ID :
+ return isStatic(field->access) ?
+ (sint16)field->getStaticInt8Field() :
+ (sint16)field->getVirtualInt8Field((JavaObject*)obj);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
+ }
+
+ return 0;
}
JNIEXPORT jdouble JNICALL Java_java_lang_reflect_Field_getDouble(
@@ -202,36 +263,38 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dByte) {
- return isStatic(field->access) ?
- (jdouble)(sint64)field->getStaticInt8Field() :
- (jdouble)(sint64)field->getVirtualInt8Field((JavaObject*)obj);
- } else if (ass == AssessorDesc::dInt) {
- return isStatic(field->access) ?
- (jdouble)(sint64)field->getStaticInt32Field() :
- (jdouble)(sint64)field->getVirtualInt32Field((JavaObject*)obj);
- } else if (ass == AssessorDesc::dShort) {
- return isStatic(field->access) ?
- (jdouble)(sint64)field->getStaticInt16Field() :
- (jdouble)(sint64)field->getVirtualInt16Field((JavaObject*)obj);
- } else if (ass == AssessorDesc::dLong) {
- return isStatic(field->access) ?
- (jdouble)(sint64)field->getStaticLongField() :
- (jdouble)(sint64)field->getVirtualLongField((JavaObject*)obj);
- } else if (ass == AssessorDesc::dChar) {
- return isStatic(field->access) ?
- (jdouble)(uint64)field->getStaticInt16Field() :
- (jdouble)(uint64)field->getVirtualInt16Field((JavaObject*)obj);
- } else if (ass == AssessorDesc::dFloat) {
- return isStatic(field->access) ?
- (jdouble)field->getStaticFloatField() :
- (jdouble)field->getVirtualFloatField((JavaObject*)obj);
- } else if (ass == AssessorDesc::dDouble) {
- return isStatic(field->access) ?
- (jdouble)field->getStaticDoubleField() :
- (jdouble)field->getVirtualDoubleField((JavaObject*)obj);
+ switch (ass->numId) {
+ case BYTE_ID :
+ return isStatic(field->access) ?
+ (jdouble)(sint64)field->getStaticInt8Field() :
+ (jdouble)(sint64)field->getVirtualInt8Field((JavaObject*)obj);
+ case INT_ID :
+ return isStatic(field->access) ?
+ (jdouble)(sint64)field->getStaticInt32Field() :
+ (jdouble)(sint64)field->getVirtualInt32Field((JavaObject*)obj);
+ case SHORT_ID :
+ return isStatic(field->access) ?
+ (jdouble)(sint64)field->getStaticInt16Field() :
+ (jdouble)(sint64)field->getVirtualInt16Field((JavaObject*)obj);
+ case LONG_ID :
+ return isStatic(field->access) ?
+ (jdouble)(sint64)field->getStaticLongField() :
+ (jdouble)(sint64)field->getVirtualLongField((JavaObject*)obj);
+ case CHAR_ID :
+ return isStatic(field->access) ?
+ (jdouble)(uint64)field->getStaticInt16Field() :
+ (jdouble)(uint64)field->getVirtualInt16Field((JavaObject*)obj);
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ (jdouble)field->getStaticFloatField() :
+ (jdouble)field->getVirtualFloatField((JavaObject*)obj);
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ (jdouble)field->getStaticDoubleField() :
+ (jdouble)field->getVirtualDoubleField((JavaObject*)obj);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
}
- JavaThread::get()->isolate->illegalArgumentException("");
return 0.0;
}
@@ -250,60 +313,79 @@
JavaThread::get()->isolate->initialiseClass(field->classDef);
JavaObject* res = 0;
- if (ass == AssessorDesc::dBool) {
- uint8 val = (isStatic(field->access) ?
- field->getStaticInt8Field() :
- field->getVirtualInt8Field(obj));
- res = (*Classpath::boolClass)(vm);
- Classpath::boolValue->setVirtualInt8Field(res, val);
- } else if (ass == AssessorDesc::dByte) {
- sint8 val = (isStatic(field->access) ?
- field->getStaticInt8Field() :
- field->getVirtualInt8Field(obj));
- res = (*Classpath::byteClass)(vm);
- Classpath::byteValue->setVirtualInt8Field(res, val);
- } else if (ass == AssessorDesc::dChar) {
- uint16 val = (isStatic(field->access) ?
- field->getStaticInt16Field() :
- field->getVirtualInt16Field(obj));
- res = (*Classpath::charClass)(vm);
- Classpath::charValue->setVirtualInt16Field(res, val);
- } else if (ass == AssessorDesc::dShort) {
- sint16 val = (isStatic(field->access) ?
- field->getStaticInt16Field() :
- field->getVirtualInt16Field(obj));
- res = (*Classpath::shortClass)(vm);
- Classpath::shortValue->setVirtualInt16Field(res, val);
- } else if (ass == AssessorDesc::dInt) {
- sint32 val = (isStatic(field->access) ?
- field->getStaticInt32Field() :
- field->getVirtualInt32Field(obj));
- res = (*Classpath::intClass)(vm);
- Classpath::intValue->setVirtualInt32Field(res, val);
- } else if (ass == AssessorDesc::dLong) {
- sint64 val = (isStatic(field->access) ?
- field->getStaticLongField() :
- field->getVirtualLongField(obj));
- res = (*Classpath::longClass)(vm);
- Classpath::longValue->setVirtualLongField(res, val);
- } else if (ass == AssessorDesc::dFloat) {
- float val = (isStatic(field->access) ?
- field->getStaticFloatField() :
- field->getVirtualFloatField(obj));
- res = (*Classpath::floatClass)(vm);
- Classpath::floatValue->setVirtualFloatField(res, val);
- } else if (ass == AssessorDesc::dDouble) {
- double val = (isStatic(field->access) ?
- field->getStaticDoubleField() :
- field->getVirtualDoubleField(obj));
- res = (*Classpath::doubleClass)(vm);
- Classpath::doubleValue->setVirtualDoubleField(res, val);
- } else if (ass == AssessorDesc::dTab || ass == AssessorDesc::dRef) {
- res = (isStatic(field->access) ?
- field->getStaticObjectField() :
- field->getVirtualObjectField(obj));
- } else {
- JavaThread::get()->isolate->unknownError("should not be here");
+ switch (ass->numId) {
+ case BOOL_ID : {
+ uint8 val = (isStatic(field->access) ?
+ field->getStaticInt8Field() :
+ field->getVirtualInt8Field(obj));
+ res = (*Classpath::boolClass)(vm);
+ Classpath::boolValue->setVirtualInt8Field(res, val);
+ break;
+ }
+ case BYTE_ID : {
+ sint8 val = (isStatic(field->access) ?
+ field->getStaticInt8Field() :
+ field->getVirtualInt8Field(obj));
+ res = (*Classpath::byteClass)(vm);
+ Classpath::byteValue->setVirtualInt8Field(res, val);
+ break;
+ }
+ case CHAR_ID : {
+ uint16 val = (isStatic(field->access) ?
+ field->getStaticInt16Field() :
+ field->getVirtualInt16Field(obj));
+ res = (*Classpath::charClass)(vm);
+ Classpath::charValue->setVirtualInt16Field(res, val);
+ break;
+ }
+ case SHORT_ID : {
+ sint16 val = (isStatic(field->access) ?
+ field->getStaticInt16Field() :
+ field->getVirtualInt16Field(obj));
+ res = (*Classpath::shortClass)(vm);
+ Classpath::shortValue->setVirtualInt16Field(res, val);
+ break;
+ }
+ case INT_ID : {
+ sint32 val = (isStatic(field->access) ?
+ field->getStaticInt32Field() :
+ field->getVirtualInt32Field(obj));
+ res = (*Classpath::intClass)(vm);
+ Classpath::intValue->setVirtualInt32Field(res, val);
+ break;
+ }
+ case LONG_ID : {
+ sint64 val = (isStatic(field->access) ?
+ field->getStaticLongField() :
+ field->getVirtualLongField(obj));
+ res = (*Classpath::longClass)(vm);
+ Classpath::longValue->setVirtualLongField(res, val);
+ break;
+ }
+ case FLOAT_ID : {
+ float val = (isStatic(field->access) ?
+ field->getStaticFloatField() :
+ field->getVirtualFloatField(obj));
+ res = (*Classpath::floatClass)(vm);
+ Classpath::floatValue->setVirtualFloatField(res, val);
+ break;
+ }
+ case DOUBLE_ID : {
+ double val = (isStatic(field->access) ?
+ field->getStaticDoubleField() :
+ field->getVirtualDoubleField(obj));
+ res = (*Classpath::doubleClass)(vm);
+ Classpath::doubleValue->setVirtualDoubleField(res, val);
+ break;
+ }
+ case OBJECT_ID :
+ case ARRAY_ID :
+ res = (isStatic(field->access) ?
+ field->getStaticObjectField() :
+ field->getVirtualObjectField(obj));
+ break;
+ default:
+ JavaThread::get()->isolate->unknownError("should not be here");
}
return (jobject)res;
}
@@ -323,44 +405,46 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dBool) {
- isStatic(field->access) ?
- field->setStaticInt8Field(((uint8*)_buf)[0]) :
- field->setVirtualInt8Field((JavaObject*)obj, ((uint8*)_buf)[0]);
- } else if (ass == AssessorDesc::dByte) {
- isStatic(field->access) ?
- field->setStaticInt8Field(((sint8*)_buf)[0]) :
- field->setVirtualInt8Field((JavaObject*)obj, ((sint8*)_buf)[0]);
- } else if (ass == AssessorDesc::dChar) {
- isStatic(field->access) ?
- field->setStaticInt16Field(((uint16*)_buf)[0]) :
- field->setVirtualInt16Field((JavaObject*)obj, ((uint16*)_buf)[0]);
- } else if (ass == AssessorDesc::dShort) {
- isStatic(field->access) ?
- field->setStaticInt16Field(((sint16*)_buf)[0]) :
- field->setVirtualInt16Field((JavaObject*)obj, ((sint16*)_buf)[0]);
- } else if (ass == AssessorDesc::dInt) {
- isStatic(field->access) ?
- field->setStaticInt32Field(((sint32*)_buf)[0]) :
- field->setVirtualInt32Field((JavaObject*)obj, ((sint32*)_buf)[0]);
- } else if (ass == AssessorDesc::dLong) {
- isStatic(field->access) ?
- field->setStaticLongField(((sint64*)_buf)[0]) :
- field->setVirtualLongField((JavaObject*)obj, ((sint64*)_buf)[0]);
- } else if (ass == AssessorDesc::dFloat) {
- isStatic(field->access) ?
- field->setStaticFloatField(((float*)_buf)[0]) :
- field->setVirtualFloatField((JavaObject*)obj, ((float*)_buf)[0]);
- } else if (ass == AssessorDesc::dDouble) {
- isStatic(field->access) ?
- field->setStaticDoubleField(((double*)_buf)[0]) :
- field->setVirtualDoubleField((JavaObject*)obj, ((double*)_buf)[0]);
- } else if (ass == AssessorDesc::dTab || ass == AssessorDesc::dRef) {
- isStatic(field->access) ?
- field->setStaticObjectField(((JavaObject**)_buf)[0]) :
- field->setVirtualObjectField((JavaObject*)obj, ((JavaObject**)_buf)[0]);
- } else {
- JavaThread::get()->isolate->unknownError("should not be here");
+ switch (ass->numId) {
+ case BOOL_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt8Field(((uint8*)_buf)[0]) :
+ field->setVirtualInt8Field((JavaObject*)obj, ((uint8*)_buf)[0]);
+ case BYTE_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt8Field(((sint8*)_buf)[0]) :
+ field->setVirtualInt8Field((JavaObject*)obj, ((sint8*)_buf)[0]);
+ case CHAR_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt16Field(((uint16*)_buf)[0]) :
+ field->setVirtualInt16Field((JavaObject*)obj, ((uint16*)_buf)[0]);
+ case SHORT_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt16Field(((sint16*)_buf)[0]) :
+ field->setVirtualInt16Field((JavaObject*)obj, ((sint16*)_buf)[0]);
+ case INT_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt32Field(((sint32*)_buf)[0]) :
+ field->setVirtualInt32Field((JavaObject*)obj, ((sint32*)_buf)[0]);
+ case LONG_ID :
+ return isStatic(field->access) ?
+ field->setStaticLongField(((sint64*)_buf)[0]) :
+ field->setVirtualLongField((JavaObject*)obj, ((sint64*)_buf)[0]);
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ field->setStaticFloatField(((float*)_buf)[0]) :
+ field->setVirtualFloatField((JavaObject*)obj, ((float*)_buf)[0]);
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ field->setStaticDoubleField(((double*)_buf)[0]) :
+ field->setVirtualDoubleField((JavaObject*)obj, ((double*)_buf)[0]);
+ case ARRAY_ID :
+ case OBJECT_ID :
+ return isStatic(field->access) ?
+ field->setStaticObjectField(((JavaObject**)_buf)[0]) :
+ field->setVirtualObjectField((JavaObject*)obj, ((JavaObject**)_buf)[0]);
+ default :
+ JavaThread::get()->isolate->unknownError("should not be here");
}
}
@@ -372,15 +456,18 @@
JavaField* field = (JavaField*)Classpath::fieldSlot->getVirtualInt32Field((JavaObject*)Field);
const AssessorDesc* ass = field->signature->funcs;
- if (ass != AssessorDesc::dBool)
- JavaThread::get()->isolate->illegalArgumentException("");
-
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
+
+ switch (ass->numId) {
+ case BOOL_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt8Field((uint8)val) :
+ field->setVirtualInt8Field((JavaObject*)obj, (uint8)val);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
+ }
- isStatic(field->access) ?
- field->setStaticInt8Field((uint8)val) :
- field->setVirtualInt8Field((JavaObject*)obj, (uint8)val);
}
JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte(
@@ -395,32 +482,33 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dByte) {
- isStatic(field->access) ?
- field->setStaticInt8Field((sint8)val) :
- field->setVirtualInt8Field((JavaObject*)obj, (sint8)val);
- } else if (ass == AssessorDesc::dShort) {
- isStatic(field->access) ?
- field->setStaticInt16Field((sint16)val) :
- field->setVirtualInt16Field((JavaObject*)obj, (sint16)val);
- } else if (ass == AssessorDesc::dInt) {
- isStatic(field->access) ?
- field->setStaticInt32Field((sint32)val) :
- field->setVirtualInt32Field((JavaObject*)obj, (sint32)val);
- } else if (ass == AssessorDesc::dLong) {
- isStatic(field->access) ?
- field->setStaticLongField((sint64)val) :
- field->setVirtualLongField((JavaObject*)obj, (sint64)val);
- } else if (ass == AssessorDesc::dFloat) {
- isStatic(field->access) ?
- field->setStaticFloatField((float)val) :
- field->setVirtualFloatField((JavaObject*)obj, (float)val);
- } else if (ass == AssessorDesc::dDouble) {
- isStatic(field->access) ?
- field->setStaticDoubleField((double)val) :
- field->setVirtualDoubleField((JavaObject*)obj, (double)val);
- } else {
- JavaThread::get()->isolate->illegalArgumentException("");
+ switch (ass->numId) {
+ case BYTE_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt8Field((sint8)val) :
+ field->setVirtualInt8Field((JavaObject*)obj, (sint8)val);
+ case SHORT_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt16Field((sint16)val) :
+ field->setVirtualInt16Field((JavaObject*)obj, (sint16)val);
+ case INT_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt32Field((sint32)val) :
+ field->setVirtualInt32Field((JavaObject*)obj, (sint32)val);
+ case LONG_ID :
+ return isStatic(field->access) ?
+ field->setStaticLongField((sint64)val) :
+ field->setVirtualLongField((JavaObject*)obj, (sint64)val);
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ field->setStaticFloatField((float)val) :
+ field->setVirtualFloatField((JavaObject*)obj, (float)val);
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ field->setStaticDoubleField((double)val) :
+ field->setVirtualDoubleField((JavaObject*)obj, (double)val);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
}
}
@@ -435,28 +523,29 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dChar) {
- isStatic(field->access) ?
- field->setStaticInt16Field((double)val) :
- field->setVirtualDoubleField((JavaObject*)obj, (uint16)val);
- } else if (ass == AssessorDesc::dInt) {
- isStatic(field->access) ?
- field->setStaticInt32Field((uint32)val) :
- field->setVirtualInt32Field((JavaObject*)obj, (uint32)val);
- } else if (ass == AssessorDesc::dLong) {
- isStatic(field->access) ?
- field->setStaticLongField((uint64)val) :
- field->setVirtualLongField((JavaObject*)obj, (uint64)val);
- } else if (ass == AssessorDesc::dFloat) {
- isStatic(field->access) ?
- field->setStaticFloatField((float)(uint32)val) :
- field->setVirtualFloatField((JavaObject*)obj, (float)(uint32)val);
- } else if (ass == AssessorDesc::dDouble) {
- isStatic(field->access) ?
- field->setStaticDoubleField((double)(uint64)val) :
- field->setVirtualDoubleField((JavaObject*)obj, (double)(uint64)val);
- } else {
- JavaThread::get()->isolate->illegalArgumentException("");
+ switch (ass->numId) {
+ case CHAR_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt16Field((double)val) :
+ field->setVirtualDoubleField((JavaObject*)obj, (uint16)val);
+ case INT_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt32Field((uint32)val) :
+ field->setVirtualInt32Field((JavaObject*)obj, (uint32)val);
+ case LONG_ID :
+ return isStatic(field->access) ?
+ field->setStaticLongField((uint64)val) :
+ field->setVirtualLongField((JavaObject*)obj, (uint64)val);
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ field->setStaticFloatField((float)(uint32)val) :
+ field->setVirtualFloatField((JavaObject*)obj, (float)(uint32)val);
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ field->setStaticDoubleField((double)(uint64)val) :
+ field->setVirtualDoubleField((JavaObject*)obj, (double)(uint64)val);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
}
}
@@ -471,28 +560,29 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dShort) {
- isStatic(field->access) ?
- field->setStaticInt16Field((sint16)val) :
- field->setVirtualInt16Field((JavaObject*)obj, (sint16)val);
- } else if (ass == AssessorDesc::dInt) {
- isStatic(field->access) ?
- field->setStaticInt32Field((sint32)val) :
- field->setVirtualInt32Field((JavaObject*)obj, (sint32)val);
- } else if (ass == AssessorDesc::dLong) {
- isStatic(field->access) ?
- field->setStaticLongField((sint64)val) :
- field->setVirtualLongField((JavaObject*)obj, (sint64)val);
- } else if (ass == AssessorDesc::dFloat) {
- isStatic(field->access) ?
- field->setStaticFloatField((float)val) :
- field->setVirtualFloatField((JavaObject*)obj, (float)val);
- } else if (ass == AssessorDesc::dDouble) {
- isStatic(field->access) ?
- field->setStaticDoubleField((double)val) :
- field->setVirtualDoubleField((JavaObject*)obj, (double)val);
- } else {
- JavaThread::get()->isolate->illegalArgumentException("");
+ switch (ass->numId) {
+ case SHORT_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt16Field((sint16)val) :
+ field->setVirtualInt16Field((JavaObject*)obj, (sint16)val);
+ case INT_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt32Field((sint32)val) :
+ field->setVirtualInt32Field((JavaObject*)obj, (sint32)val);
+ case LONG_ID :
+ return isStatic(field->access) ?
+ field->setStaticLongField((sint64)val) :
+ field->setVirtualLongField((JavaObject*)obj, (sint64)val);
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ field->setStaticFloatField((float)val) :
+ field->setVirtualFloatField((JavaObject*)obj, (float)val);
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ field->setStaticDoubleField((double)val) :
+ field->setVirtualDoubleField((JavaObject*)obj, (double)val);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
}
}
@@ -507,23 +597,24 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dInt) {
- isStatic(field->access) ?
- field->setStaticInt32Field((sint32)val) :
- field->setVirtualInt32Field((JavaObject*)obj, (sint32)val);
- } else if (ass == AssessorDesc::dLong) {
- isStatic(field->access) ?
- field->setStaticLongField((sint64)val) :
- field->setVirtualLongField((JavaObject*)obj, (sint64)val);
- } else if (ass == AssessorDesc::dFloat) {
- isStatic(field->access) ?
- field->setStaticFloatField((float)val) :
- field->setVirtualFloatField((JavaObject*)obj, (float)val);
- } else if (ass == AssessorDesc::dDouble) {
- isStatic(field->access) ?
- field->setStaticDoubleField((double)val) :
- field->setVirtualDoubleField((JavaObject*)obj, (double)val);
- } else {
+ switch (ass->numId) {
+ case INT_ID :
+ return isStatic(field->access) ?
+ field->setStaticInt32Field((sint32)val) :
+ field->setVirtualInt32Field((JavaObject*)obj, (sint32)val);
+ case LONG_ID :
+ return isStatic(field->access) ?
+ field->setStaticLongField((sint64)val) :
+ field->setVirtualLongField((JavaObject*)obj, (sint64)val);
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ field->setStaticFloatField((float)val) :
+ field->setVirtualFloatField((JavaObject*)obj, (float)val);
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ field->setStaticDoubleField((double)val) :
+ field->setVirtualDoubleField((JavaObject*)obj, (double)val);
+ default :
JavaThread::get()->isolate->illegalArgumentException("");
}
}
@@ -539,20 +630,21 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dLong) {
- isStatic(field->access) ?
- field->setStaticLongField((sint64)val) :
- field->setVirtualLongField((JavaObject*)obj, (sint64)val);
- } else if (ass == AssessorDesc::dFloat) {
- isStatic(field->access) ?
- field->setStaticFloatField((float)val) :
- field->setVirtualFloatField((JavaObject*)obj, (float)val);
- } else if (ass == AssessorDesc::dDouble) {
- isStatic(field->access) ?
- field->setStaticDoubleField((double)val) :
- field->setVirtualDoubleField((JavaObject*)obj, (double)val);
- } else {
- JavaThread::get()->isolate->illegalArgumentException("");
+ switch (ass->numId) {
+ case LONG_ID :
+ return isStatic(field->access) ?
+ field->setStaticLongField((sint64)val) :
+ field->setVirtualLongField((JavaObject*)obj, (sint64)val);
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ field->setStaticFloatField((float)val) :
+ field->setVirtualFloatField((JavaObject*)obj, (float)val);
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ field->setStaticDoubleField((double)val) :
+ field->setVirtualDoubleField((JavaObject*)obj, (double)val);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
}
}
@@ -567,16 +659,17 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dFloat) {
- isStatic(field->access) ?
- field->setStaticFloatField((float)val) :
- field->setVirtualFloatField((JavaObject*)obj, (float)val);
- } else if (ass == AssessorDesc::dDouble) {
- isStatic(field->access) ?
- field->setStaticDoubleField((double)val) :
- field->setVirtualDoubleField((JavaObject*)obj, (double)val);
- } else {
- JavaThread::get()->isolate->illegalArgumentException("");
+ switch (ass->numId) {
+ case FLOAT_ID :
+ return isStatic(field->access) ?
+ field->setStaticFloatField((float)val) :
+ field->setVirtualFloatField((JavaObject*)obj, (float)val);
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ field->setStaticDoubleField((double)val) :
+ field->setVirtualDoubleField((JavaObject*)obj, (double)val);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
}
}
@@ -591,12 +684,13 @@
if (isStatic(field->access))
JavaThread::get()->isolate->initialiseClass(field->classDef);
- if (ass == AssessorDesc::dDouble) {
- isStatic(field->access) ?
- field->setStaticDoubleField((double)val) :
- field->setVirtualDoubleField((JavaObject*)obj, (double)val);
- } else {
- JavaThread::get()->isolate->illegalArgumentException("");
+ switch (ass->numId) {
+ case DOUBLE_ID :
+ return isStatic(field->access) ?
+ field->setStaticDoubleField((double)val) :
+ field->setVirtualDoubleField((JavaObject*)obj, (double)val);
+ default :
+ JavaThread::get()->isolate->illegalArgumentException("");
}
}
More information about the llvm-commits
mailing list