@@ -369,7 +369,8 @@ parser_parse_class_literal (parser_context_t *context_p) /**< context */
369369 parser_emit_cbc (context_p , CBC_CREATE_OBJECT );
370370
371371 bool super_called = false;
372- uint32_t status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE | (context_p -> status_flags & PARSER_CLASS_HAS_SUPER );
372+ uint32_t status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE ;
373+ status_flags |= (context_p -> status_flags & (PARSER_CLASS_HAS_SUPER | PARSER_CLASS_IMPLICIT_SUPER ));
373374
374375 while (true)
375376 {
@@ -480,9 +481,10 @@ parser_parse_class_literal (parser_context_t *context_p) /**< context */
480481 lexer_literal_t * literal_p = (lexer_literal_t * ) parser_list_append (context_p , & context_p -> literal_pool );
481482 literal_p -> type = LEXER_UNUSED_LITERAL ;
482483 literal_p -> status_flags = 0 ;
484+ uint16_t result_index = context_p -> literal_count ;
483485 literal_p -> u .bytecode_p = parser_parse_function (context_p , constructor_status_flags );
484486 literal_p -> type = LEXER_FUNCTION_LITERAL ;
485- parser_emit_cbc_literal (context_p , PARSER_TO_EXT_OPCODE (CBC_EXT_SET_CLASS_LITERAL ), context_p -> literal_count );
487+ parser_emit_cbc_literal (context_p , PARSER_TO_EXT_OPCODE (CBC_EXT_SET_CLASS_LITERAL ), result_index );
486488 context_p -> literal_count ++ ;
487489 continue ;
488490 }
@@ -560,8 +562,6 @@ parser_parse_class (parser_context_t *context_p, /**< context */
560562{
561563 JERRY_ASSERT (context_p -> token .type == LEXER_KEYW_CLASS );
562564
563- context_p -> status_flags &= (uint32_t ) ~PARSER_CLASS_HAS_SUPER ;
564-
565565 uint16_t class_ident_index = PARSER_MAXIMUM_NUMBER_OF_LITERALS ;
566566
567567 if (is_statement )
@@ -587,7 +587,10 @@ parser_parse_class (parser_context_t *context_p, /**< context */
587587 }
588588 }
589589
590- if (context_p -> token .type == LEXER_KEYW_EXTENDS )
590+ bool create_class_env = (bool ) (context_p -> token .type == LEXER_KEYW_EXTENDS
591+ || context_p -> status_flags & PARSER_CLASS_HAS_SUPER );
592+
593+ if (create_class_env )
591594 {
592595 parser_parse_super_class_context_start (context_p );
593596 }
@@ -620,10 +623,10 @@ parser_parse_class (parser_context_t *context_p, /**< context */
620623 parser_emit_cbc_literal (context_p , CBC_ASSIGN_SET_IDENT , class_ident_index );
621624 }
622625
623- if (context_p -> status_flags & PARSER_CLASS_HAS_SUPER )
626+ if (create_class_env )
624627 {
625628 parser_parse_super_class_context_end (context_p , is_statement );
626- context_p -> status_flags &= (uint32_t ) ~PARSER_CLASS_HAS_SUPER ;
629+ context_p -> status_flags &= (uint32_t ) ~( PARSER_CLASS_HAS_SUPER | PARSER_CLASS_IMPLICIT_SUPER ) ;
627630 }
628631
629632 parser_flush_cbc (context_p );
@@ -1371,7 +1374,14 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
13711374#ifndef CONFIG_DISABLE_ES2015_CLASS
13721375 if (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p -> status_flags ))
13731376 {
1374- parser_emit_cbc_ext (context_p , CBC_EXT_PUSH_CONSTRUCTOR_THIS );
1377+ if (context_p -> status_flags & PARSER_CLASS_IMPLICIT_SUPER )
1378+ {
1379+ parser_emit_cbc (context_p , CBC_PUSH_THIS );
1380+ }
1381+ else
1382+ {
1383+ parser_emit_cbc_ext (context_p , CBC_EXT_PUSH_CONSTRUCTOR_THIS );
1384+ }
13751385 }
13761386 else
13771387 {
@@ -1420,13 +1430,20 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
14201430 break ;
14211431 }
14221432
1433+ if (context_p -> status_flags & PARSER_CLASS_IMPLICIT_SUPER )
1434+ {
1435+ parser_emit_cbc_ext (context_p , CBC_EXT_PUSH_STATIC_SUPER );
1436+ break ;
1437+ }
1438+
14231439 bool is_static = (context_p -> status_flags & PARSER_CLASS_STATIC_FUNCTION ) != 0 ;
14241440 parser_emit_cbc_ext (context_p , is_static ? CBC_EXT_PUSH_STATIC_SUPER : CBC_EXT_PUSH_SUPER );
14251441 break ;
14261442 }
14271443
14281444 if (lexer_check_next_character (context_p , LIT_CHAR_LEFT_PAREN )
14291445 && (context_p -> status_flags & PARSER_CLASS_HAS_SUPER )
1446+ && !(context_p -> status_flags & PARSER_CLASS_IMPLICIT_SUPER )
14301447 && (context_p -> status_flags & (PARSER_IS_ARROW_FUNCTION | PARSER_CLASS_CONSTRUCTOR )))
14311448 {
14321449 parser_emit_cbc_ext (context_p , CBC_EXT_PUSH_CONSTRUCTOR_SUPER );
0 commit comments