Improve lexer_expect_object_literal_id option handling (#2436)

This patch allows to add further options flags to `lexer_expect_object_literal_id` to handle unique behaviors more easily
also substitutes `PARSER_IS_CLASS` flag hence it is removed.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2018-07-30 15:12:35 +02:00
committed by László Langó
parent 8482fef41a
commit a6ace5efdf
4 changed files with 23 additions and 15 deletions
+5 -7
View File
@@ -379,7 +379,7 @@ parser_parse_class_literal (parser_context_t *context_p, /**< context */
lexer_skip_empty_statements (context_p);
}
lexer_expect_object_literal_id (context_p, false);
lexer_expect_object_literal_id (context_p, LEXER_OBJ_IDENT_CLASS_METHOD);
if (context_p->token.type == LEXER_RIGHT_BRACE)
{
@@ -403,7 +403,7 @@ parser_parse_class_literal (parser_context_t *context_p, /**< context */
opcode = is_static ? CBC_EXT_SET_STATIC_SETTER : CBC_EXT_SET_SETTER;
}
lexer_expect_object_literal_id (context_p, true);
lexer_expect_object_literal_id (context_p, LEXER_OBJ_IDENT_CLASS_METHOD | LEXER_OBJ_IDENT_ONLY_IDENTIFIERS);
literal_index = context_p->lit_object.index;
if (!is_static && lexer_compare_raw_identifier_to_current (context_p, "constructor", 11))
@@ -556,7 +556,7 @@ parser_parse_class (parser_context_t *context_p, /**< context */
bool is_strict = context_p->status_flags & PARSER_IS_STRICT;
/* 14.5. A ClassBody is always strict code. */
context_p->status_flags |= PARSER_IS_STRICT | PARSER_IS_CLASS;
context_p->status_flags |= PARSER_IS_STRICT;
/* ClassDeclaration is parsed. Continue with class body. */
parser_parse_class_literal (context_p, constructor_literal_p);
@@ -586,8 +586,6 @@ parser_parse_class (parser_context_t *context_p, /**< context */
parser_flush_cbc (context_p);
context_p->status_flags &= (uint32_t) ~PARSER_IS_CLASS;
if (!is_strict)
{
/* Restore flag */
@@ -612,7 +610,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
while (true)
{
lexer_expect_object_literal_id (context_p, false);
lexer_expect_object_literal_id (context_p, LEXER_OBJ_IDENT_NO_OPTS);
if (context_p->token.type == LEXER_RIGHT_BRACE)
{
@@ -640,7 +638,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
item_type = PARSER_OBJECT_PROPERTY_SETTER;
}
lexer_expect_object_literal_id (context_p, true);
lexer_expect_object_literal_id (context_p, LEXER_OBJ_IDENT_ONLY_IDENTIFIERS);
literal_index = context_p->lit_object.index;
parser_append_object_literal_item (context_p, literal_index, item_type);