Esempio n. 1
0
static void convert_ir_const_single(struct compilation_unit *cu, void *value, uint8_t type)
{
	uint64_t cp_infos[] = { (unsigned long) value };
	uint8_t cp_types[] = { type };

	convert_ir_const(cu, (void *)cp_infos, 8, cp_types);
}
Esempio n. 2
0
static void assert_convert_ldc_w_float(enum vm_type expected_type,
                                       double expected_value,
                                       uint8_t cp_type, unsigned long opcode)
{
    unsigned char code[] = { opcode, 0x01, 0x00 };
    uint32_t cp_infos[NR_CP_ENTRIES];
    uint8_t cp_types[NR_CP_ENTRIES];
    struct expression *expr;
    struct basic_block *bb;

    if (opcode == OPC_LDC_W)
        const_set_float(cp_infos, 0x100, (float) expected_value);
    else
        const_set_double(cp_infos, 0x100, expected_value);
    cp_types[0x100] = cp_type;

    bb = alloc_simple_bb(code, ARRAY_SIZE(code));
    convert_ir_const(bb->b_parent, cp_infos, NR_CP_ENTRIES, cp_types);

    expr = stack_pop(bb->mimic_stack);
    assert_fvalue_expr(expected_type, expected_value, &expr->node);
    assert_true(stack_is_empty(bb->mimic_stack));

    expr_put(expr);
    free_simple_bb(bb);
}
Esempio n. 3
0
static void assert_convert_ldc_float(float expected_value)
{
    unsigned char code[] = { OPC_LDC, 0xff };
    uint32_t cp_infos[NR_CP_ENTRIES];
    uint8_t cp_types[NR_CP_ENTRIES];
    struct expression *expr;
    struct basic_block *bb;

    const_set_float(cp_infos, 0xff, expected_value);
    cp_types[0xff] = CAFEBABE_CONSTANT_TAG_FLOAT;

    bb = alloc_simple_bb(code, ARRAY_SIZE(code));
    convert_ir_const(bb->b_parent, cp_infos, NR_CP_ENTRIES, cp_types);

    expr = stack_pop(bb->mimic_stack);
    assert_fvalue_expr(J_FLOAT, expected_value, &expr->node);
    assert_true(stack_is_empty(bb->mimic_stack));

    expr_put(expr);
    free_simple_bb(bb);
}
Esempio n. 4
0
static void assert_convert_ldc_w_string(enum vm_type expected_type, long long expected_value)
{
    unsigned char code[] = { OPC_LDC_W, 0x01, 0x00 };
    uint32_t cp_infos[NR_CP_ENTRIES];
    uint8_t cp_types[NR_CP_ENTRIES];
    struct basic_block *bb;
    struct expression *expr;

    const_set_int32_t(cp_infos, 0x100, 0x00);
    cp_types[0x100] = CAFEBABE_CONSTANT_TAG_STRING;

    bb = alloc_simple_bb(code, ARRAY_SIZE(code));
    convert_ir_const(bb->b_parent, cp_infos, NR_CP_ENTRIES, cp_types);

    expr = stack_pop(bb->mimic_stack);
    assert_value_expr(expected_type, expected_value, &expr->node);
    assert_true(stack_is_empty(bb->mimic_stack));

    expr_put(expr);
    free_simple_bb(bb);
}
Esempio n. 5
0
static void assert_convert_ldc(enum vm_type expected_type,
                               long long expected_value, uint8_t cp_type)
{
    uint32_t cp_infos[NR_CP_ENTRIES];
    uint8_t cp_types[NR_CP_ENTRIES];
    unsigned char code[] = { OPC_LDC, 0xff };
    struct expression *expr;
    struct basic_block *bb;

    const_set_int32_t(cp_infos, 0xff, expected_value);
    cp_types[0xff] = cp_type;

    bb = alloc_simple_bb(code, ARRAY_SIZE(code));
    convert_ir_const(bb->b_parent, cp_infos, NR_CP_ENTRIES, cp_types);

    expr = stack_pop(bb->mimic_stack);
    assert_value_expr(expected_type, expected_value, &expr->node);
    assert_true(stack_is_empty(bb->mimic_stack));

    expr_put(expr);
    free_simple_bb(bb);
}