Implement binding pattern support for rest argument and for statement. (#3327)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2019-11-19 14:02:17 +01:00
committed by Dániel Bátyai
parent a7d129c8b2
commit bf630c0c54
9 changed files with 153 additions and 11 deletions
+9 -2
View File
@@ -1638,7 +1638,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
}
else if (context_p->token.type == LEXER_THREE_DOTS)
{
lexer_expect_identifier (context_p, LEXER_IDENT_LITERAL);
lexer_next_token (context_p);
if (duplicated_argument_names)
{
@@ -1647,7 +1647,8 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
context_p->status_flags |= PARSER_FUNCTION_HAS_REST_PARAM | PARSER_FUNCTION_HAS_NON_SIMPLE_PARAM;
}
else if (context_p->token.type == LEXER_LEFT_SQUARE || context_p->token.type == LEXER_LEFT_BRACE)
if (context_p->token.type == LEXER_LEFT_SQUARE || context_p->token.type == LEXER_LEFT_BRACE)
{
if (duplicated_argument_names)
{
@@ -1668,6 +1669,12 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
{
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_INITIALIZER);
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
parser_raise_error (context_p, PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER);
}
flags |= PARSER_PATTERN_TARGET_DEFAULT;
}