Revise ES2015 feature guards (#3240)
All the basic language element guards are merged into JERRY_ES2015 macro guard. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
59e0d6e262
commit
3b73562fa5
@@ -64,19 +64,19 @@
|
||||
|
||||
#define CBC_HAS_POP_STACK_BYTE_ARG (CBC_HAS_BYTE_ARG | CBC_POP_STACK_BYTE_ARG)
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Checks whether the current opcode is a super constructor call
|
||||
*/
|
||||
#define CBC_SUPER_CALL_OPERATION(opcode) \
|
||||
((opcode) >= PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_CALL) \
|
||||
&& (opcode) <= PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_CALL_BLOCK))
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
/**
|
||||
* Checks whether the current opcode is a super constructor call
|
||||
*/
|
||||
#define CBC_SUPER_CALL_OPERATION(opcode) false
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Debug macro. */
|
||||
#define CBC_ARGS_EQ(op, types) \
|
||||
|
||||
@@ -311,7 +311,7 @@ lexer_skip_spaces (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* lexer_skip_spaces */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Skip all the continuous empty statements.
|
||||
*/
|
||||
@@ -329,7 +329,7 @@ lexer_skip_empty_statements (parser_context_t *context_p) /**< context */
|
||||
|
||||
context_p->token.flags = (uint8_t) (context_p->token.flags | LEXER_NO_SKIP_SPACES);
|
||||
} /* lexer_skip_empty_statements */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Keyword data.
|
||||
@@ -661,12 +661,12 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
size_t length = 0;
|
||||
uint8_t has_escape = false;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (str_end_character == LIT_CHAR_RIGHT_BRACE)
|
||||
{
|
||||
str_end_character = LIT_CHAR_GRAVE_ACCENT;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -809,7 +809,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT &&
|
||||
source_p[0] == LIT_CHAR_DOLLAR_SIGN &&
|
||||
source_p + 1 < source_end_p &&
|
||||
@@ -818,7 +818,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
source_p++;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (*source_p >= LEXER_UTF8_4BYTE_START)
|
||||
{
|
||||
@@ -837,7 +837,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
/* Subtract -1 because column is increased below. */
|
||||
column--;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT)
|
||||
{
|
||||
/* Newline (without backslash) is part of the string. */
|
||||
@@ -872,7 +872,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
else if (*source_p == LIT_CHAR_CR
|
||||
|| *source_p == LIT_CHAR_LF
|
||||
|| (*source_p == LEXER_NEWLINE_LS_PS_BYTE_1 && LEXER_NEWLINE_LS_PS_BYTE_23 (source_p)))
|
||||
@@ -899,12 +899,12 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_STRING_TOO_LONG);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
context_p->token.type = ((str_end_character != LIT_CHAR_GRAVE_ACCENT) ? LEXER_LITERAL
|
||||
: LEXER_TEMPLATE_LITERAL);
|
||||
#else /* !ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
context_p->token.type = LEXER_LITERAL;
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Fill literal data. */
|
||||
context_p->token.lit_location.char_p = string_start_p;
|
||||
@@ -1188,7 +1188,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (length >= 3
|
||||
&& context_p->source_p[1] == LIT_CHAR_DOT
|
||||
&& context_p->source_p[2] == LIT_CHAR_DOT)
|
||||
@@ -1197,7 +1197,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
length = 3;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
context_p->token.type = LEXER_DOT;
|
||||
length = 1;
|
||||
@@ -1301,14 +1301,14 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->source_p[1] == (uint8_t) LIT_CHAR_GREATER_THAN)
|
||||
{
|
||||
context_p->token.type = LEXER_ARROW;
|
||||
length = 2;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
|
||||
context_p->token.type = LEXER_ASSIGN;
|
||||
@@ -1363,9 +1363,9 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
|
||||
case LIT_CHAR_SINGLE_QUOTE:
|
||||
case LIT_CHAR_DOUBLE_QUOTE:
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case LIT_CHAR_GRAVE_ACCENT:
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
{
|
||||
lexer_parse_string (context_p);
|
||||
return;
|
||||
@@ -1406,7 +1406,7 @@ lexer_check_next_character (parser_context_t *context_p, /**< context */
|
||||
&& context_p->source_p[0] == (uint8_t) character);
|
||||
} /* lexer_check_next_character */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|
||||
/**
|
||||
* Checks whether the next token is a type used for detecting arrow functions.
|
||||
@@ -1428,7 +1428,7 @@ lexer_check_arrow (parser_context_t *context_p) /**< context */
|
||||
&& context_p->source_p[1] == (uint8_t) LIT_CHAR_GREATER_THAN);
|
||||
} /* lexer_check_arrow */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Search or append the string to the literal pool.
|
||||
@@ -1604,12 +1604,12 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
uint8_t str_end_character = source_p[-1];
|
||||
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (str_end_character == LIT_CHAR_RIGHT_BRACE)
|
||||
{
|
||||
str_end_character = LIT_CHAR_GRAVE_ACCENT;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -1745,7 +1745,7 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT
|
||||
&& source_p[0] == LIT_CHAR_DOLLAR_SIGN
|
||||
&& source_p[1] == LIT_CHAR_LEFT_BRACE)
|
||||
@@ -1754,7 +1754,7 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
|
||||
JERRY_ASSERT (source_p < context_p->source_end_p);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (*source_p >= LEXER_UTF8_4BYTE_START)
|
||||
{
|
||||
@@ -2033,7 +2033,7 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
|
||||
result_index = context_p->literal_count;
|
||||
context_p->literal_count++;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (!(extra_status_flags & PARSER_IS_ARROW_FUNCTION))
|
||||
{
|
||||
compiled_code_p = parser_parse_function (context_p, extra_status_flags);
|
||||
@@ -2042,9 +2042,9 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
compiled_code_p = parser_parse_arrow_function (context_p, extra_status_flags);
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
compiled_code_p = parser_parse_function (context_p, extra_status_flags);
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
literal_p->u.bytecode_p = compiled_code_p;
|
||||
literal_p->type = LEXER_FUNCTION_LITERAL;
|
||||
@@ -2326,7 +2326,7 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
|
||||
context_p->status_flags &= (uint32_t) ~(PARSER_MODULE_DEFAULT_CLASS_OR_FUNC);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_EXPECTED);
|
||||
} /* lexer_expect_identifier */
|
||||
@@ -2340,11 +2340,11 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
lexer_skip_spaces (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
int is_class_method = ((ident_opts & LEXER_OBJ_IDENT_CLASS_METHOD)
|
||||
&& !(ident_opts & LEXER_OBJ_IDENT_ONLY_IDENTIFIERS)
|
||||
&& (context_p->token.type != LEXER_KEYW_STATIC));
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
context_p->token.line = context_p->line;
|
||||
context_p->token.column = context_p->column;
|
||||
@@ -2364,10 +2364,10 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
context_p->token.flags = (uint8_t) (context_p->token.flags | LEXER_NO_SKIP_SPACES);
|
||||
|
||||
if (context_p->source_p < context_p->source_end_p
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
&& context_p->source_p[0] != LIT_CHAR_COMMA
|
||||
&& context_p->source_p[0] != LIT_CHAR_RIGHT_BRACE
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
&& context_p->source_p[0] != LIT_CHAR_COLON)
|
||||
{
|
||||
if (lexer_compare_literal_to_string (context_p, "get", 3))
|
||||
@@ -2383,13 +2383,13 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (is_class_method && lexer_compare_literal_to_string (context_p, "static", 6))
|
||||
{
|
||||
context_p->token.type = LEXER_KEYW_STATIC;
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
create_literal_object = true;
|
||||
}
|
||||
@@ -2399,7 +2399,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
lexer_parse_string (context_p);
|
||||
create_literal_object = true;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
else if (context_p->source_p[0] == LIT_CHAR_LEFT_SQUARE)
|
||||
{
|
||||
context_p->source_p += 1;
|
||||
@@ -2414,7 +2414,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
else if (!(ident_opts & LEXER_OBJ_IDENT_ONLY_IDENTIFIERS) && context_p->source_p[0] == LIT_CHAR_RIGHT_BRACE)
|
||||
{
|
||||
context_p->token.type = LEXER_RIGHT_BRACE;
|
||||
@@ -2443,13 +2443,13 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (create_literal_object)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (is_class_method && lexer_compare_literal_to_string (context_p, "constructor", 11))
|
||||
{
|
||||
context_p->token.type = LEXER_CLASS_CONSTRUCTOR;
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
lexer_construct_literal_object (context_p,
|
||||
&context_p->token.lit_location,
|
||||
@@ -2485,10 +2485,10 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
|
||||
context_p->token.flags = (uint8_t) (context_p->token.flags | LEXER_NO_SKIP_SPACES);
|
||||
|
||||
if (context_p->source_p < context_p->source_end_p
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
&& context_p->source_p[0] != LIT_CHAR_COMMA
|
||||
&& context_p->source_p[0] != LIT_CHAR_RIGHT_BRACE
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
&& context_p->source_p[0] != LIT_CHAR_COLON)
|
||||
{
|
||||
if (lexer_compare_literal_to_string (context_p, "get", 3))
|
||||
@@ -2509,23 +2509,23 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
|
||||
lexer_next_token (context_p);
|
||||
|
||||
if (context_p->token.type == LEXER_LITERAL
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|| context_p->token.type == LEXER_LEFT_SQUARE
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|| context_p->token.type == LEXER_RIGHT_BRACE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (ident_opts & LEXER_SCAN_CLASS_PROPERTY)
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
|
||||
if (context_p->token.type == LEXER_LITERAL
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|| context_p->token.type == LEXER_LEFT_SQUARE
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|| context_p->token.type == LEXER_RIGHT_BRACE
|
||||
|| context_p->token.type == LEXER_SEMICOLON
|
||||
|| ((ident_opts & LEXER_SCAN_CLASS_LEFT_PAREN) && context_p->token.type == LEXER_LEFT_PAREN))
|
||||
@@ -2533,7 +2533,7 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_EXPECTED);
|
||||
} /* lexer_scan_identifier */
|
||||
|
||||
@@ -39,12 +39,10 @@ typedef enum
|
||||
LEXER_LIT_TRUE, /**< true (not a keyword!) */
|
||||
LEXER_LIT_FALSE, /**< false (not a keyword!) */
|
||||
LEXER_LIT_NULL, /**< null (not a keyword!) */
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
LEXER_TEMPLATE_LITERAL, /**< multi segment template literal */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
LEXER_THREE_DOTS, /**< ... (rest or spread operator) */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Unary operators
|
||||
* IMPORTANT: update CBC_UNARY_OP_TOKEN_TO_OPCODE and
|
||||
@@ -121,9 +119,9 @@ typedef enum
|
||||
LEXER_SEMICOLON, /**< ";" */
|
||||
LEXER_COLON, /**< ":" */
|
||||
LEXER_COMMA, /**< "," */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
LEXER_ARROW, /**< "=>" */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
LEXER_KEYW_BREAK, /**< break */
|
||||
LEXER_KEYW_DO, /**< do */
|
||||
@@ -153,10 +151,10 @@ typedef enum
|
||||
LEXER_COMMA_SEP_LIST, /**< comma separated bracketed expression list */
|
||||
LEXER_SCAN_SWITCH, /**< special value for switch pre-scan */
|
||||
LEXER_CLASS_CONSTRUCTOR, /**< special value for class constructor method */
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
LEXER_FOR_IN_OF, /**< special value during for in/of statmenet scanning */
|
||||
LEXER_LITERAL_OF, /**< 'of' literal */
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
/* Future reserved words: these keywords
|
||||
@@ -263,10 +261,10 @@ typedef enum
|
||||
LEXER_SCAN_IDENT_NO_OPTS = (1u << 0), /**< no options */
|
||||
LEXER_SCAN_IDENT_PROPERTY = (1u << 1), /**< scan valid property names */
|
||||
LEXER_SCAN_IDENT_NO_KEYW = (1u << 2), /**< don't scan keywords (e.g. get/set) */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
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) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
} lexer_scan_ident_opts_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -256,7 +256,7 @@ parser_parse_array_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* parser_parse_array_literal */
|
||||
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Object literal item types.
|
||||
*/
|
||||
@@ -353,14 +353,9 @@ parser_append_object_literal_item (parser_context_t *context_p, /**< context */
|
||||
context_p->stack_top_uint8 = PARSER_OBJECT_PROPERTY_BOTH_ACCESSORS;
|
||||
}
|
||||
} /* parser_append_object_literal_item */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#error "Class support requires ES2015 object literal support"
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Description of "get" literal string.
|
||||
*/
|
||||
@@ -676,9 +671,9 @@ parser_parse_class (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_parse_class */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Parse object initializer method definition.
|
||||
*
|
||||
@@ -700,7 +695,7 @@ parser_parse_object_method (parser_context_t *context_p) /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_parse_object_method */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Parse object literal.
|
||||
@@ -712,9 +707,9 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_emit_cbc (context_p, CBC_CREATE_OBJECT);
|
||||
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
parser_stack_push_uint8 (context_p, PARSER_OBJECT_PROPERTY_START);
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -732,25 +727,25 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
uint32_t status_flags;
|
||||
cbc_ext_opcode_t opcode;
|
||||
uint16_t literal_index, function_literal_index;
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
parser_object_literal_item_types_t item_type;
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type == LEXER_PROPERTY_GETTER)
|
||||
{
|
||||
status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE | PARSER_IS_PROPERTY_GETTER;
|
||||
opcode = CBC_EXT_SET_GETTER;
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
item_type = PARSER_OBJECT_PROPERTY_GETTER;
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
else
|
||||
{
|
||||
status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE | PARSER_IS_PROPERTY_SETTER;
|
||||
opcode = CBC_EXT_SET_SETTER;
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
item_type = PARSER_OBJECT_PROPERTY_SETTER;
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
|
||||
lexer_expect_object_literal_id (context_p, LEXER_OBJ_IDENT_ONLY_IDENTIFIERS);
|
||||
@@ -758,25 +753,25 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
/* This assignment is a nop for computed getters/setters. */
|
||||
literal_index = context_p->lit_object.index;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_RIGHT_SQUARE)
|
||||
{
|
||||
opcode = ((opcode == CBC_EXT_SET_GETTER) ? CBC_EXT_SET_COMPUTED_GETTER
|
||||
: CBC_EXT_SET_COMPUTED_SETTER);
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
parser_append_object_literal_item (context_p, literal_index, item_type);
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
parser_flush_cbc (context_p);
|
||||
function_literal_index = lexer_construct_function_object (context_p, status_flags);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (opcode >= CBC_EXT_SET_COMPUTED_GETTER)
|
||||
{
|
||||
literal_index = function_literal_index;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
parser_emit_cbc_literal (context_p,
|
||||
CBC_PUSH_LITERAL,
|
||||
@@ -789,7 +784,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case LEXER_RIGHT_SQUARE:
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
@@ -821,23 +816,23 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
default:
|
||||
{
|
||||
uint16_t literal_index = context_p->lit_object.index;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
parser_line_counter_t start_line = context_p->token.line;
|
||||
parser_line_counter_t start_column = context_p->token.column;
|
||||
#else /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
parser_append_object_literal_item (context_p,
|
||||
literal_index,
|
||||
PARSER_OBJECT_PROPERTY_VALUE);
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_LEFT_PAREN)
|
||||
{
|
||||
parser_parse_object_method (context_p);
|
||||
@@ -876,7 +871,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type != LEXER_COLON)
|
||||
{
|
||||
@@ -910,14 +905,14 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
while (context_p->stack_top_uint8 != PARSER_OBJECT_PROPERTY_START)
|
||||
{
|
||||
parser_stack_pop (context_p, NULL, 3);
|
||||
}
|
||||
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
} /* parser_parse_object_literal */
|
||||
|
||||
/**
|
||||
@@ -1030,7 +1025,7 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
|
||||
context_p->last_cbc.literal_object_type = LEXER_LITERAL_OBJECT_ANY;
|
||||
} /* parser_parse_function_expression */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|
||||
/**
|
||||
* Parse template literal.
|
||||
@@ -1134,7 +1129,7 @@ parser_parse_template_literal (parser_context_t *context_p) /**< context */
|
||||
return;
|
||||
} /* parser_parse_template_literal */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Parse and record unary operators, and parse the primary literal.
|
||||
@@ -1163,13 +1158,13 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
* they are processed when their closing paren is reached. */
|
||||
if (context_p->token.type == LEXER_LEFT_PAREN)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
|
||||
{
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
(*grouping_level_p)++;
|
||||
new_was_seen = 0;
|
||||
}
|
||||
@@ -1190,7 +1185,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
/* Parse primary expression. */
|
||||
switch (context_p->token.type)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case LEXER_TEMPLATE_LITERAL:
|
||||
{
|
||||
if (context_p->source_p[-1] != LIT_CHAR_GRAVE_ACCENT)
|
||||
@@ -1202,10 +1197,10 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
/* The string is a normal string literal. */
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case LEXER_LITERAL:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
|
||||
{
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
|
||||
@@ -1214,7 +1209,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
PARSER_IS_FUNCTION | PARSER_IS_ARROW_FUNCTION);
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
uint8_t type = context_p->token.lit_location.type;
|
||||
|
||||
@@ -1332,7 +1327,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
case LEXER_KEYW_THIS:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags))
|
||||
{
|
||||
if (context_p->status_flags & PARSER_CLASS_IMPLICIT_SUPER)
|
||||
@@ -1346,11 +1341,11 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
parser_emit_cbc (context_p, CBC_PUSH_THIS);
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
break;
|
||||
}
|
||||
case LEXER_LIT_TRUE:
|
||||
@@ -1368,7 +1363,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
parser_emit_cbc (context_p, CBC_PUSH_NULL);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_parse_class (context_p, false);
|
||||
@@ -1412,8 +1407,6 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_raise_error (context_p, PARSER_ERR_UNEXPECTED_SUPER_REFERENCE);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
case LEXER_LEFT_PAREN:
|
||||
{
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->source_p == context_p->source_p
|
||||
@@ -1424,7 +1417,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
PARSER_IS_FUNCTION | PARSER_IS_ARROW_FUNCTION | PARSER_ARROW_PARSE_ARGS);
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
default:
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_PRIMARY_EXP_EXPECTED);
|
||||
@@ -1441,15 +1434,15 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
static void
|
||||
parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* Track to see if a property was accessed or not */
|
||||
bool property_accessed = false;
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Parse postfix part of a primary expression. */
|
||||
while (true)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_DOT || context_p->token.type == LEXER_LEFT_SQUARE)
|
||||
{
|
||||
if (property_accessed)
|
||||
@@ -1464,7 +1457,7 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
property_accessed = true;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Since break would only break the switch, we use
|
||||
* continue to continue this loop. Without continue,
|
||||
@@ -1550,12 +1543,12 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
||||
opcode = CBC_CALL_PROP;
|
||||
context_p->last_cbc_opcode = PARSER_PUSH_PROP_TO_PUSH_PROP_REFERENCE (context_p->last_cbc_opcode);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
else if (context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_CONSTRUCTOR_SUPER))
|
||||
{
|
||||
opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_CALL);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
else if (JERRY_UNLIKELY ((context_p->status_flags & (PARSER_INSIDE_WITH | PARSER_RESOLVE_BASE_FOR_CALLS))
|
||||
&& PARSER_IS_PUSH_LITERAL (context_p->last_cbc_opcode)
|
||||
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL))
|
||||
@@ -1596,7 +1589,7 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
||||
|
||||
if (is_eval)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->status_flags & PARSER_CLASS_HAS_SUPER)
|
||||
{
|
||||
parser_flush_cbc (context_p);
|
||||
@@ -1605,20 +1598,20 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
parser_emit_cbc (context_p, CBC_EVAL);
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if ((context_p->status_flags & PARSER_CLASS_SUPER_PROP_REFERENCE) && opcode == CBC_CALL_PROP)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_SUPER_PROP_CALL);
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_CLASS_SUPER_PROP_REFERENCE;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (call_arguments <= 1)
|
||||
{
|
||||
@@ -1802,14 +1795,14 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */
|
||||
parser_stack_push_uint16 (context_p, context_p->last_cbc.literal_index);
|
||||
parser_stack_push_uint8 (context_p, CBC_ASSIGN_PROP_LITERAL);
|
||||
context_p->last_cbc_opcode = PARSER_CBC_UNAVAILABLE;
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->status_flags & PARSER_CLASS_SUPER_PROP_REFERENCE)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_SUPER_PROP_ASSIGN);
|
||||
parser_flush_cbc (context_p);
|
||||
}
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_CLASS_SUPER_PROP_REFERENCE;
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2126,7 +2119,7 @@ parser_parse_expression (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_stack_push_uint8 (context_p, LEXER_EXPRESSION_START);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* Parsing a new expression:
|
||||
* So save, remove, and at the end restore the super prop reference indicator.
|
||||
*
|
||||
@@ -2213,13 +2206,13 @@ process_unary_expression:
|
||||
parser_push_result (context_p);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* Restore the super prop ref flag. */
|
||||
if (has_super_ref)
|
||||
{
|
||||
context_p->status_flags |= (uint32_t) PARSER_CLASS_SUPER_PROP_REFERENCE;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
} /* parser_parse_expression */
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,29 +48,25 @@ typedef enum
|
||||
PARSER_IS_FUNC_EXPRESSION = (1u << 3), /**< a function expression is parsed */
|
||||
PARSER_IS_PROPERTY_GETTER = (1u << 4), /**< a property getter function is parsed */
|
||||
PARSER_IS_PROPERTY_SETTER = (1u << 5), /**< a property setter function is parsed */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
PARSER_FUNCTION_HAS_REST_PARAM = (1u << 6), /**< function has rest parameter */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
PARSER_HAS_NON_STRICT_ARG = (1u << 7), /**< the function has arguments which
|
||||
PARSER_HAS_NON_STRICT_ARG = (1u << 6), /**< the function has arguments which
|
||||
* are not supported in strict mode */
|
||||
PARSER_ARGUMENTS_NEEDED = (1u << 8), /**< arguments object must be created */
|
||||
PARSER_ARGUMENTS_NOT_NEEDED = (1u << 9), /**< arguments object must NOT be created */
|
||||
PARSER_LEXICAL_ENV_NEEDED = (1u << 10), /**< lexical environment object must be created */
|
||||
PARSER_INSIDE_WITH = (1u << 12), /**< code block is inside a with statement */
|
||||
PARSER_RESOLVE_BASE_FOR_CALLS = (1u << 13), /**< the this object must be resolved when
|
||||
PARSER_ARGUMENTS_NEEDED = (1u << 7), /**< arguments object must be created */
|
||||
PARSER_ARGUMENTS_NOT_NEEDED = (1u << 8), /**< arguments object must NOT be created */
|
||||
PARSER_LEXICAL_ENV_NEEDED = (1u << 9), /**< lexical environment object must be created */
|
||||
PARSER_INSIDE_WITH = (1u << 10), /**< code block is inside a with statement */
|
||||
PARSER_RESOLVE_BASE_FOR_CALLS = (1u << 11), /**< the this object must be resolved when
|
||||
* a function without a base object is called */
|
||||
PARSER_HAS_INITIALIZED_VARS = (1u << 14), /**< a CBC_INITIALIZE_VARS instruction must be emitted */
|
||||
PARSER_HAS_LATE_LIT_INIT = (1u << 15), /**< allocate memory for this string after
|
||||
PARSER_HAS_INITIALIZED_VARS = (1u << 12), /**< a CBC_INITIALIZE_VARS instruction must be emitted */
|
||||
PARSER_HAS_LATE_LIT_INIT = (1u << 13), /**< allocate memory for this string after
|
||||
* the local parser data is freed */
|
||||
PARSER_NO_END_LABEL = (1u << 16), /**< return instruction must be inserted
|
||||
PARSER_NO_END_LABEL = (1u << 14), /**< return instruction must be inserted
|
||||
* after the last byte code */
|
||||
PARSER_DEBUGGER_BREAKPOINT_APPENDED = (1u << 17), /**< pending (unsent) breakpoint
|
||||
PARSER_DEBUGGER_BREAKPOINT_APPENDED = (1u << 15), /**< pending (unsent) breakpoint
|
||||
* info is available */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
PARSER_FUNCTION_HAS_REST_PARAM = (1u << 16), /**< function has rest parameter */
|
||||
PARSER_IS_ARROW_FUNCTION = (1u << 18), /**< an arrow function is parsed */
|
||||
PARSER_ARROW_PARSE_ARGS = (1u << 19), /**< parse the argument list of an arrow function */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
/* These four status flags must be in this order. See PARSER_CLASS_PARSE_OPTS_OFFSET. */
|
||||
PARSER_CLASS_CONSTRUCTOR = (1u << 20), /**< a class constructor is parsed (this value must be kept in
|
||||
* in sync with ECMA_PARSE_CLASS_CONSTRUCTOR) */
|
||||
@@ -78,7 +74,7 @@ typedef enum
|
||||
PARSER_CLASS_IMPLICIT_SUPER = (1u << 22), /**< class has implicit parent class */
|
||||
PARSER_CLASS_STATIC_FUNCTION = (1u << 23), /**< this function is a static class method */
|
||||
PARSER_CLASS_SUPER_PROP_REFERENCE = (1u << 24), /**< super property call or assignment */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
PARSER_MODULE_DEFAULT_CLASS_OR_FUNC = (1u << 25), /**< parsing a function or class default export */
|
||||
PARSER_MODULE_STORE_IDENT = (1u << 26), /**< store identifier of the current export statement */
|
||||
@@ -106,7 +102,7 @@ typedef enum
|
||||
*/
|
||||
#define PARSER_STRICT_MODE_MASK 0x1
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Offset between PARSER_CLASS_CONSTRUCTOR and ECMA_PARSE_CLASS_CONSTRUCTOR
|
||||
*/
|
||||
@@ -147,7 +143,7 @@ typedef enum
|
||||
*/
|
||||
#define PARSER_IS_CLASS_CONSTRUCTOR_SUPER(flag) \
|
||||
(((flag) & PARSER_CLASS_CONSTRUCTOR_SUPER) == PARSER_CLASS_CONSTRUCTOR_SUPER)
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* The maximum of PARSER_CBC_STREAM_PAGE_SIZE is 127. */
|
||||
#define PARSER_CBC_STREAM_PAGE_SIZE \
|
||||
@@ -572,12 +568,10 @@ void parser_set_continues_to_current_position (parser_context_t *context_p, pars
|
||||
|
||||
void lexer_next_token (parser_context_t *context_p);
|
||||
bool lexer_check_next_character (parser_context_t *context_p, lit_utf8_byte_t character);
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
void lexer_skip_empty_statements (parser_context_t *context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
bool lexer_check_arrow (parser_context_t *context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
void lexer_parse_string (parser_context_t *context_p);
|
||||
void lexer_expect_identifier (parser_context_t *context_p, uint8_t literal_type);
|
||||
void lexer_scan_identifier (parser_context_t *context_p, uint32_t ident_opts);
|
||||
@@ -608,11 +602,11 @@ uint8_t lexer_convert_binary_lvalue_token_to_binary (uint8_t token);
|
||||
void parser_parse_block_expression (parser_context_t *context_p, int options);
|
||||
void parser_parse_expression_statement (parser_context_t *context_p, int options);
|
||||
void parser_parse_expression (parser_context_t *context_p, int options);
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
void parser_parse_class (parser_context_t *context_p, bool is_statement);
|
||||
void parser_parse_super_class_context_start (parser_context_t *context_p);
|
||||
void parser_parse_super_class_context_end (parser_context_t *context_p, bool is_statement);
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -686,9 +680,9 @@ void parser_module_add_names_to_node (parser_context_t *context_p,
|
||||
*/
|
||||
|
||||
ecma_compiled_code_t *parser_parse_function (parser_context_t *context_p, uint32_t status_flags);
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ecma_compiled_code_t *parser_parse_arrow_function (parser_context_t *context_p, uint32_t status_flags);
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Error management. */
|
||||
|
||||
|
||||
@@ -21,13 +21,6 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if !ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
|
||||
#error "For of support requires ES2015 iterator support"
|
||||
#endif /* !ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
*
|
||||
@@ -78,9 +71,9 @@ typedef enum
|
||||
* Break and continue uses another instruction form
|
||||
* when crosses their borders. */
|
||||
PARSER_STATEMENT_FOR_IN,
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
PARSER_STATEMENT_FOR_OF,
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
PARSER_STATEMENT_WITH,
|
||||
PARSER_STATEMENT_TRY,
|
||||
} parser_statement_type_t;
|
||||
@@ -217,10 +210,10 @@ parser_statement_length (uint8_t type) /**< type of statement */
|
||||
(uint8_t) (sizeof (parser_for_statement_t) + sizeof (parser_loop_statement_t) + 1),
|
||||
/* PARSER_STATEMENT_FOR_IN */
|
||||
(uint8_t) (sizeof (parser_for_in_of_statement_t) + sizeof (parser_loop_statement_t) + 1),
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* PARSER_STATEMENT_FOR_OF */
|
||||
(uint8_t) (sizeof (parser_for_in_of_statement_t) + sizeof (parser_loop_statement_t) + 1),
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
/* PARSER_STATEMENT_WITH */
|
||||
(uint8_t) (sizeof (parser_with_statement_t) + 1),
|
||||
/* PARSER_STATEMENT_TRY */
|
||||
@@ -579,7 +572,7 @@ parser_parse_with_statement_end (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* parser_parse_with_statement_end */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Parse super class context like a with statement (starting part).
|
||||
*/
|
||||
@@ -648,7 +641,7 @@ parser_parse_super_class_context_end (parser_context_t *context_p, /**< context
|
||||
|
||||
parser_set_branch_to_current_position (context_p, &with_statement.branch);
|
||||
} /* parser_parse_super_class_context_end */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Parse do-while statement (ending part).
|
||||
@@ -887,16 +880,16 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
parser_for_in_of_statement_t for_in_of_statement;
|
||||
scanner_location_t start_location, end_location;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN
|
||||
|| context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_OF);
|
||||
|
||||
bool is_for_in = (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN);
|
||||
#else /* !ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN);
|
||||
|
||||
bool is_for_in = true;
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
scanner_get_location (&start_location, context_p);
|
||||
scanner_set_location (context_p, &((scanner_location_info_t *) context_p->next_scanner_info_p)->location);
|
||||
@@ -986,11 +979,11 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
|
||||
if (context_p->token.type != LEXER_EOS)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
parser_raise_error (context_p, is_for_in ? PARSER_ERR_IN_EXPECTED : PARSER_ERR_OF_EXPECTED);
|
||||
#else /* !ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
parser_raise_error (context_p, PARSER_ERR_IN_EXPECTED);
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
|
||||
parser_flush_cbc (context_p);
|
||||
@@ -1002,12 +995,12 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_stack_push (context_p, &for_in_of_statement, sizeof (parser_for_in_of_statement_t));
|
||||
parser_stack_push (context_p, &loop, sizeof (parser_loop_statement_t));
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
parser_stack_push_uint8 (context_p, is_for_in ? PARSER_STATEMENT_FOR_IN
|
||||
: PARSER_STATEMENT_FOR_OF);
|
||||
#else /* !ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_FOR_IN);
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
parser_stack_iterator_init (context_p, &context_p->last_statement);
|
||||
return;
|
||||
}
|
||||
@@ -1588,9 +1581,9 @@ parser_parse_break_statement (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
|
||||
if (type == PARSER_STATEMENT_FOR_IN
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|| type == PARSER_STATEMENT_FOR_OF
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|| type == PARSER_STATEMENT_WITH
|
||||
|| type == PARSER_STATEMENT_TRY)
|
||||
{
|
||||
@@ -1632,9 +1625,9 @@ parser_parse_break_statement (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
|
||||
if (type == PARSER_STATEMENT_FOR_IN
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|| type == PARSER_STATEMENT_FOR_OF
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|| type == PARSER_STATEMENT_WITH
|
||||
|| type == PARSER_STATEMENT_TRY)
|
||||
{
|
||||
@@ -1646,9 +1639,9 @@ parser_parse_break_statement (parser_context_t *context_p) /**< context */
|
||||
|| type == PARSER_STATEMENT_DO_WHILE
|
||||
|| type == PARSER_STATEMENT_WHILE
|
||||
|| type == PARSER_STATEMENT_FOR
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|| type == PARSER_STATEMENT_FOR_OF
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|| type == PARSER_STATEMENT_FOR_IN)
|
||||
{
|
||||
parser_loop_statement_t loop;
|
||||
@@ -1723,11 +1716,11 @@ parser_parse_continue_statement (parser_context_t *context_p) /**< context */
|
||||
continue;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
bool is_for_in_of_statement = (type == PARSER_STATEMENT_FOR_IN) || (type == PARSER_STATEMENT_FOR_OF);
|
||||
#else /* !ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
bool is_for_in_of_statement = (type == PARSER_STATEMENT_FOR_IN);
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (type == PARSER_STATEMENT_WITH
|
||||
|| type == PARSER_STATEMENT_TRY
|
||||
@@ -1743,9 +1736,9 @@ parser_parse_continue_statement (parser_context_t *context_p) /**< context */
|
||||
if (type == PARSER_STATEMENT_DO_WHILE
|
||||
|| type == PARSER_STATEMENT_WHILE
|
||||
|| type == PARSER_STATEMENT_FOR
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|| type == PARSER_STATEMENT_FOR_OF
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|| type == PARSER_STATEMENT_FOR_IN)
|
||||
{
|
||||
loop_iterator = iterator;
|
||||
@@ -1771,9 +1764,9 @@ parser_parse_continue_statement (parser_context_t *context_p) /**< context */
|
||||
if (type == PARSER_STATEMENT_DO_WHILE
|
||||
|| type == PARSER_STATEMENT_WHILE
|
||||
|| type == PARSER_STATEMENT_FOR
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|| type == PARSER_STATEMENT_FOR_OF
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|| type == PARSER_STATEMENT_FOR_IN)
|
||||
{
|
||||
parser_loop_statement_t loop;
|
||||
@@ -2296,9 +2289,9 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
|| context_p->stack_top_uint8 == PARSER_STATEMENT_WHILE
|
||||
|| context_p->stack_top_uint8 == PARSER_STATEMENT_FOR
|
||||
|| context_p->stack_top_uint8 == PARSER_STATEMENT_FOR_IN
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|| context_p->stack_top_uint8 == PARSER_STATEMENT_FOR_OF
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|| context_p->stack_top_uint8 == PARSER_STATEMENT_WITH)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_STATEMENT_EXPECTED);
|
||||
@@ -2320,13 +2313,13 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_parse_class (context_p, true);
|
||||
goto consume_last_statement;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
case LEXER_KEYW_IMPORT:
|
||||
@@ -2472,7 +2465,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
|| context_p->token.type == LEXER_SEMICOLON
|
||||
|| context_p->token.type == LEXER_RIGHT_BRACE)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (JERRY_UNLIKELY (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags)))
|
||||
{
|
||||
if (context_p->status_flags & PARSER_CLASS_IMPLICIT_SUPER)
|
||||
@@ -2487,20 +2480,20 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
parser_emit_cbc (context_p, CBC_RETURN_WITH_BLOCK);
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
break;
|
||||
}
|
||||
|
||||
parser_parse_expression (context_p, PARSE_EXPR);
|
||||
|
||||
bool return_with_literal = (context_p->last_cbc_opcode == CBC_PUSH_LITERAL);
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
return_with_literal = return_with_literal && !PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags);
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (return_with_literal)
|
||||
{
|
||||
@@ -2508,18 +2501,18 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (JERRY_UNLIKELY (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags)))
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_CONSTRUCTOR_RETURN);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
parser_emit_cbc (context_p, CBC_RETURN);
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2624,7 +2617,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
/* There is no lexer_next_token here, since the
|
||||
* next token belongs to the parent context. */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (JERRY_UNLIKELY (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags)))
|
||||
{
|
||||
if (context_p->status_flags & PARSER_CLASS_IMPLICIT_SUPER)
|
||||
@@ -2638,7 +2631,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
parser_emit_cbc (context_p, CBC_RETURN);
|
||||
parser_flush_cbc (context_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
return;
|
||||
}
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_RIGHT_SQUARE);
|
||||
@@ -2715,18 +2708,18 @@ consume_last_statement:
|
||||
}
|
||||
|
||||
case PARSER_STATEMENT_FOR_IN:
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case PARSER_STATEMENT_FOR_OF:
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
{
|
||||
parser_for_in_of_statement_t for_in_of_statement;
|
||||
parser_loop_statement_t loop;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
bool is_for_in = (context_p->stack_top_uint8 == PARSER_STATEMENT_FOR_IN);
|
||||
#else
|
||||
bool is_for_in = true;
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
parser_stack_pop (context_p, &loop, sizeof (parser_loop_statement_t));
|
||||
@@ -2839,9 +2832,9 @@ parser_free_jumps (parser_stack_iterator_t iterator) /**< iterator position */
|
||||
case PARSER_STATEMENT_WHILE:
|
||||
case PARSER_STATEMENT_FOR:
|
||||
case PARSER_STATEMENT_FOR_IN:
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case PARSER_STATEMENT_FOR_OF:
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
{
|
||||
parser_loop_statement_t loop;
|
||||
|
||||
|
||||
@@ -956,24 +956,6 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Case statement must be in a switch block.";
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
case PARSER_ERR_MULTIPLE_CLASS_CONSTRUCTORS:
|
||||
{
|
||||
return "Multiple constructors are not allowed.";
|
||||
}
|
||||
case PARSER_ERR_CLASS_CONSTRUCTOR_AS_ACCESSOR:
|
||||
{
|
||||
return "Class constructor may not be an accessor.";
|
||||
}
|
||||
case PARSER_ERR_CLASS_STATIC_PROTOTYPE:
|
||||
{
|
||||
return "Classes may not have a static property called 'prototype'.";
|
||||
}
|
||||
case PARSER_ERR_UNEXPECTED_SUPER_REFERENCE:
|
||||
{
|
||||
return "Super is not allowed to be used here.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
case PARSER_ERR_LEFT_PAREN_EXPECTED:
|
||||
{
|
||||
return "Expected '(' token.";
|
||||
@@ -990,12 +972,6 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Expected ']' token.";
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
case PARSER_ERR_RIGHT_BRACE_EXPECTED:
|
||||
{
|
||||
return "Expected '}' token.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
case PARSER_ERR_COLON_EXPECTED:
|
||||
{
|
||||
return "Expected ':' token.";
|
||||
@@ -1012,12 +988,6 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Expected 'in' token.";
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
case PARSER_ERR_OF_EXPECTED:
|
||||
{
|
||||
return "Expected 'of' token.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
case PARSER_ERR_WHILE_EXPECTED:
|
||||
{
|
||||
return "While expected for do-while loop.";
|
||||
@@ -1102,24 +1072,6 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Duplicated label.";
|
||||
}
|
||||
#if ((ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)) \
|
||||
|| (ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)))
|
||||
case PARSER_ERR_DUPLICATED_ARGUMENT_NAMES:
|
||||
{
|
||||
return "Duplicated function argument names are not allowed here.";
|
||||
}
|
||||
#endif /* ((ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER))
|
||||
|| (ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER))) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
case PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER:
|
||||
{
|
||||
return "Rest parameter must be the last formal parameter.";
|
||||
}
|
||||
case PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER:
|
||||
{
|
||||
return "Rest parameter may not have a default initializer.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
case PARSER_ERR_OBJECT_PROPERTY_REDEFINED:
|
||||
{
|
||||
return "Property of object literal redefined.";
|
||||
@@ -1128,7 +1080,44 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Non-strict argument definition.";
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case PARSER_ERR_MULTIPLE_CLASS_CONSTRUCTORS:
|
||||
{
|
||||
return "Multiple constructors are not allowed.";
|
||||
}
|
||||
case PARSER_ERR_CLASS_CONSTRUCTOR_AS_ACCESSOR:
|
||||
{
|
||||
return "Class constructor may not be an accessor.";
|
||||
}
|
||||
case PARSER_ERR_CLASS_STATIC_PROTOTYPE:
|
||||
{
|
||||
return "Classes may not have a static property called 'prototype'.";
|
||||
}
|
||||
case PARSER_ERR_UNEXPECTED_SUPER_REFERENCE:
|
||||
{
|
||||
return "Super is not allowed to be used here.";
|
||||
}
|
||||
case PARSER_ERR_RIGHT_BRACE_EXPECTED:
|
||||
{
|
||||
return "Expected '}' token.";
|
||||
}
|
||||
case PARSER_ERR_OF_EXPECTED:
|
||||
{
|
||||
return "Expected 'of' token.";
|
||||
}
|
||||
case PARSER_ERR_DUPLICATED_ARGUMENT_NAMES:
|
||||
{
|
||||
return "Duplicated function argument names are not allowed here.";
|
||||
}
|
||||
case PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER:
|
||||
{
|
||||
return "Rest parameter must be the last formal parameter.";
|
||||
}
|
||||
case PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER:
|
||||
{
|
||||
return "Rest parameter may not have a default initializer.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
case PARSER_ERR_FILE_NOT_FOUND:
|
||||
{
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_PARSE_STRICT_MODE == (int) PARSER_IS_STRICT,
|
||||
ecma_parse_strict_mode_must_be_equal_to_parser_is_strict);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
JERRY_STATIC_ASSERT ((ECMA_PARSE_CLASS_CONSTRUCTOR << PARSER_CLASS_PARSE_OPTS_OFFSET) == PARSER_CLASS_CONSTRUCTOR,
|
||||
ecma_class_parse_options_must_be_able_to_be_shifted_to_ecma_general_flags);
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@@ -540,12 +540,12 @@ parse_print_literal (ecma_compiled_code_t *compiled_code_p, /**< compiled code *
|
||||
ident_end = args_p->ident_end;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_REST_PARAMETER)
|
||||
{
|
||||
argument_end++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (literal_index < argument_end)
|
||||
{
|
||||
@@ -670,19 +670,17 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
JERRY_DEBUG_MSG (",no_lexical_env");
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION)
|
||||
{
|
||||
JERRY_DEBUG_MSG (",arrow");
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_CONSTRUCTOR)
|
||||
{
|
||||
JERRY_DEBUG_MSG (",constructor");
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
JERRY_DEBUG_MSG ("]\n");
|
||||
|
||||
@@ -991,12 +989,12 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
PARSER_NEXT_BYTE (page_p, offset);
|
||||
length++;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (ext_opcode == CBC_EXT_CONSTRUCTOR_RETURN)
|
||||
{
|
||||
last_opcode = CBC_RETURN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
if (ext_opcode == CBC_EXT_LINE)
|
||||
@@ -1193,13 +1191,13 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
compiled_code_p->refs = 1;
|
||||
compiled_code_p->status_flags = CBC_CODE_FLAGS_FUNCTION;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
JERRY_ASSERT (context_p->argument_count > 0);
|
||||
context_p->argument_count--;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (needs_uint16_arguments)
|
||||
{
|
||||
@@ -1262,26 +1260,22 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->status_flags & PARSER_IS_ARROW_FUNCTION)
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_ARROW_FUNCTION;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (context_p->status_flags & PARSER_CLASS_CONSTRUCTOR)
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_CONSTRUCTOR;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_REST_PARAMETER;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
literal_pool_p = ((ecma_value_t *) byte_code_p) - context_p->register_count;
|
||||
byte_code_p += literal_length;
|
||||
@@ -1617,12 +1611,10 @@ static void
|
||||
parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
lexer_token_type_t end_type) /**< expected end type */
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) || ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
bool duplicated_argument_names = false;
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) || ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
bool initializer_found = false;
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
|
||||
scanner_create_variables (context_p, sizeof (scanner_function_info_t));
|
||||
@@ -1634,7 +1626,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
while (true)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER);
|
||||
@@ -1650,7 +1642,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
context_p->status_flags |= PARSER_FUNCTION_HAS_REST_PARAM;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type != LEXER_LITERAL
|
||||
|| context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
|
||||
@@ -1670,15 +1662,15 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (JERRY_UNLIKELY (context_p->lit_object.literal_p->status_flags & LEXER_FLAG_FUNCTION_ARGUMENT))
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (initializer_found)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_DUPLICATED_ARGUMENT_NAMES);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) || ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
duplicated_argument_names = true;
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) || ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
context_p->status_flags |= PARSER_HAS_NON_STRICT_ARG;
|
||||
}
|
||||
@@ -1695,15 +1687,13 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_ASSIGN)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
parser_branch_t skip_init;
|
||||
|
||||
@@ -1723,7 +1713,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_set_branch_to_current_position (context_p, &skip_init);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type != LEXER_COMMA)
|
||||
{
|
||||
@@ -1785,9 +1775,9 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
context.module_current_node_p = NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
context.status_flags |= PARSER_GET_CLASS_PARSER_OPTS (parse_opts);
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
context.stack_depth = 0;
|
||||
context.stack_limit = 0;
|
||||
@@ -2122,13 +2112,13 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
JERRY_DEBUG_MSG ("\n--- %s parsing start ---\n\n",
|
||||
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor"
|
||||
: "Function");
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
JERRY_DEBUG_MSG ("\n--- Function parsing start ---\n\n");
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
@@ -2178,25 +2168,25 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if ((context_p->status_flags & PARSER_CLASS_CONSTRUCTOR_SUPER) == PARSER_CLASS_CONSTRUCTOR_SUPER)
|
||||
{
|
||||
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
parser_parse_statements (context_p);
|
||||
compiled_code_p = parser_post_processing (context_p);
|
||||
|
||||
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
JERRY_DEBUG_MSG ("\n--- %s parsing end ---\n\n",
|
||||
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor"
|
||||
: "Function");
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
JERRY_DEBUG_MSG ("\n--- Function parsing end ---\n\n");
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
@@ -2205,7 +2195,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
return compiled_code_p;
|
||||
} /* parser_parse_function */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|
||||
/**
|
||||
* Parse arrow function code
|
||||
@@ -2223,9 +2213,9 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
|
||||
&& (status_flags & PARSER_IS_ARROW_FUNCTION));
|
||||
parser_save_context (context_p, &saved_context);
|
||||
context_p->status_flags |= status_flags;
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
context_p->status_flags |= saved_context.status_flags & PARSER_CLASS_HAS_SUPER;
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
if (context_p->is_show_opcodes)
|
||||
@@ -2301,7 +2291,7 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
|
||||
return compiled_code_p;
|
||||
} /* parser_parse_arrow_function */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Raise a parse error.
|
||||
|
||||
@@ -79,28 +79,16 @@ typedef enum
|
||||
PARSER_ERR_MULTIPLE_DEFAULTS_NOT_ALLOWED, /**< multiple default cases are not allowed */
|
||||
PARSER_ERR_DEFAULT_NOT_IN_SWITCH, /**< default statement is not in switch block */
|
||||
PARSER_ERR_CASE_NOT_IN_SWITCH, /**< case statement is not in switch block */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
PARSER_ERR_MULTIPLE_CLASS_CONSTRUCTORS, /**< multiple class constructor */
|
||||
PARSER_ERR_CLASS_CONSTRUCTOR_AS_ACCESSOR, /**< class constructor cannot be an accessor */
|
||||
PARSER_ERR_CLASS_STATIC_PROTOTYPE, /**< static method name 'prototype' is not allowed */
|
||||
PARSER_ERR_UNEXPECTED_SUPER_REFERENCE, /**< unexpected super keyword */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
PARSER_ERR_LEFT_PAREN_EXPECTED, /**< left paren expected */
|
||||
PARSER_ERR_LEFT_BRACE_EXPECTED, /**< left brace expected */
|
||||
PARSER_ERR_RIGHT_PAREN_EXPECTED, /**< right paren expected */
|
||||
PARSER_ERR_RIGHT_SQUARE_EXPECTED, /**< right square expected */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
PARSER_ERR_RIGHT_BRACE_EXPECTED, /**< right brace expected */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
PARSER_ERR_COLON_EXPECTED, /**< colon expected */
|
||||
PARSER_ERR_COLON_FOR_CONDITIONAL_EXPECTED, /**< colon expected for conditional expression */
|
||||
PARSER_ERR_SEMICOLON_EXPECTED, /**< semicolon expected */
|
||||
PARSER_ERR_IN_EXPECTED, /**< in keyword expected */
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
PARSER_ERR_OF_EXPECTED, /**< of keyword expected */
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
PARSER_ERR_WHILE_EXPECTED, /**< while expected for do-while loop */
|
||||
PARSER_ERR_CATCH_FINALLY_EXPECTED, /**< catch or finally expected */
|
||||
PARSER_ERR_ARRAY_ITEM_SEPARATOR_EXPECTED, /**< array item separator expected */
|
||||
@@ -123,15 +111,21 @@ typedef enum
|
||||
PARSER_ERR_INVALID_RETURN, /**< return must be inside a function */
|
||||
PARSER_ERR_INVALID_RIGHT_SQUARE, /**< right square must terminate a block */
|
||||
PARSER_ERR_DUPLICATED_LABEL, /**< duplicated label */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) || ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
PARSER_ERR_DUPLICATED_ARGUMENT_NAMES, /**< duplicated argument names */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) || ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER, /**< formal parameter after rest parameter */
|
||||
PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER, /**< rest parameter default initializer */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
PARSER_ERR_OBJECT_PROPERTY_REDEFINED, /**< property of object literal redefined */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
PARSER_ERR_MULTIPLE_CLASS_CONSTRUCTORS, /**< multiple class constructor */
|
||||
PARSER_ERR_CLASS_CONSTRUCTOR_AS_ACCESSOR, /**< class constructor cannot be an accessor */
|
||||
PARSER_ERR_CLASS_STATIC_PROTOTYPE, /**< static method name 'prototype' is not allowed */
|
||||
PARSER_ERR_UNEXPECTED_SUPER_REFERENCE, /**< unexpected super keyword */
|
||||
|
||||
PARSER_ERR_RIGHT_BRACE_EXPECTED, /**< right brace expected */
|
||||
PARSER_ERR_OF_EXPECTED, /**< of keyword expected */
|
||||
|
||||
PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER, /**< formal parameter after rest parameter */
|
||||
PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER, /**< rest parameter default initializer */
|
||||
PARSER_ERR_DUPLICATED_ARGUMENT_NAMES, /**< duplicated argument names */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
PARSER_ERR_FILE_NOT_FOUND, /**< file not found*/
|
||||
PARSER_ERR_FROM_EXPECTED, /**< from expected */
|
||||
|
||||
@@ -952,9 +952,9 @@ scanner_cleanup (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
case SCANNER_TYPE_WHILE:
|
||||
case SCANNER_TYPE_FOR_IN:
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case SCANNER_TYPE_FOR_OF:
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case SCANNER_TYPE_CASE:
|
||||
{
|
||||
size = sizeof (scanner_location_info_t);
|
||||
|
||||
@@ -44,14 +44,12 @@ typedef enum
|
||||
SCAN_MODE_STATEMENT_END, /**< scanning statement end */
|
||||
SCAN_MODE_VAR_STATEMENT, /**< scanning var statement */
|
||||
SCAN_MODE_FUNCTION_ARGUMENTS, /**< scanning function arguments */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
SCAN_MODE_CONTINUE_FUNCTION_ARGUMENTS, /**< continue scanning function arguments */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
SCAN_MODE_PROPERTY_NAME, /**< scanning property name */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
SCAN_MODE_CONTINUE_FUNCTION_ARGUMENTS, /**< continue scanning function arguments */
|
||||
SCAN_MODE_CLASS_DECLARATION, /**< scanning class declaration */
|
||||
SCAN_MODE_CLASS_METHOD, /**< scanning class method */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
} scan_modes_t;
|
||||
|
||||
/**
|
||||
@@ -87,24 +85,16 @@ typedef enum
|
||||
SCAN_STACK_CATCH_STATEMENT, /**< catch statement */
|
||||
SCAN_STACK_SQUARE_BRACKETED_EXPRESSION, /**< square bracketed expression group */
|
||||
SCAN_STACK_OBJECT_LITERAL, /**< object literal group */
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
SCAN_STACK_COMPUTED_PROPERTY, /**< computed property name */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
SCAN_STACK_TEMPLATE_STRING, /**< template string */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
SCAN_STACK_ARROW_ARGUMENTS, /**< might be arguments of an arrow function */
|
||||
SCAN_STACK_ARROW_EXPRESSION, /**< expression body of an arrow function */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
SCAN_STACK_CLASS_STATEMENT, /**< class statement */
|
||||
SCAN_STACK_CLASS_EXPRESSION, /**< class expression */
|
||||
SCAN_STACK_CLASS_EXTENDS, /**< class extends expression */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
SCAN_STACK_FUNCTION_PARAMETERS, /**< function parameter initializer */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
} scan_stack_modes_t;
|
||||
|
||||
/**
|
||||
@@ -125,13 +115,13 @@ typedef enum
|
||||
/**
|
||||
* Checks whether token type is "of".
|
||||
*/
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#define SCANNER_IDENTIFIER_IS_OF() (lexer_compare_literal_to_identifier (context_p, "of", 2))
|
||||
#else
|
||||
#define SCANNER_IDENTIFIER_IS_OF() (false)
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
|
||||
/**
|
||||
* Init scanning the body of an arrow function.
|
||||
@@ -222,12 +212,10 @@ scanner_process_arrow_arg (parser_context_t *context_p, /**< context */
|
||||
|
||||
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->token.type == LEXER_THREE_DOTS)
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
if (context_p->token.type == LEXER_LITERAL
|
||||
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL)
|
||||
@@ -266,7 +254,7 @@ scanner_process_arrow_arg (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
} /* scanner_process_arrow_arg */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Scan primary expression.
|
||||
@@ -310,7 +298,7 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
case LEXER_LEFT_PAREN:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_ARROW_ARGUMENTS);
|
||||
|
||||
scanner_literal_pool_t *literal_pool_p;
|
||||
@@ -327,10 +315,10 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
|
||||
scanner_process_arrow_arg (context_p, scanner_context_p);
|
||||
return SCAN_KEEP_TOKEN;
|
||||
#else
|
||||
#else /* ENABLED (JERRY_ES2015) */
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_PAREN_EXPRESSION);
|
||||
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
break;
|
||||
}
|
||||
case LEXER_LEFT_SQUARE:
|
||||
@@ -345,7 +333,7 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
scanner_context_p->mode = SCAN_MODE_PROPERTY_NAME;
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case LEXER_TEMPLATE_LITERAL:
|
||||
{
|
||||
if (context_p->source_p[-1] != LIT_CHAR_GRAVE_ACCENT)
|
||||
@@ -358,10 +346,10 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
/* The string is a normal string literal. */
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case LEXER_LITERAL:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
const uint8_t *source_p = context_p->source_p;
|
||||
|
||||
if (context_p->token.lit_location.type == LEXER_IDENT_LITERAL
|
||||
@@ -370,7 +358,7 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
scanner_process_simple_arrow (context_p, scanner_context_p, source_p);
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.lit_location.type == LEXER_IDENT_LITERAL)
|
||||
{
|
||||
@@ -387,7 +375,7 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
scanner_context_p->mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_CLASS_EXPRESSION);
|
||||
@@ -401,7 +389,7 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case LEXER_RIGHT_SQUARE:
|
||||
{
|
||||
if (stack_top != SCAN_STACK_SQUARE_BRACKETED_EXPRESSION)
|
||||
@@ -526,7 +514,7 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
scanner_raise_error (context_p);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case SCAN_STACK_ARROW_ARGUMENTS:
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
@@ -537,15 +525,13 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
{
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
case SCAN_STACK_FUNCTION_PARAMETERS:
|
||||
{
|
||||
scanner_context_p->mode = SCAN_MODE_CONTINUE_FUNCTION_ARGUMENTS;
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
default:
|
||||
{
|
||||
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
@@ -660,11 +646,11 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
location_info = (scanner_location_info_t *) scanner_insert_info (context_p,
|
||||
for_statement.u.source_p,
|
||||
sizeof (scanner_location_info_t));
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
location_info->info.type = (type == LEXER_KEYW_IN) ? SCANNER_TYPE_FOR_IN : SCANNER_TYPE_FOR_OF;
|
||||
#else /* !ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
location_info->info.type = SCANNER_TYPE_FOR_IN;
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
scanner_get_location (&location_info->location, context_p);
|
||||
|
||||
@@ -846,7 +832,7 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case SCAN_STACK_COMPUTED_PROPERTY:
|
||||
{
|
||||
if (type != LEXER_RIGHT_SQUARE)
|
||||
@@ -886,8 +872,6 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
case SCAN_STACK_TEMPLATE_STRING:
|
||||
{
|
||||
if (type != LEXER_RIGHT_BRACE)
|
||||
@@ -910,8 +894,6 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
}
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
case SCAN_STACK_ARROW_ARGUMENTS:
|
||||
{
|
||||
if (type != LEXER_RIGHT_PAREN)
|
||||
@@ -929,8 +911,6 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
scanner_context_p->mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
case SCAN_STACK_CLASS_EXTENDS:
|
||||
{
|
||||
if (type != LEXER_LEFT_BRACE)
|
||||
@@ -941,8 +921,6 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
case SCAN_STACK_FUNCTION_PARAMETERS:
|
||||
{
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
@@ -956,7 +934,7 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
scanner_context_p->mode = SCAN_MODE_CONTINUE_FUNCTION_ARGUMENTS;
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
default:
|
||||
{
|
||||
scanner_context_p->mode = SCAN_MODE_STATEMENT_END;
|
||||
@@ -1194,7 +1172,7 @@ scanner_scan_statement (parser_context_t *context_p, /**< context */
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_STATEMENT);
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
@@ -1211,7 +1189,7 @@ scanner_scan_statement (parser_context_t *context_p, /**< context */
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_CLASS_STATEMENT);
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
case LEXER_KEYW_IMPORT:
|
||||
{
|
||||
@@ -1380,7 +1358,7 @@ scanner_scan_statement (parser_context_t *context_p, /**< context */
|
||||
scanner_context_p->mode = SCAN_MODE_FUNCTION_ARGUMENTS;
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_KEYW_CLASS)
|
||||
{
|
||||
scanner_context_p->mode = SCAN_MODE_CLASS_DECLARATION;
|
||||
@@ -1402,7 +1380,7 @@ scanner_scan_statement (parser_context_t *context_p, /**< context */
|
||||
location_p->type |= SCANNER_LITERAL_IS_VAR;
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Assignment expression. */
|
||||
lexer_lit_location_t *location_p;
|
||||
@@ -1525,7 +1503,7 @@ scanner_scan_statement (parser_context_t *context_p, /**< context */
|
||||
|
||||
JERRY_ASSERT (context_p->token.flags & LEXER_NO_SKIP_SPACES);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* The colon needs to be checked first because the parser also checks
|
||||
* it first, and this check skips the spaces which affects source_p. */
|
||||
if (JERRY_UNLIKELY (lexer_check_arrow (context_p)))
|
||||
@@ -1533,7 +1511,7 @@ scanner_scan_statement (parser_context_t *context_p, /**< context */
|
||||
scanner_process_simple_arrow (context_p, scanner_context_p, context_p->source_p);
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
scanner_add_reference (context_p, scanner_context_p);
|
||||
|
||||
@@ -1578,9 +1556,9 @@ scanner_scan_statement_end (parser_context_t *context_p, /**< context */
|
||||
break;
|
||||
}
|
||||
case SCAN_STACK_BLOCK_STATEMENT:
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case SCAN_STACK_CLASS_STATEMENT:
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case SCAN_STACK_FUNCTION_STATEMENT:
|
||||
{
|
||||
if (type != LEXER_RIGHT_BRACE)
|
||||
@@ -1621,14 +1599,14 @@ scanner_scan_statement_end (parser_context_t *context_p, /**< context */
|
||||
scanner_pop_literal_pool (context_p, scanner_context_p);
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->stack_top_uint8 == SCAN_STACK_CLASS_STATEMENT
|
||||
|| context_p->stack_top_uint8 == SCAN_STACK_CLASS_EXPRESSION)
|
||||
{
|
||||
scanner_context_p->mode = SCAN_MODE_CLASS_METHOD;
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
JERRY_ASSERT (context_p->stack_top_uint8 == SCAN_STACK_OBJECT_LITERAL);
|
||||
|
||||
@@ -1908,7 +1886,7 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case SCAN_MODE_CLASS_DECLARATION:
|
||||
{
|
||||
if (context_p->token.type == LEXER_KEYW_EXTENDS)
|
||||
@@ -1966,20 +1944,18 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_LEFT_SQUARE)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_COMPUTED_PROPERTY);
|
||||
scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
scanner_push_literal_pool (context_p, &scanner_context, SCANNER_LITERAL_POOL_FUNCTION);
|
||||
lexer_next_token (context_p);
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case SCAN_MODE_POST_PRIMARY_EXPRESSION:
|
||||
{
|
||||
if (scanner_scan_post_primary_expression (context_p, &scanner_context, type))
|
||||
@@ -2096,23 +2072,23 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* FALLTHRU */
|
||||
}
|
||||
case SCAN_MODE_CONTINUE_FUNCTION_ARGUMENTS:
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type != LEXER_RIGHT_PAREN && context_p->token.type != LEXER_EOS)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_THREE_DOTS)
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type != LEXER_LITERAL
|
||||
|| context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
|
||||
@@ -2132,14 +2108,14 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_ASSIGN)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_PARAMETERS);
|
||||
scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type == LEXER_EOS && stack_top == SCAN_STACK_SCRIPT_FUNCTION)
|
||||
{
|
||||
@@ -2183,14 +2159,14 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_scan_identifier (context_p, LEXER_SCAN_IDENT_PROPERTY);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_LEFT_SQUARE)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_COMPUTED_PROPERTY);
|
||||
scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type == LEXER_RIGHT_BRACE)
|
||||
{
|
||||
@@ -2206,14 +2182,14 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_PROPERTY);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_LEFT_SQUARE)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_COMPUTED_PROPERTY);
|
||||
scanner_context.mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type != LEXER_LITERAL)
|
||||
{
|
||||
@@ -2227,15 +2203,15 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
|
||||
|
||||
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
parser_line_counter_t start_line = context_p->token.line;
|
||||
parser_line_counter_t start_column = context_p->token.column;
|
||||
bool is_ident = (context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->token.type == LEXER_LEFT_PAREN)
|
||||
{
|
||||
scanner_push_literal_pool (context_p, &scanner_context, SCANNER_LITERAL_POOL_FUNCTION);
|
||||
@@ -2277,7 +2253,7 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
|
||||
scanner_context.mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (context_p->token.type != LEXER_COLON)
|
||||
{
|
||||
@@ -2481,14 +2457,14 @@ scan_completed:
|
||||
print_location = true;
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case SCANNER_TYPE_FOR_OF:
|
||||
{
|
||||
name_p = "FOR-OF";
|
||||
print_location = true;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case SCANNER_TYPE_SWITCH:
|
||||
{
|
||||
JERRY_DEBUG_MSG (" SWITCH: source:%d\n",
|
||||
|
||||
@@ -39,9 +39,9 @@ typedef enum
|
||||
SCANNER_TYPE_WHILE, /**< while statement */
|
||||
SCANNER_TYPE_FOR, /**< for statement */
|
||||
SCANNER_TYPE_FOR_IN, /**< for-in statement */
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
SCANNER_TYPE_FOR_OF, /**< for-of statement */
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
SCANNER_TYPE_SWITCH, /**< switch statement */
|
||||
SCANNER_TYPE_CASE, /**< case statement */
|
||||
} scanner_info_type_t;
|
||||
|
||||
Reference in New Issue
Block a user