📄 soft.c
字号:
*/voidsoft_nosuchmethod(Hjava_lang_Class* c, Utf8Const* n, Utf8Const* s){ char buf[256]; sprintf(buf, "%.80s.%.80s%.80s", CLASS_CNAME(c), n->data, s->data); throwException(NoSuchMethodError(buf));}/* * soft_nosuchfield. */voidsoft_nosuchfield(Utf8Const* c, Utf8Const* n){ char buf[256]; sprintf(buf, "%.100s.%.100s", c->data, n->data); throwException(NoSuchFieldError(buf));}voidsoft_linkage(Utf8Const *c, Utf8Const* n){ char buf[256]; sprintf(buf, "%.100s.%.100s", c->data, n->data); throwException(LinkageError(buf));}voidsoft_illegalaccess(Utf8Const *c, Utf8Const* n){ char buf[256]; sprintf(buf, "%.100s.%.100s", c->data, n->data); throwException(IllegalAccessError(buf));}/* * soft_incompatibleclasschange. */voidsoft_incompatibleclasschange(Utf8Const *c, Utf8Const* n){ char buf[256]; sprintf(buf, "%.100s.%.100s", c->data, n->data); throwException(IncompatibleClassChangeError(buf));}/* * soft_abstractmethod. */voidsoft_abstractmethod(Utf8Const *c, Utf8Const* n){ char buf[256]; sprintf(buf, "%.100s.%.100s", c->data, n->data); throwException(AbstractMethodError(buf));}/* * soft_initialise_class. */voidsoft_initialise_class(Hjava_lang_Class* c){ /* We check this outside the processClass to save a subroutine call */ if (c->state != CSTATE_COMPLETE) { errorInfo info; if (processClass(c, CSTATE_COMPLETE, &info) == false) { throwError(&info); } }}/* * Check we can store 'obj' into the 'array'. */voidsoft_checkarraystore(Hjava_lang_Object* array, Hjava_lang_Object* obj){ if (obj != NULL && soft_instanceof(Kaffe_get_array_element_type(OBJECT_CLASS(array)), obj) == 0) { Hjava_lang_Throwable* asexc; const char *otype = CLASS_CNAME(OBJECT_CLASS(obj)); const char *atype = CLASS_CNAME(OBJECT_CLASS(array)); char *b;#define _FORMAT "can't store `%s' in `%s'" b = checkPtr(KMALLOC(strlen(otype)+strlen(atype)+strlen(_FORMAT))); sprintf(b, _FORMAT, otype, atype);#undef _FORMAT asexc = ArrayStoreException(b); KFREE(b); throwException(asexc); }}/** * dcmp helper function. * * @param v1 left side value * @param v2 right side value * @param nan return value in case v1 or v2 is NaN * * @return 1 if v1 > v2, 0 if v1 == v2, -1 if v1 < v2, otherwise nan. */staticjintsoft_dcmp(const jdouble v1, const jdouble v2, const jint nan){ if (v1 > v2) return 1; else if (v1 == v2) return 0; else if (v1 < v2) return -1; else return nan;} /* * soft_dcmpg */jintsoft_dcmpg(jdouble v1, jdouble v2){ return soft_dcmp(v1, v2, 1);}/* * soft_dcmpl */jintsoft_dcmpl(jdouble v1, jdouble v2){ return soft_dcmp(v1, v2, -1);}/* * soft_fcmpg */jintsoft_fcmpg(jfloat v1, jfloat v2){ return soft_dcmpg(v1, v2);}/* * soft_fcmpg */jintsoft_fcmpl(jfloat v1, jfloat v2){ return soft_dcmpl(v1, v2);}jdoublesoft_fdivl(jdouble v1, jdouble v2){ return doubleDivide(v1, v2);}#if defined(TRANSLATOR)jlongsoft_lmul(jlong v1, jlong v2){ return (v1 * v2);}jlongsoft_ldiv(jlong v1, jlong v2){ return (v1 / v2);}jlongsoft_lrem(jlong v1, jlong v2){ return (v1 % v2);}jfloatsoft_fadd(jfloat v1, jfloat v2){ return floatAdd(v1, v2);}jdoublesoft_faddl(jdouble v1, jdouble v2){ return doubleAdd(v1, v2);}jfloatsoft_fsub(jfloat v1, jfloat v2){ return floatSubtract(v1, v2);}jdoublesoft_fsubl(jdouble v1, jdouble v2){ return doubleSubtract(v1, v2);}jfloatsoft_fmul(jfloat v1, jfloat v2){ return floatMultiply(v1, v2);}jdoublesoft_fmull(jdouble v1, jdouble v2){ return doubleMultiply(v1, v2);}jfloatsoft_fdiv(jfloat v1, jfloat v2){ return floatDivide(v1, v2);}jfloatsoft_frem(jfloat v1, jfloat v2){ return (javaRemainderf(v1, v2));}jdoublesoft_freml(jdouble v1, jdouble v2){ return (javaRemainder(v1, v2));}jlongsoft_lshll(jlong v1, jint v2){ return (v1 << (v2 & 63));}jlongsoft_ashrl(jlong v1, jint v2){ return (v1 >> (v2 & 63));}jlongsoft_lshrl(jlong v1, jint v2){ return (((uint64)v1) >> (v2 & 63));}jintsoft_lcmp(jlong v1, jlong v2){ if (v2 < v1) { return (-1); } else if (v2 > v1) { return (1); } else { return (0); }}#endifjintsoft_mul(jint v1, jint v2){ return (v1*v2);}jintsoft_div(jint v1, jint v2){ if (v2 == -1) return -v1; return (v1/v2);}jintsoft_rem(jint v1, jint v2){ if (v2 == -1) return 0; return (v1%v2);}jfloatsoft_cvtlf(jlong v){ return ((jfloat)v);}jfloatsoft_cvtif(jint v){ return ((jfloat)v);}jdoublesoft_cvtid(jint v){ return ((jdouble)v);}jdoublesoft_cvtld(jlong v){ return ((jdouble)v);}/** * convert a float to a double * * @param v a float * * @return the double corresponding to the float, or Double.NaN if the float is a NaN. */jdoublesoft_cvtfd(jfloat v){ if (isnan(v)) return KAFFE_JDOUBLE_NAN; else return (jdouble)v;}/** * convert a double to float * * @param v a double * * @return the float corresponding to the double, or Float.NaN if the double is a NaN. */jfloatsoft_cvtdf(jdouble v){ if (isnan(v)) return KAFFE_JFLOAT_NAN; else return (jfloat)v;}/* * The following functions round the float/double to an int/long. * They round the value toward zero. */jlongsoft_cvtfl(jfloat v){ if(isnan(v)) { return ((jlong)0); } if (v < 0.0) { v = ceil(v); } else { v = floor(v); } /* If too small return smallest long */ if (v <= -9223372036854775808.0) { return ((jlong)1) << 63; } /* If too big return biggest long */ else if (v >= 9223372036854775807.0) { return ~(((jlong)1) << 63); } else { return ((jlong)v); }}jlongsoft_cvtdl(jdouble v){ if (isnan(v)) { return ((jlong)0); } if (v < 0.0) { v = ceil(v); } else { v = floor(v); } /* If too small return smallest long */ if (v <= -9223372036854775808.0) { return ((jlong)1) << 63; } /* If too big return biggest long */ else if (v >= 9223372036854775807.0) { return ~(((jlong)1) << 63); } else { return ((jlong)v); }}jintsoft_cvtfi(jfloat v){ if (isnan(v)) { return (0); } if (v < 0.0) { v = ceil(v); } else { v = floor(v); } /* If too small return smallest int */ if (v <= -2147483648.0f) { return (-2147483647-1); } /* If too big return biggest int */ if (v >= 2147483647.0f) { return (2147483647); } return ((jint)v);}jintsoft_cvtdi(jdouble v){ if (isnan(v)) { return (0); } if (v < 0.0) { v = ceil(v); } else { v = floor(v); } /* If too small return smallest int */ if (v <= -2147483648.0) { return (-2147483647-1); } /* If too big return biggest int */ else if (v >= 2147483647.0) { return (2147483647); } else { return ((jint)v); }}voidsoft_debug1(void* a0 UNUSED, void* a1 UNUSED, void* a2 UNUSED){}voidsoft_debug2(void* a0 UNUSED, void* a1 UNUSED, void* a2 UNUSED){}voidsoft_trace(Method* meth, void* args UNUSED){ dprintf("soft_trace: %s.%s%s\n", CLASS_CNAME(meth->class), meth->name->data, METHOD_SIGD(meth));}#if defined(ENABLE_JVMPI)voidsoft_enter_method(Hjava_lang_Object *obj, Method *meth){ if( JVMPI_EVENT_ISENABLED(JVMPI_EVENT_METHOD_ENTRY) ) { JVMPI_Event ev; ev.event_type = JVMPI_EVENT_METHOD_ENTRY; ev.u.method.method_id = meth; jvmpiPostEvent(&ev); } if( JVMPI_EVENT_ISENABLED(JVMPI_EVENT_METHOD_ENTRY2) ) { JVMPI_Event ev; ev.event_type = JVMPI_EVENT_METHOD_ENTRY2; ev.u.method_entry2.method_id = meth; ev.u.method_entry2.obj_id = obj; jvmpiPostEvent(&ev); }}#elsevoidsoft_enter_method(Hjava_lang_Object *obj UNUSED, Method *meth UNUSED){}#endif#if defined(ENABLE_JVMPI)voidsoft_exit_method(Method *meth){ if( JVMPI_EVENT_ISENABLED(JVMPI_EVENT_METHOD_EXIT) ) { JVMPI_Event ev; ev.event_type = JVMPI_EVENT_METHOD_EXIT; ev.u.method.method_id = meth; jvmpiPostEvent(&ev); }}#elsevoidsoft_exit_method(Method *meth UNUSED){}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -