Support get/set function declarations in classes in the pre-scanner. (#3098)
Fixes #3094 Fixes #3095 Fixes #3096 JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
committed by
Robert Fancsik
parent
fc30f003ba
commit
57de923770
@@ -2457,7 +2457,8 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
|
||||
|| context_p->token.type == LEXER_LEFT_SQUARE
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|| context_p->token.type == LEXER_RIGHT_BRACE
|
||||
|| context_p->token.type == LEXER_SEMICOLON)
|
||||
|| context_p->token.type == LEXER_SEMICOLON
|
||||
|| ((ident_opts & LEXER_SCAN_CLASS_LEFT_PAREN) && context_p->token.type == LEXER_LEFT_PAREN))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -265,6 +265,7 @@ typedef enum
|
||||
LEXER_SCAN_IDENT_NO_KEYW = (1u << 2), /**< don't scan keywords (e.g. get/set) */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
LEXER_SCAN_CLASS_PROPERTY = (1u << 3), /**< scan valid class property names */
|
||||
LEXER_SCAN_CLASS_LEFT_PAREN = (1u << 4), /**< also parse left parenthesis */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
} lexer_scan_ident_opts_t;
|
||||
|
||||
|
||||
@@ -1390,13 +1390,19 @@ scanner_scan_all (parser_context_t *context_p) /**< context */
|
||||
lexer_scan_identifier (context_p, LEXER_SCAN_CLASS_PROPERTY);
|
||||
}
|
||||
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_CLASS_FUNCTION);
|
||||
scanner_context.mode = SCAN_MODE_FUNCTION_ARGUMENTS;
|
||||
|
||||
if (lexer_compare_literal_to_identifier (context_p, "get", 3)
|
||||
|| lexer_compare_literal_to_identifier (context_p, "set", 3))
|
||||
{
|
||||
lexer_scan_identifier (context_p, LEXER_SCAN_CLASS_PROPERTY);
|
||||
}
|
||||
lexer_scan_identifier (context_p, LEXER_SCAN_CLASS_PROPERTY | LEXER_SCAN_CLASS_LEFT_PAREN);
|
||||
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_CLASS_FUNCTION);
|
||||
if (context_p->token.type == LEXER_LEFT_PAREN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_LEFT_SQUARE)
|
||||
@@ -1408,7 +1414,6 @@ scanner_scan_all (parser_context_t *context_p) /**< context */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
scanner_context.mode = SCAN_MODE_FUNCTION_ARGUMENTS;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
Reference in New Issue
Block a user