diff --git a/src/libjsparser/parser.c b/src/libjsparser/parser.c index 6840e2cbe..0c075ad16 100644 --- a/src/libjsparser/parser.c +++ b/src/libjsparser/parser.c @@ -761,6 +761,17 @@ rewrite_meta_opcode_counter (opcode_counter_t meta_oc, opcode_meta_type type) rewrite_meta_opcode_counter_set_oc (meta_oc, type, (opcode_counter_t) (OPCODE_COUNTER () - meta_oc)); } +static void +generate_tmp_for_left_arg (void) +{ + STACK_DECLARE_USAGE (IDX); + STACK_PUSH (IDX, next_temp_name ()); + DUMP_OPCODE_3 (assignment, ID(1), OPCODE_ARG_TYPE_VARIABLE, ID(2)); + STACK_SWAP (IDX); + STACK_DROP (IDX, 1); + STACK_CHECK_USAGE (IDX); +} + /* property_assignment : property_name_and_value | get LT!* property_name LT!* '(' LT!* ')' LT!* '{' LT!* function_body LT!* '}' @@ -1746,6 +1757,7 @@ parse_unary_expression (void) #define DUMP_OF(GETOP, EXPR) \ do { \ + generate_tmp_for_left_arg (); \ STACK_PUSH (IDX, next_temp_name ()); \ NEXT (EXPR);\ DUMP_OPCODE_3 (GETOP, ID(2), ID(3), ID(1)); \ @@ -2068,31 +2080,31 @@ parse_conditional_expression (void) skip_newlines (); if (token_is (TOK_QUERY)) { - DUMP_OPCODE_3 (is_true_jmp_down, ID(1), 0, 2); - STACK_PUSH (IDX, next_temp_name ()); + generate_tmp_for_left_arg (); STACK_PUSH (U16, OPCODE_COUNTER ()); - DUMP_OPCODE_2 (jmp_down, INVALID_VALUE, INVALID_VALUE); + DUMP_OPCODE_3 (is_false_jmp_down, ID(1), INVALID_VALUE, INVALID_VALUE); + STACK_PUSH (IDX, next_temp_name ()); NEXT (assignment_expression); DUMP_OPCODE_3 (assignment, ID(2), OPCODE_ARG_TYPE_VARIABLE, ID(1)); + STACK_DROP (IDX, 1); + STACK_SWAP (IDX); token_after_newlines_must_be (TOK_COLON); - REWRITE_JMP (STACK_TOP (U16), jmp_down, OPCODE_COUNTER () - STACK_TOP (U16)); - STACK_DROP (U16, 1); STACK_PUSH (U16, OPCODE_COUNTER ()); DUMP_OPCODE_2 (jmp_down, INVALID_VALUE, INVALID_VALUE); + REWRITE_COND_JMP (STACK_HEAD (U16, 2), is_false_jmp_down, OPCODE_COUNTER () - STACK_HEAD (U16, 2)); + STACK_DROP (IDX, 1); NEXT (assignment_expression); DUMP_OPCODE_3 (assignment, ID(2), OPCODE_ARG_TYPE_VARIABLE, ID(1)); REWRITE_JMP (STACK_TOP (U16), jmp_down, OPCODE_COUNTER () - STACK_TOP (U16)); STACK_DROP (U8, 1); - STACK_DROP (U16, 1); + STACK_DROP (U16, 2); STACK_PUSH (U8, 1); STACK_DROP (IDX, 1); - STACK_SWAP (IDX); - STACK_DROP (IDX, 1); } else { diff --git a/tests/jerry-test-suite/11/11.06/11.06.02/11.06.02-009.js b/tests/jerry-test-suite/11/11.06/11.06.02/11.06.02-009.js index 9e9914a7f..1d8041df3 100644 --- a/tests/jerry-test-suite/11/11.06/11.06.02/11.06.02-009.js +++ b/tests/jerry-test-suite/11/11.06/11.06.02/11.06.02-009.js @@ -13,4 +13,4 @@ // limitations under the License. var x = 0; -assert(x - (x = 1) !== -1) \ No newline at end of file +assert(x - (x = 1) === -1) \ No newline at end of file diff --git a/tests/jerry-test-suite/12/12.13/12.13-001.js b/tests/jerry-test-suite/12/12.13/12.13-001.js index 495bcccc2..f5c88ed15 100644 --- a/tests/jerry-test-suite/12/12.13/12.13-001.js +++ b/tests/jerry-test-suite/12/12.13/12.13-001.js @@ -19,9 +19,9 @@ function test() throw "error"; } } catch (e) { - return 0; + return 1; } - return 1; + return 0; } assert(test()); \ No newline at end of file diff --git a/tests/jerry-test-suite/12/12.13/12.13-003.js b/tests/jerry-test-suite/12/12.13/12.13-003.js index 6549821d6..b61eef364 100644 --- a/tests/jerry-test-suite/12/12.13/12.13-003.js +++ b/tests/jerry-test-suite/12/12.13/12.13-003.js @@ -30,9 +30,9 @@ function test() try { a(); } catch (e) { - return 0; + return 1; } - return 1; + return 0; } assert(test()); \ No newline at end of file diff --git a/tests/jerry-test-suite/12/12.14/12.14-001.js b/tests/jerry-test-suite/12/12.14/12.14-001.js index a8023845c..61c9103b4 100644 --- a/tests/jerry-test-suite/12/12.14/12.14-001.js +++ b/tests/jerry-test-suite/12/12.14/12.14-001.js @@ -18,7 +18,6 @@ try { } catch (e) { throw e; } + assert(false); } catch (e) { } - -assert(false); diff --git a/tests/jerry-test-suite/12/12.14/12.14-002.js b/tests/jerry-test-suite/12/12.14/12.14-002.js index 1643094af..815997ff0 100644 --- a/tests/jerry-test-suite/12/12.14/12.14-002.js +++ b/tests/jerry-test-suite/12/12.14/12.14-002.js @@ -17,10 +17,10 @@ function test() try { var x = 1; } catch (e) { - return 1; + return 0; } - return 0; + return 1; } -assert(test()); \ No newline at end of file +assert(test()); diff --git a/tests/jerry-test-suite/12/12.14/12.14-005.js b/tests/jerry-test-suite/12/12.14/12.14-005.js index 47aea7a8e..f6a3c218e 100644 --- a/tests/jerry-test-suite/12/12.14/12.14-005.js +++ b/tests/jerry-test-suite/12/12.14/12.14-005.js @@ -17,11 +17,11 @@ function test() try { throw "error"; } catch (e) { - return 0; + return 1; } finally { } - return 1; + return 0; } -assert(test()); \ No newline at end of file +assert(test()); diff --git a/tests/jerry-test-suite/12/12.14/12.14-006.js b/tests/jerry-test-suite/12/12.14/12.14-006.js index a914bb1e4..28931d6a7 100644 --- a/tests/jerry-test-suite/12/12.14/12.14-006.js +++ b/tests/jerry-test-suite/12/12.14/12.14-006.js @@ -17,10 +17,10 @@ function test() try { var x = 1; } finally { - return 0; + return 1; } - return 1; + return 0; } -assert(test()); \ No newline at end of file +assert(test());