@@ -2251,9 +2251,9 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
22512251 */
22522252static uint8_t
22532253parser_append_binary_single_assignment_token (parser_context_t * context_p , /**< context */
2254- bool is_lexical ) /**< assign lexical declaration */
2254+ uint32_t pattern_flags ) /**< pattern flags */
22552255{
2256- JERRY_UNUSED (is_lexical );
2256+ JERRY_UNUSED (pattern_flags );
22572257
22582258 /* Unlike other tokens, the whole byte code is saved for binary
22592259 * assignment, since it has multiple forms depending on the
@@ -2301,7 +2301,7 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**<
23012301 assign_opcode = CBC_ASSIGN_SET_IDENT ;
23022302
23032303#if ENABLED (JERRY_ES2015 )
2304- if (!is_lexical )
2304+ if (!( pattern_flags & ( PARSER_PATTERN_LET | PARSER_PATTERN_CONST | PARSER_PATTERN_LOCAL )) )
23052305 {
23062306 if (scanner_literal_is_const_reg (context_p , literal_index ))
23072307 {
@@ -2310,7 +2310,20 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**<
23102310 }
23112311 else if (literal_index < PARSER_REGISTER_START )
23122312 {
2313- assign_opcode = CBC_ASSIGN_LET_CONST ;
2313+ assign_opcode = CBC_INIT_LET ;
2314+
2315+ if (scanner_literal_is_created (context_p , literal_index ))
2316+ {
2317+ assign_opcode = CBC_ASSIGN_LET_CONST ;
2318+ }
2319+ else if (pattern_flags & PARSER_PATTERN_CONST )
2320+ {
2321+ assign_opcode = CBC_INIT_CONST ;
2322+ }
2323+ else if (pattern_flags & PARSER_PATTERN_LOCAL )
2324+ {
2325+ assign_opcode = CBC_INIT_ARG_OR_CATCH ;
2326+ }
23142327 }
23152328#endif /* ENABLED (JERRY_ES2015) */
23162329
@@ -2395,7 +2408,7 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */
23952408
23962409 if (context_p -> token .type == LEXER_ASSIGN )
23972410 {
2398- parser_append_binary_single_assignment_token (context_p , false );
2411+ parser_append_binary_single_assignment_token (context_p , 0 );
23992412 return ;
24002413 }
24012414
@@ -2486,7 +2499,10 @@ parser_process_binary_opcodes (parser_context_t *context_p, /**< context */
24862499 JERRY_ASSERT (opcode == CBC_ASSIGN_SET_IDENT
24872500 || opcode == CBC_ASSIGN_PROP_LITERAL
24882501 || opcode == CBC_ASSIGN_PROP_THIS_LITERAL
2489- || opcode == CBC_ASSIGN_LET_CONST );
2502+ || opcode == CBC_ASSIGN_LET_CONST
2503+ || opcode == CBC_INIT_ARG_OR_CATCH
2504+ || opcode == CBC_INIT_LET
2505+ || opcode == CBC_INIT_CONST );
24902506
24912507 index = parser_stack_pop_uint16 (context_p );
24922508 }
@@ -2601,7 +2617,7 @@ parser_pattern_get_target (parser_context_t *context_p, /**< context */
26012617 {
26022618 JERRY_ASSERT (flags & PARSER_PATTERN_TARGET_ON_STACK );
26032619
2604- parser_emit_cbc_forward_branch (context_p , PARSER_TO_EXT_OPCODE ( CBC_EXT_DEFAULT_INITIALIZER ) , & skip_init );
2620+ parser_emit_cbc_ext_forward_branch (context_p , CBC_EXT_DEFAULT_INITIALIZER , & skip_init );
26052621 }
26062622
26072623 if ((flags & (PARSER_PATTERN_TARGET_ON_STACK | PARSER_PATTERN_TARGET_DEFAULT )) != PARSER_PATTERN_TARGET_ON_STACK )
@@ -2707,8 +2723,7 @@ parser_pattern_form_assignment (parser_context_t *context_p, /**< context */
27072723 JERRY_UNUSED (ident_line_counter );
27082724
27092725 parser_stack_push_uint8 (context_p , LEXER_EXPRESSION_START );
2710- bool is_lexical = (flags & (PARSER_PATTERN_LEXICAL | PARSER_PATTERN_LOCAL )) != 0 ;
2711- uint8_t assign_opcode = parser_append_binary_single_assignment_token (context_p , is_lexical );
2726+ uint8_t assign_opcode = parser_append_binary_single_assignment_token (context_p , flags );
27122727
27132728 if (flags & PARSER_PATTERN_ARRAY )
27142729 {
@@ -2724,7 +2739,7 @@ parser_pattern_form_assignment (parser_context_t *context_p, /**< context */
27242739 {
27252740 parser_branch_t skip_init ;
27262741 lexer_next_token (context_p );
2727- parser_emit_cbc_forward_branch (context_p , PARSER_TO_EXT_OPCODE ( CBC_EXT_DEFAULT_INITIALIZER ) , & skip_init );
2742+ parser_emit_cbc_ext_forward_branch (context_p , CBC_EXT_DEFAULT_INITIALIZER , & skip_init );
27282743
27292744 parser_parse_expression (context_p , PARSE_EXPR_NO_COMMA );
27302745 parser_set_branch_to_current_position (context_p , & skip_init );
@@ -2770,7 +2785,8 @@ parser_pattern_process_nested_pattern (parser_context_t *context_p, /**< context
27702785 parser_pattern_flags_t options = (PARSER_PATTERN_NESTED_PATTERN
27712786 | PARSER_PATTERN_TARGET_ON_STACK
27722787 | (flags & (PARSER_PATTERN_BINDING
2773- | PARSER_PATTERN_LEXICAL
2788+ | PARSER_PATTERN_LET
2789+ | PARSER_PATTERN_CONST
27742790 | PARSER_PATTERN_LOCAL
27752791 | PARSER_PATTERN_REST_ELEMENT
27762792 | PARSER_PATTERN_ARGUMENTS )));
@@ -2821,7 +2837,7 @@ parser_pattern_process_assignment (parser_context_t *context_p, /**< context */
28212837
28222838 lexer_construct_literal_object (context_p , & context_p -> token .lit_location , LEXER_IDENT_LITERAL );
28232839
2824- if (flags & PARSER_PATTERN_LEXICAL
2840+ if (flags & ( PARSER_PATTERN_LET | PARSER_PATTERN_CONST )
28252841 && context_p -> token .keyword_type == LEXER_KEYW_LET )
28262842 {
28272843 parser_raise_error (context_p , PARSER_ERR_LEXICAL_LET_BINDING );
0 commit comments