Exemplo n.º 1
0
static void testCall0ReturnLong(CuTest* tc) {
    CallInfo* ci = CALL0_ALLOCATE_CALL_INFO(NULL, testCall0ReturnLong_target, 0, 0, 1, 0, 0);
    CuAssertPtrNotNull(tc, ci);
    call0AddLong(ci, 0xdeadbeef);
    jlong (*f)(CallInfo*) = (jlong (*)(CallInfo*)) _call0;
    jlong result = f(ci);
    CuAssertTrue(tc, result == 0xdeadbeef00LL);
}
Exemplo n.º 2
0
static void testCall0OneArgOfEach(CuTest* tc) {
    CallInfo* ci = CALL0_ALLOCATE_CALL_INFO(NULL, testCall0OneArgOfEach_target, 1, 1, 1, 1, 1);
    CuAssertPtrNotNull(tc, ci);
    call0AddPtr(ci, testCall0OneArgOfEach_target);
    call0AddInt(ci, -100);
    call0AddLong(ci, 0xfedcba9876543210LL);
    call0AddFloat(ci, 3.14f);
    call0AddDouble(ci, -3.14);
    jlong (*f)(CallInfo*) = (jlong (*)(CallInfo*)) _call0;
    jlong result = f(ci);
    CuAssertTrue(tc, result == 0x0123456789abcdefLL);
}
Exemplo n.º 3
0
static void testCall0ManyArgsOfEach(CuTest* tc) {
    CallInfo* ci = CALL0_ALLOCATE_CALL_INFO(NULL, testCall0ManyArgsOfEach_target, 8, 8, 8, 8, 8);
    CuAssertPtrNotNull(tc, ci);
    call0AddPtr(ci, testCall0ManyArgsOfEach_target + 0xcab1);
    call0AddInt(ci, -100);
    call0AddLong(ci, 0xfedcba9876543211LL);
    call0AddFloat(ci, 3.11f);
    call0AddDouble(ci, -3.11);
    call0AddPtr(ci, testCall0ManyArgsOfEach_target + 0xcab2);
    call0AddInt(ci, -200);
    call0AddLong(ci, 0xfedcba9876543212LL);
    call0AddFloat(ci, 3.12f);
    call0AddDouble(ci, -3.12);
    call0AddPtr(ci, testCall0ManyArgsOfEach_target + 0xcab3);
    call0AddInt(ci, -300);
    call0AddLong(ci, 0xfedcba9876543213LL);
    call0AddFloat(ci, 3.13f);
    call0AddDouble(ci, -3.13);
    call0AddPtr(ci, testCall0ManyArgsOfEach_target + 0xcab4);
    call0AddInt(ci, -400);
    call0AddLong(ci, 0xfedcba9876543214LL);
    call0AddFloat(ci, 3.14f);
    call0AddDouble(ci, -3.14);
    call0AddPtr(ci, testCall0ManyArgsOfEach_target + 0xcab5);
    call0AddInt(ci, -500);
    call0AddLong(ci, 0xfedcba9876543215LL);
    call0AddFloat(ci, 3.15f);
    call0AddDouble(ci, -3.15);
    call0AddPtr(ci, testCall0ManyArgsOfEach_target + 0xcab6);
    call0AddInt(ci, -600);
    call0AddLong(ci, 0xfedcba9876543216LL);
    call0AddFloat(ci, 3.16f);
    call0AddDouble(ci, -3.16);
    call0AddPtr(ci, testCall0ManyArgsOfEach_target + 0xcab7);
    call0AddInt(ci, -700);
    call0AddLong(ci, 0xfedcba9876543217LL);
    call0AddFloat(ci, 3.17f);
    call0AddDouble(ci, -3.17);
    call0AddPtr(ci, testCall0ManyArgsOfEach_target + 0xcab8);
    call0AddInt(ci, -800);
    call0AddLong(ci, 0xfedcba9876543218LL);
    call0AddFloat(ci, 3.18f);
    call0AddDouble(ci, -3.18);

    jint (*f)(CallInfo*) = (jint (*)(CallInfo*)) _call0;
    jint result = f(ci);
    CuAssertIntEquals(tc, 1, result);
}
Exemplo n.º 4
0
static void setArgs(Env* env, Object* obj, Method* method, CallInfo* callInfo, jvalue* args) {
    call0AddPtr(callInfo, env);
    if (!(method->access & ACC_STATIC)) {
        call0AddPtr(callInfo, obj);
    }    

    const char* desc = method->desc;
    const char* c;
    jint i = 0;
    while ((c = rvmGetNextParameterType(&desc))) {
        switch (c[0]) {
        case 'Z':
            call0AddInt(callInfo, (jint) args[i++].z);
            break;
        case 'B':
            call0AddInt(callInfo, (jint) args[i++].b);
            break;
        case 'S':
            call0AddInt(callInfo, (jint) args[i++].s);
            break;
        case 'C':
            call0AddInt(callInfo, (jint) args[i++].c);
            break;
        case 'I':
            call0AddInt(callInfo, args[i++].i);
            break;
        case 'J':
            call0AddLong(callInfo, args[i++].j);
            break;
        case 'F':
            call0AddFloat(callInfo, args[i++].f);
            break;
        case 'D':
            call0AddDouble(callInfo, args[i++].d);
            break;
        case 'L':
        case '[':
            call0AddPtr(callInfo, args[i++].l);
            break;
        }
    }
}