From dc095bb9022a756b51de1bfb9e4ebef136a4c7f8 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Sun, 28 Jun 2015 17:42:19 +0300 Subject: [PATCH] Enhancement of argument list parsing loop: removing break / continue operators, so that every iteration passes start and end of loop body. The change makes possible simple notification of byte-code generator about start / end of byte-code generation for an argument. As register values are not passed between byte-code sequences that prepare different arguments, the change would make possible for byte-code generator to reuse registers allocated for the code sequences. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com --- jerry-core/parser/js/parser.cpp | 87 ++++++++++++++++----------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/jerry-core/parser/js/parser.cpp b/jerry-core/parser/js/parser.cpp index 6b1307745..d4527b37e 100644 --- a/jerry-core/parser/js/parser.cpp +++ b/jerry-core/parser/js/parser.cpp @@ -522,61 +522,56 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera while (!token_is (close_tt)) { operand op; - switch (vlt) - { - case VARG_FUNC_DECL: - case VARG_FUNC_EXPR: - { - current_token_must_be (TOK_NAME); - op = literal_operand (token_data_as_lit_cp ()); - syntax_add_varg (op); - syntax_check_for_eval_and_arguments_in_strict_mode (op, is_strict_mode (), tok.loc); - break; - } - case VARG_ARRAY_DECL: - { - if (token_is (TOK_COMMA)) - { - op = dump_undefined_assignment_res (); - dump_varg (op); - args_num++; - skip_newlines (); - continue; - } - /* FALLTHRU */ - } - case VARG_CONSTRUCT_EXPR: - { - op = parse_assignment_expression (true); - break; - } - case VARG_CALL_EXPR: - { - op = parse_assignment_expression (true); - break; - } - case VARG_OBJ_DECL: - { - parse_property_assignment (); - break; - } - } - /* In case of obj_decl prop is already dumped. */ - if (vlt != VARG_OBJ_DECL) + if (vlt == VARG_FUNC_DECL + || vlt == VARG_FUNC_EXPR) { + current_token_must_be (TOK_NAME); + op = literal_operand (token_data_as_lit_cp ()); + syntax_add_varg (op); + syntax_check_for_eval_and_arguments_in_strict_mode (op, is_strict_mode (), tok.loc); dump_varg (op); + skip_newlines (); } - args_num++; + else if (vlt == VARG_CONSTRUCT_EXPR + || vlt == VARG_CALL_EXPR) + { + op = parse_assignment_expression (true); + dump_varg (op); + skip_newlines (); + } + else if (vlt == VARG_ARRAY_DECL) + { + if (token_is (TOK_COMMA)) + { + op = dump_undefined_assignment_res (); + dump_varg (op); + } + else + { + op = parse_assignment_expression (true); + dump_varg (op); + skip_newlines (); + } + } + else + { + JERRY_ASSERT (vlt == VARG_OBJ_DECL); - skip_newlines (); - if (!token_is (TOK_COMMA)) + parse_property_assignment (); + skip_newlines (); + } + + if (token_is (TOK_COMMA)) + { + skip_newlines (); + } + else { current_token_must_be (close_tt); - break; } - skip_newlines (); + args_num++; } if (args_count != NULL)