@@ -364,6 +364,22 @@ parser_append_object_literal_item (parser_context_t *context_p, /**< context */
364364#error "Class support requires ES2015 object literal support"
365365#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
366366
367+ /**
368+ * Description of "get" literal string.
369+ */
370+ static const lexer_lit_location_t lexer_get_literal =
371+ {
372+ (const uint8_t * ) "get" , 3 , LEXER_STRING_LITERAL , false
373+ };
374+
375+ /**
376+ * Description of "set" literal string.
377+ */
378+ static const lexer_lit_location_t lexer_set_literal =
379+ {
380+ (const uint8_t * ) "set" , 3 , LEXER_STRING_LITERAL , false
381+ };
382+
367383/**
368384 * Parse class as an object literal.
369385 */
@@ -390,19 +406,30 @@ parser_parse_class_literal (parser_context_t *context_p) /**< context */
390406 break ;
391407 }
392408
409+ bool is_computed = false;
410+
393411 if (context_p -> token .type == LEXER_PROPERTY_GETTER || context_p -> token .type == LEXER_PROPERTY_SETTER )
394412 {
395413 uint16_t literal_index , function_literal_index ;
396414 bool is_getter = (context_p -> token .type == LEXER_PROPERTY_GETTER );
397415
416+ lexer_skip_empty_statements (context_p );
417+
418+ if (lexer_check_next_character (context_p , LIT_CHAR_LEFT_PAREN ))
419+ {
420+ lexer_construct_literal_object (context_p ,
421+ (is_getter ? (lexer_lit_location_t * ) & lexer_get_literal
422+ : (lexer_lit_location_t * ) & lexer_set_literal ),
423+ LEXER_STRING_LITERAL );
424+ goto parse_class_method ;
425+ }
426+
398427 uint32_t accessor_status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE ;
399428 accessor_status_flags |= (is_getter ? PARSER_IS_PROPERTY_GETTER : PARSER_IS_PROPERTY_SETTER );
400429
401430 lexer_expect_object_literal_id (context_p , LEXER_OBJ_IDENT_CLASS_METHOD | LEXER_OBJ_IDENT_ONLY_IDENTIFIERS );
402431 literal_index = context_p -> lit_object .index ;
403432
404- bool is_computed = false;
405-
406433 if (context_p -> token .type == LEXER_RIGHT_SQUARE )
407434 {
408435 is_computed = true;
@@ -499,8 +526,6 @@ parser_parse_class_literal (parser_context_t *context_p) /**< context */
499526 continue ;
500527 }
501528
502- bool is_computed = false;
503-
504529 if (context_p -> token .type == LEXER_RIGHT_SQUARE )
505530 {
506531 is_computed = true;
@@ -511,6 +536,7 @@ parser_parse_class_literal (parser_context_t *context_p) /**< context */
511536 parser_raise_error (context_p , PARSER_ERR_CLASS_STATIC_PROTOTYPE );
512537 }
513538
539+ parse_class_method :
514540 parser_flush_cbc (context_p );
515541
516542 uint16_t literal_index = context_p -> lit_object .index ;
0 commit comments