From cc4d55803cc13fac67d8a85569d8d7b4895b07ed Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Thu, 7 Aug 2014 19:35:11 +0400 Subject: [PATCH] Fix func_decl_0: correctly set interpreter's opcode counter. --- src/libcoreint/interpreter.c | 9 +++++++++ src/libcoreint/interpreter.h | 2 ++ src/libcoreint/opcodes.c | 5 +++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libcoreint/interpreter.c b/src/libcoreint/interpreter.c index 023d31ad5..2aac550c2 100644 --- a/src/libcoreint/interpreter.c +++ b/src/libcoreint/interpreter.c @@ -205,3 +205,12 @@ get_number_by_idx(T_IDX idx) /**< literal id */ return num; } /* get_number_by_idx */ + +/** + * Get specified opcode from the program. + */ +OPCODE +read_opcode(opcode_counter_t counter) /**< opcode counter */ +{ + return __program[ counter ]; +} /* read_opcode */ diff --git a/src/libcoreint/interpreter.h b/src/libcoreint/interpreter.h index c1d22f544..53962f821 100644 --- a/src/libcoreint/interpreter.h +++ b/src/libcoreint/interpreter.h @@ -43,5 +43,7 @@ ecma_completion_value_t run_int_from_pos (opcode_counter_t start_pos, ssize_t try_get_string_by_idx( T_IDX idx, ecma_char_t *buffer_p, ssize_t buffer_size); ecma_number_t get_number_by_idx(T_IDX idx); +OPCODE read_opcode(opcode_counter_t counter); + #endif /* INTERPRETER_H */ diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index 202184021..05150e38b 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -1338,8 +1338,9 @@ opfunc_func_decl_0(OPCODE opdata, /**< operation data */ TODO( Iterate vargs ); const opcode_counter_t jmp_down_opcode_idx = (opcode_counter_t) (int_data->pos); - - TODO( ASSERT( Current opcode is jmp_down ) ); + OPCODE jmp_down_opcode = read_opcode( jmp_down_opcode_idx ); + JERRY_ASSERT( jmp_down_opcode.op_idx == __op__idx_jmp_down ); + int_data->pos = (opcode_counter_t) ( jmp_down_opcode_idx + jmp_down_opcode.data.jmp_down.opcode_count ); const opcode_counter_t function_code_opcode_idx = (opcode_counter_t) (jmp_down_opcode_idx + 1);