From 2718d8e9186c5c2c94ba13de32fb75cb98594a2d Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Wed, 23 Jul 2014 22:22:50 +0400 Subject: [PATCH] Fixing is_false_jmp, is_true_jmp opcodes; adding them to var_decl and assignment unit tests as partial checks. --- src/libcoreint/opcodes.c | 16 ++++++++++------ tests/unit/test_assignment_opcode.c | 18 +++++++++++------- .../test_var_decl_opcode_in_decl_lex_env.c | 4 +++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index 203044bf7..1737468cd 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -410,8 +410,6 @@ opfunc_is_true_jmp (OPCODE opdata, /**< operation data */ const T_IDX cond_var_idx = opdata.data.is_true_jmp.value; const T_IDX dst_opcode_idx = opdata.data.is_true_jmp.opcode; - int_data->pos = dst_opcode_idx; - ecma_completion_value_t ret_value; TRY_CATCH(cond_value, get_variable_value( int_data, cond_var_idx, false), ret_value); @@ -421,7 +419,11 @@ opfunc_is_true_jmp (OPCODE opdata, /**< operation data */ if ( ecma_is_value_true( to_bool_completion.value) ) { - int_data->pos = opdata.data.jmp.opcode_idx; + int_data->pos = dst_opcode_idx; + } + else + { + int_data->pos++; } ret_value = ecma_make_empty_completion_value(); @@ -445,8 +447,6 @@ opfunc_is_false_jmp (OPCODE opdata, /**< operation data */ const T_IDX cond_var_idx = opdata.data.is_false_jmp.value; const T_IDX dst_opcode_idx = opdata.data.is_false_jmp.opcode; - int_data->pos = dst_opcode_idx; - ecma_completion_value_t ret_value; TRY_CATCH(cond_value, get_variable_value( int_data, cond_var_idx, false), ret_value); @@ -456,7 +456,11 @@ opfunc_is_false_jmp (OPCODE opdata, /**< operation data */ if ( !ecma_is_value_true( to_bool_completion.value) ) { - int_data->pos = opdata.data.jmp.opcode_idx; + int_data->pos = dst_opcode_idx; + } + else + { + int_data->pos++; } ret_value = ecma_make_empty_completion_value(); diff --git a/tests/unit/test_assignment_opcode.c b/tests/unit/test_assignment_opcode.c index 0d12e410e..8b4ef8292 100644 --- a/tests/unit/test_assignment_opcode.c +++ b/tests/unit/test_assignment_opcode.c @@ -26,13 +26,17 @@ main( int __unused argc, char __unused **argv) { const OPCODE test_program[] = { - getop_var_decl( 0), - getop_var_decl( 1), - getop_assignment( 0, OPCODE_ARG_TYPE_STRING, 1), - getop_assignment( 1, OPCODE_ARG_TYPE_VARIABLE, 0), - getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), - getop_assignment( 1, OPCODE_ARG_TYPE_NUMBER, 2), - getop_exitval( 0) + /* 0: */ getop_var_decl( 0), + /* 1: */ getop_var_decl( 1), + /* 2: */ getop_assignment( 0, OPCODE_ARG_TYPE_STRING, 1), + /* 3: */ getop_assignment( 1, OPCODE_ARG_TYPE_VARIABLE, 0), + /* 4: */ getop_is_true_jmp( 1, 6), + /* 5: */ getop_jmp_down( 5), + /* 6: */ getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), + /* 7: */ getop_assignment( 1, OPCODE_ARG_TYPE_NUMBER, 2), + /* 8: */ getop_is_false_jmp( 1, 10), + /* 9: */ getop_exitval( 0), + /* 10: */ getop_exitval( 1) }; mem_init(); diff --git a/tests/unit/test_var_decl_opcode_in_decl_lex_env.c b/tests/unit/test_var_decl_opcode_in_decl_lex_env.c index ceedd75d4..d6164c131 100644 --- a/tests/unit/test_var_decl_opcode_in_decl_lex_env.c +++ b/tests/unit/test_var_decl_opcode_in_decl_lex_env.c @@ -27,7 +27,9 @@ main( int __unused argc, { const OPCODE test_program[] = { getop_var_decl( 0), - getop_exitval( 0) + getop_is_true_jmp( 0, 3), + getop_exitval( 0), + getop_exitval( 1) }; mem_init();