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:
committed by
Dániel Bátyai
parent
a7d129c8b2
commit
bf630c0c54
@@ -496,8 +496,7 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
while (true)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (lexer_check_next_character (context_p, LIT_CHAR_LEFT_BRACE)
|
||||
|| lexer_check_next_character (context_p, LIT_CHAR_LEFT_SQUARE))
|
||||
if (lexer_check_next_characters (context_p, LIT_CHAR_LEFT_SQUARE, LIT_CHAR_LEFT_BRACE))
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
parser_pattern_flags_t options = PARSER_PATTERN_BINDING;
|
||||
@@ -1199,14 +1198,40 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case LEXER_KEYW_VAR:
|
||||
{
|
||||
uint16_t literal_index;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (lexer_check_next_characters (context_p, LIT_CHAR_LEFT_SQUARE, LIT_CHAR_LEFT_BRACE))
|
||||
{
|
||||
bool is_lexical = (context_p->token.type != LEXER_KEYW_VAR);
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT
|
||||
: CBC_EXT_FOR_OF_GET_NEXT);
|
||||
|
||||
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);
|
||||
|
||||
scanner_release_next (context_p, sizeof (scanner_location_info_t));
|
||||
}
|
||||
|
||||
uint32_t flags = (PARSER_PATTERN_BINDING | PARSER_PATTERN_TARGET_ON_STACK);
|
||||
|
||||
if (is_lexical)
|
||||
{
|
||||
flags |= PARSER_PATTERN_LEXICAL;
|
||||
}
|
||||
|
||||
parser_parse_initializer (context_p, (parser_pattern_flags_t) flags);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
lexer_expect_identifier (context_p, LEXER_IDENT_LITERAL);
|
||||
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
|
||||
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
|
||||
|
||||
literal_index = context_p->lit_object.index;
|
||||
|
||||
uint16_t literal_index = context_p->lit_object.index;
|
||||
lexer_next_token (context_p);
|
||||
|
||||
if (context_p->token.type == LEXER_ASSIGN)
|
||||
|
||||
Reference in New Issue
Block a user