@@ -364,7 +364,8 @@ parser_parse_class_literal (parser_context_t *context_p) /**< context */
364364 parser_emit_cbc (context_p , CBC_CREATE_OBJECT );
365365
366366 bool super_called = false;
367- uint32_t status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE | (context_p -> status_flags & PARSER_CLASS_HAS_SUPER );
367+ uint32_t status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE ;
368+ status_flags |= context_p -> status_flags & (PARSER_CLASS_HAS_SUPER | PARSER_CLASS_IMPLICIT_SUPER );
368369
369370 while (true)
370371 {
@@ -475,9 +476,10 @@ parser_parse_class_literal (parser_context_t *context_p) /**< context */
475476 lexer_literal_t * literal_p = (lexer_literal_t * ) parser_list_append (context_p , & context_p -> literal_pool );
476477 literal_p -> type = LEXER_UNUSED_LITERAL ;
477478 literal_p -> status_flags = 0 ;
479+ uint16_t result_index = context_p -> literal_count ;
478480 literal_p -> u .bytecode_p = parser_parse_function (context_p , constructor_status_flags );
479481 literal_p -> type = LEXER_FUNCTION_LITERAL ;
480- parser_emit_cbc_literal (context_p , PARSER_TO_EXT_OPCODE (CBC_EXT_SET_CLASS_LITERAL ), context_p -> literal_count );
482+ parser_emit_cbc_literal (context_p , PARSER_TO_EXT_OPCODE (CBC_EXT_SET_CLASS_LITERAL ), result_index );
481483 context_p -> literal_count ++ ;
482484 continue ;
483485 }
@@ -555,8 +557,6 @@ parser_parse_class (parser_context_t *context_p, /**< context */
555557{
556558 JERRY_ASSERT (context_p -> token .type == LEXER_KEYW_CLASS );
557559
558- context_p -> status_flags &= (uint32_t ) ~PARSER_CLASS_HAS_SUPER ;
559-
560560 uint16_t class_ident_index = PARSER_MAXIMUM_NUMBER_OF_LITERALS ;
561561
562562 if (is_statement )
@@ -582,7 +582,10 @@ parser_parse_class (parser_context_t *context_p, /**< context */
582582 }
583583 }
584584
585- if (context_p -> token .type == LEXER_KEYW_EXTENDS )
585+ bool create_class_env = (context_p -> token .type == LEXER_KEYW_EXTENDS
586+ || (context_p -> status_flags & PARSER_CLASS_HAS_SUPER ));
587+
588+ if (create_class_env )
586589 {
587590 parser_parse_super_class_context_start (context_p );
588591 }
@@ -615,10 +618,10 @@ parser_parse_class (parser_context_t *context_p, /**< context */
615618 parser_emit_cbc_literal (context_p , CBC_ASSIGN_SET_IDENT , class_ident_index );
616619 }
617620
618- if (context_p -> status_flags & PARSER_CLASS_HAS_SUPER )
621+ if (create_class_env )
619622 {
620623 parser_parse_super_class_context_end (context_p , is_statement );
621- context_p -> status_flags &= (uint32_t ) ~PARSER_CLASS_HAS_SUPER ;
624+ context_p -> status_flags &= (uint32_t ) ~( PARSER_CLASS_HAS_SUPER | PARSER_CLASS_IMPLICIT_SUPER ) ;
622625 }
623626
624627 parser_flush_cbc (context_p );
@@ -1366,7 +1369,14 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
13661369#ifndef CONFIG_DISABLE_ES2015_CLASS
13671370 if (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p -> status_flags ))
13681371 {
1369- parser_emit_cbc_ext (context_p , CBC_EXT_PUSH_CONSTRUCTOR_THIS );
1372+ if (context_p -> status_flags & PARSER_CLASS_IMPLICIT_SUPER )
1373+ {
1374+ parser_emit_cbc (context_p , CBC_PUSH_THIS );
1375+ }
1376+ else
1377+ {
1378+ parser_emit_cbc_ext (context_p , CBC_EXT_PUSH_CONSTRUCTOR_THIS );
1379+ }
13701380 }
13711381 else
13721382 {
@@ -1415,13 +1425,20 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
14151425 break ;
14161426 }
14171427
1428+ if (context_p -> status_flags & PARSER_CLASS_IMPLICIT_SUPER )
1429+ {
1430+ parser_emit_cbc_ext (context_p , CBC_EXT_PUSH_STATIC_SUPER );
1431+ break ;
1432+ }
1433+
14181434 bool is_static = (context_p -> status_flags & PARSER_CLASS_STATIC_FUNCTION ) != 0 ;
14191435 parser_emit_cbc_ext (context_p , is_static ? CBC_EXT_PUSH_STATIC_SUPER : CBC_EXT_PUSH_SUPER );
14201436 break ;
14211437 }
14221438
14231439 if (lexer_check_next_character (context_p , LIT_CHAR_LEFT_PAREN )
14241440 && (context_p -> status_flags & PARSER_CLASS_HAS_SUPER )
1441+ && !(context_p -> status_flags & PARSER_CLASS_IMPLICIT_SUPER )
14251442 && (context_p -> status_flags & (PARSER_IS_ARROW_FUNCTION | PARSER_CLASS_CONSTRUCTOR )))
14261443 {
14271444 parser_emit_cbc_ext (context_p , CBC_EXT_PUSH_CONSTRUCTOR_SUPER );
0 commit comments