Remove ES_NEXT macro (#4915)

- remove all '#JERRY_ESNEXT' macro
- remove 5.1 build profile, update test runner accordingly (Note: all builtins are turn on by default)
- move tests from tests/jerry/esnext into tests/jerry, concatenate files with same names
- add skiplist to some snapshot tests that were supported only in 5.1
- fix doxygen issues that were hidden before (bc. of es.next macro)

Co-authored-by: Martin Negyokru negyokru@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2022-01-31 16:46:00 +01:00
committed by GitHub
parent 76403606d0
commit 4924f9fd31
973 changed files with 1902 additions and 8240 deletions
-7
View File
@@ -63,19 +63,12 @@
#define CBC_HAS_POP_STACK_BYTE_ARG (CBC_HAS_BYTE_ARG | CBC_POP_STACK_BYTE_ARG)
#if JERRY_ESNEXT
/**
* CBC_NO_RESULT_OPERATION for ext opcodes
*/
#define CBC_EXT_NO_RESULT_OPERATION(opcode) \
((opcode) >= PARSER_TO_EXT_OPCODE (CBC_EXT_ASSIGN_SUPER) \
&& (opcode) <= PARSER_TO_EXT_OPCODE (CBC_EXT_SPREAD_CALL_PROP_BLOCK))
#else /* !JERRY_ESNEXT */
/**
* CBC_NO_RESULT_OPERATION for ext opcodes
*/
#define CBC_EXT_NO_RESULT_OPERATION(opcode) false
#endif /* JERRY_ESNEXT */
/* Debug macro. */
#define CBC_ARGS_EQ(op, types) ((cbc_flags[op] & CBC_ARG_TYPES) == (types))
-4
View File
@@ -347,7 +347,6 @@ util_print_cbc (ecma_compiled_code_t *compiled_code_p) /**< compiled code */
JERRY_DEBUG_MSG (",no_lexical_env");
}
#if JERRY_ESNEXT
switch (CBC_FUNCTION_GET_TYPE (compiled_code_p->status_flags))
{
case CBC_FUNCTION_CONSTRUCTOR:
@@ -386,7 +385,6 @@ util_print_cbc (ecma_compiled_code_t *compiled_code_p) /**< compiled code */
break;
}
}
#endif /* JERRY_ESNEXT */
JERRY_DEBUG_MSG ("]\n");
@@ -396,7 +394,6 @@ util_print_cbc (ecma_compiled_code_t *compiled_code_p) /**< compiled code */
JERRY_DEBUG_MSG (" Const literal range end: %d\n", (int) const_literal_end);
JERRY_DEBUG_MSG (" Literal range end: %d\n\n", (int) literal_end);
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_HAS_EXTENDED_INFO)
{
uint8_t *extended_info_p = ecma_compiled_code_resolve_extended_info (compiled_code_p);
@@ -420,7 +417,6 @@ util_print_cbc (ecma_compiled_code_t *compiled_code_p) /**< compiled code */
size -= (size_t) (extended_info_start_p - extended_info_p);
}
#endif /* JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING */
byte_code_start_p = (uint8_t *) compiled_code_p;
-2
View File
@@ -76,9 +76,7 @@ typedef enum
* (no need to allocate memory) */
LEXER_FLAG_LATE_INIT = (1 << 3), /**< initialize this variable after the byte code is freed */
LEXER_FLAG_ASCII = (1 << 4), /**< the literal contains only ascii characters */
#if JERRY_ESNEXT
LEXER_FLAG_GLOBAL = (1 << 5), /**< this local identifier is not a let or const declaration */
#endif /* JERRY_ESNEXT */
} lexer_literal_status_flags_t;
/**
+15 -185
View File
@@ -93,8 +93,6 @@ lexer_hex_to_code_point (const uint8_t *source_p, /**< current source position *
return result;
} /* lexer_hex_to_code_point */
#if JERRY_ESNEXT
/**
* Parse hexadecimal character sequence enclosed in braces
*
@@ -146,8 +144,6 @@ lexer_hex_in_braces_to_code_point (const uint8_t *source_p, /**< current source
return result;
} /* lexer_hex_in_braces_to_code_point */
#endif /* JERRY_ESNEXT */
/**
* Parse hexadecimal character sequence
*
@@ -160,13 +156,11 @@ lexer_unchecked_hex_to_character (const uint8_t **source_p) /**< [in, out] curre
const uint8_t *char_p = *source_p;
uint32_t length = (char_p[-1] == LIT_CHAR_LOWERCASE_U) ? 4 : 2;
#if JERRY_ESNEXT
if (char_p[0] == LIT_CHAR_LEFT_BRACE)
{
length = 0;
char_p++;
}
#endif /* JERRY_ESNEXT */
while (true)
{
@@ -188,17 +182,16 @@ lexer_unchecked_hex_to_character (const uint8_t **source_p) /**< [in, out] curre
JERRY_ASSERT (result <= LIT_UNICODE_CODE_POINT_MAX);
#if JERRY_ESNEXT
if (length == 0)
{
if (*char_p != LIT_CHAR_RIGHT_BRACE)
{
continue;
}
*source_p = char_p + 1;
return result;
}
#endif /* JERRY_ESNEXT */
if (--length == 0)
{
@@ -388,8 +381,6 @@ lexer_skip_spaces (parser_context_t *context_p) /**< context */
}
} /* lexer_skip_spaces */
#if JERRY_ESNEXT
/**
* Skip all the continuous empty statements.
*/
@@ -407,21 +398,12 @@ 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 /* JERRY_ESNEXT */
#if JERRY_ESNEXT
/**
* Checks whether the keyword has escape sequences.
*/
#define LEXER_CHECK_INVALID_KEYWORD(ident_start_p, buffer_p) \
(JERRY_UNLIKELY ((ident_start_p) == (buffer_p)) \
&& !(context_p->global_status_flags & ECMA_PARSE_INTERNAL_PRE_SCANNING))
#else /* !JERRY_ESNEXT */
/**
* Checks whether the keyword has escape sequences.
*/
#define LEXER_CHECK_INVALID_KEYWORD(ident_start_p, buffer_p) (JERRY_UNLIKELY ((ident_start_p) == (buffer_p)))
#endif /* JERRY_ESNEXT */
/**
* Keyword data.
@@ -488,9 +470,7 @@ static const keyword_string_t keywords_with_length_4[] = {
* Keywords with 5 characters.
*/
static const keyword_string_t keywords_with_length_5[] = {
#if JERRY_ESNEXT
LEXER_KEYWORD ("async", LEXER_KEYW_ASYNC), LEXER_KEYWORD ("await", LEXER_KEYW_AWAIT),
#endif /* JERRY_ESNEXT */
LEXER_KEYWORD ("break", LEXER_KEYW_BREAK), LEXER_KEYWORD ("catch", LEXER_KEYW_CATCH),
LEXER_KEYWORD ("class", LEXER_KEYW_CLASS), LEXER_KEYWORD ("const", LEXER_KEYW_CONST),
LEXER_KEYWORD ("false", LEXER_LIT_FALSE), LEXER_KEYWORD ("super", LEXER_KEYW_SUPER),
@@ -605,7 +585,6 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
status_flags = LEXER_LIT_LOCATION_HAS_ESCAPE;
#if JERRY_ESNEXT
if (source_p + 5 <= source_end_p && source_p[1] == LIT_CHAR_LOWERCASE_U)
{
if (source_p[2] == LIT_CHAR_LEFT_BRACE)
@@ -617,12 +596,6 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
code_point = lexer_hex_to_code_point (source_p + 2, 4);
}
}
#else /* !JERRY_ESNEXT */
if (source_p + 6 <= source_end_p && source_p[1] == LIT_CHAR_LOWERCASE_U)
{
code_point = lexer_hex_to_code_point (source_p + 2, 4);
}
#endif /* JERRY_ESNEXT */
if (code_point == UINT32_MAX)
{
@@ -659,7 +632,6 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
{
status_flags &= (uint32_t) ~LEXER_LIT_LOCATION_IS_ASCII;
#if JERRY_ESNEXT
utf8_length = lit_read_code_point_from_utf8 (source_p, (lit_utf8_size_t) (source_end_p - source_p), &code_point);
decoded_length = utf8_length;
@@ -686,18 +658,6 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
context_p->global_status_flags |= ECMA_PARSE_INTERNAL_HAS_4_BYTE_MARKER;
#endif /* JERRY_FUNCTION_TO_STRING */
}
#else /* !JERRY_ESNEXT */
if (code_point < LIT_UTF8_4_BYTE_MARKER)
{
utf8_length =
lit_read_code_point_from_utf8 (source_p, (lit_utf8_size_t) (source_end_p - source_p), &code_point);
decoded_length = utf8_length;
}
else
{
code_point = 0;
}
#endif /* JERRY_ESNEXT */
}
if (length == 0)
@@ -778,7 +738,6 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
if (JERRY_LIKELY (keyword_p->type < LEXER_FIRST_NON_RESERVED_KEYWORD))
{
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (keyword_p->type == LEXER_KEYW_AWAIT))
{
if (!(context_p->status_flags & (PARSER_IS_ASYNC_FUNCTION | PARSER_IS_CLASS_STATIC_BLOCK))
@@ -799,7 +758,6 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
context_p->token.type = (uint8_t) LEXER_KEYW_AWAIT;
break;
}
#endif /* JERRY_ESNEXT */
if (LEXER_CHECK_INVALID_KEYWORD (ident_start_p, buffer_p))
{
@@ -811,7 +769,6 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
break;
}
#if JERRY_ESNEXT
if (keyword_p->type == LEXER_KEYW_LET && (context_p->status_flags & PARSER_IS_STRICT))
{
if (LEXER_CHECK_INVALID_KEYWORD (ident_start_p, buffer_p))
@@ -842,7 +799,6 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
{
parser_raise_error (context_p, PARSER_ERR_ARGUMENTS_IN_CLASS_FIELD);
}
#endif /* JERRY_ESNEXT */
if (keyword_p->type >= LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD && (context_p->status_flags & PARSER_IS_STRICT)
&& !(options & LEXER_PARSE_NO_STRICT_IDENT_ERROR))
@@ -881,11 +837,7 @@ void
lexer_parse_string (parser_context_t *context_p, /**< context */
lexer_string_options_t opts) /**< options */
{
#if JERRY_ESNEXT
int32_t raw_length_adjust = 0;
#else /* JERRY_ESNEXT */
JERRY_UNUSED (opts);
#endif /* JERRY_ESNEXT */
uint8_t str_end_character = context_p->source_p[0];
const uint8_t *source_p = context_p->source_p + 1;
@@ -898,12 +850,10 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
size_t length = 0;
lexer_lit_location_flags_t status_flags = LEXER_LIT_LOCATION_IS_ASCII;
#if JERRY_ESNEXT
if (str_end_character == LIT_CHAR_RIGHT_BRACE)
{
str_end_character = LIT_CHAR_GRAVE_ACCENT;
}
#endif /* JERRY_ESNEXT */
while (true)
{
@@ -937,9 +887,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
source_p++;
if (source_p < source_end_p && *source_p == LIT_CHAR_LF)
{
#if JERRY_ESNEXT
raw_length_adjust--;
#endif /* JERRY_ESNEXT */
source_p++;
}
@@ -962,7 +910,6 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
continue;
}
#if JERRY_ESNEXT
if (opts & LEXER_STRING_RAW)
{
if ((*source_p == LIT_CHAR_GRAVE_ACCENT) || (*source_p == LIT_CHAR_BACKSLASH))
@@ -973,7 +920,6 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
}
continue;
}
#endif /* JERRY_ESNEXT */
if (*source_p == LIT_CHAR_0 && source_p + 1 < source_end_p
&& (*(source_p + 1) < LIT_CHAR_0 || *(source_p + 1) > LIT_CHAR_9))
@@ -988,12 +934,10 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
* converted to a character which has the same byte length. */
if (*source_p >= LIT_CHAR_0 && *source_p <= LIT_CHAR_3)
{
#if JERRY_ESNEXT
if (str_end_character == LIT_CHAR_GRAVE_ACCENT)
{
parser_raise_error (context_p, PARSER_ERR_TEMPLATE_STR_OCTAL_ESCAPE);
}
#endif /* JERRY_ESNEXT */
if (context_p->status_flags & PARSER_IS_STRICT)
{
@@ -1053,7 +997,6 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
uint32_t escape_length = (*source_p == LIT_CHAR_LOWERCASE_X) ? 3 : 5;
lit_code_point_t code_point = UINT32_MAX;
#if JERRY_ESNEXT
if (source_p + 4 <= source_end_p && source_p[0] == LIT_CHAR_LOWERCASE_U && source_p[1] == LIT_CHAR_LEFT_BRACE)
{
code_point = lexer_hex_in_braces_to_code_point (source_p + 2, source_end_p, &escape_length);
@@ -1061,14 +1004,11 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
}
else
{
#endif /* JERRY_ESNEXT */
if (source_p + escape_length <= source_end_p)
{
code_point = lexer_hex_to_code_point (source_p + 1, escape_length - 1);
}
#if JERRY_ESNEXT
}
#endif /* JERRY_ESNEXT */
if (code_point == UINT32_MAX)
{
@@ -1084,7 +1024,6 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
continue;
}
}
#if JERRY_ESNEXT
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT && source_p[0] == LIT_CHAR_DOLLAR_SIGN
&& source_p + 1 < source_end_p && source_p[1] == LIT_CHAR_LEFT_BRACE)
{
@@ -1092,7 +1031,6 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
source_p++;
break;
}
#endif /* JERRY_ESNEXT */
if (*source_p >= LIT_UTF8_4_BYTE_MARKER)
{
@@ -1102,9 +1040,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
length += 2 * 3;
status_flags = LEXER_LIT_LOCATION_HAS_ESCAPE;
source_p += 4;
#if JERRY_ESNEXT
raw_length_adjust += 2;
#endif /* JERRY_ESNEXT */
column++;
#if JERRY_FUNCTION_TO_STRING
context_p->global_status_flags |= ECMA_PARSE_INTERNAL_HAS_4_BYTE_MARKER;
@@ -1117,7 +1053,6 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
/* Subtract -1 because column is increased below. */
column--;
}
#if JERRY_ESNEXT
else if (*source_p == LEXER_NEWLINE_LS_PS_BYTE_1 && LEXER_NEWLINE_LS_PS_BYTE_23 (source_p))
{
source_p += 3;
@@ -1153,12 +1088,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
continue;
}
}
#endif /* JERRY_ESNEXT */
else if (*source_p == LIT_CHAR_CR
#if !JERRY_ESNEXT
|| (*source_p == LEXER_NEWLINE_LS_PS_BYTE_1 && LEXER_NEWLINE_LS_PS_BYTE_23 (source_p))
#endif /* !JERRY_ESNEXT */
|| *source_p == LIT_CHAR_LF)
else if (*source_p == LIT_CHAR_CR || *source_p == LIT_CHAR_LF)
{
context_p->token.line = line;
context_p->token.column = column;
@@ -1176,23 +1106,17 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
}
}
#if JERRY_ESNEXT
if (opts & LEXER_STRING_RAW)
{
length = (size_t) ((source_p - string_start_p) + raw_length_adjust);
}
#endif /* JERRY_ESNEXT */
if (length > PARSER_MAXIMUM_STRING_LENGTH)
{
parser_raise_error (context_p, PARSER_ERR_STRING_TOO_LONG);
}
#if JERRY_ESNEXT
context_p->token.type = ((str_end_character != LIT_CHAR_GRAVE_ACCENT) ? LEXER_LITERAL : LEXER_TEMPLATE_LITERAL);
#else /* !JERRY_ESNEXT */
context_p->token.type = LEXER_LITERAL;
#endif /* JERRY_ESNEXT */
/* Fill literal data. */
context_p->token.lit_location.char_p = string_start_p;
@@ -1215,17 +1139,12 @@ lexer_check_numbers (parser_context_t *context_p, /**< context */
const ecma_char_t digit_max, /**< maximum of the number range */
const bool is_legacy) /**< is legacy octal number */
{
#if !JERRY_ESNEXT
JERRY_UNUSED (context_p);
JERRY_UNUSED (is_legacy);
#endif /* !JERRY_ESNEXT */
while (true)
{
while (*source_p < source_end_p && *source_p[0] >= LIT_CHAR_0 && *source_p[0] <= digit_max)
{
*source_p += 1;
}
#if JERRY_ESNEXT
if (*source_p != source_end_p && *source_p[0] == LIT_CHAR_UNDERSCORE)
{
*source_p += 1;
@@ -1236,7 +1155,6 @@ lexer_check_numbers (parser_context_t *context_p, /**< context */
}
continue;
}
#endif /* JERRY_ESNEXT */
break;
}
@@ -1264,12 +1182,11 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
if (source_p[0] == LIT_CHAR_0 && source_p + 1 < source_end_p)
{
#if JERRY_ESNEXT
if (source_p[1] == LIT_CHAR_UNDERSCORE)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
}
#endif /* JERRY_ESNEXT */
if (LEXER_TO_ASCII_LOWERCASE (source_p[1]) == LIT_CHAR_LOWERCASE_X)
{
context_p->token.extra_value = LEXER_NUMBER_HEXADECIMAL;
@@ -1283,7 +1200,6 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
do
{
source_p++;
#if JERRY_ESNEXT
if (source_p < source_end_p && source_p[0] == LIT_CHAR_UNDERSCORE)
{
source_p++;
@@ -1292,10 +1208,8 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
}
}
#endif /* JERRY_ESNEXT */
} while (source_p < source_end_p && lit_char_is_hex_digit (source_p[0]));
}
#if JERRY_ESNEXT
else if (LEXER_TO_ASCII_LOWERCASE (source_p[1]) == LIT_CHAR_LOWERCASE_O)
{
context_p->token.extra_value = LEXER_NUMBER_OCTAL;
@@ -1308,7 +1222,6 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
lexer_check_numbers (context_p, &source_p, source_end_p, LIT_CHAR_7, false);
}
#endif /* JERRY_ESNEXT */
else if (source_p[1] >= LIT_CHAR_0 && source_p[1] <= LIT_CHAR_9)
{
context_p->token.extra_value = LEXER_NUMBER_OCTAL;
@@ -1325,15 +1238,11 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
if (source_p < source_end_p && source_p[0] >= LIT_CHAR_8 && source_p[0] <= LIT_CHAR_9)
{
#if JERRY_ESNEXT
lexer_check_numbers (context_p, &source_p, source_end_p, LIT_CHAR_9, true);
context_p->token.extra_value = LEXER_NUMBER_DECIMAL;
#else /* !JERRY_ESNEXT */
parser_raise_error (context_p, PARSER_ERR_INVALID_NUMBER);
#endif /* JERRY_ESNEXT */
}
}
#if JERRY_ESNEXT
else if (LEXER_TO_ASCII_LOWERCASE (source_p[1]) == LIT_CHAR_LOWERCASE_B)
{
context_p->token.extra_value = LEXER_NUMBER_BINARY;
@@ -1357,7 +1266,6 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
}
} while (source_p < source_end_p && lit_char_is_binary_digit (source_p[0]));
}
#endif /* JERRY_ESNEXT */
else
{
can_be_float = true;
@@ -1379,12 +1287,11 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
can_be_bigint = false;
#endif /* JERRY_BUILTIN_BIGINT */
#if JERRY_ESNEXT
if (source_p < source_end_p && source_p[0] == LIT_CHAR_UNDERSCORE)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
}
#endif /* JERRY_ESNEXT */
lexer_check_numbers (context_p, &source_p, source_end_p, LIT_CHAR_9, false);
}
@@ -1522,7 +1429,6 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
* @param char4 fourth character
* @param type4 type of the fourth character
*/
#if JERRY_ESNEXT
#define LEXER_TYPE_D_TOKEN(char1, type1, char2, type2, char3, type3, char4, type4) \
case (uint8_t) (char1): \
{ \
@@ -1553,10 +1459,6 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
length = 1; \
break; \
}
#else /* !JERRY_ESNEXT */
#define LEXER_TYPE_D_TOKEN(char1, type1, char2, type2, char3, type3, char4, type4) \
LEXER_TYPE_C_TOKEN (char1, type1, char2, type2, char3, type3)
#endif /* JERRY_ESNEXT */
/**
* Get next token.
@@ -1566,10 +1468,10 @@ lexer_next_token (parser_context_t *context_p) /**< context */
{
size_t length;
#if JERRY_ESNEXT && JERRY_FUNCTION_TO_STRING
#if JERRY_FUNCTION_TO_STRING
/* Needed by arrow functions with expression body */
context_p->function_end_p = context_p->source_p;
#endif /* JERRY_ESNEXT && JERRY_FUNCTION_TO_STRING */
#endif /* JERRY_FUNCTION_TO_STRING */
lexer_skip_spaces (context_p);
@@ -1605,9 +1507,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
LEXER_TYPE_A_TOKEN (LIT_CHAR_RIGHT_SQUARE, LEXER_RIGHT_SQUARE);
LEXER_TYPE_A_TOKEN (LIT_CHAR_SEMICOLON, LEXER_SEMICOLON);
LEXER_TYPE_A_TOKEN (LIT_CHAR_COMMA, LEXER_COMMA);
#if JERRY_ESNEXT
LEXER_TYPE_A_TOKEN (LIT_CHAR_HASHMARK, LEXER_HASHMARK);
#endif /* JERRY_ESNEXT */
case (uint8_t) LIT_CHAR_DOT:
{
@@ -1617,14 +1517,12 @@ lexer_next_token (parser_context_t *context_p) /**< context */
return;
}
#if JERRY_ESNEXT
if (length >= 3 && context_p->source_p[1] == LIT_CHAR_DOT && context_p->source_p[2] == LIT_CHAR_DOT)
{
context_p->token.type = LEXER_THREE_DOTS;
length = 3;
break;
}
#endif /* JERRY_ESNEXT */
context_p->token.type = LEXER_DOT;
length = 1;
@@ -1728,14 +1626,12 @@ lexer_next_token (parser_context_t *context_p) /**< context */
break;
}
#if JERRY_ESNEXT
if (context_p->source_p[1] == (uint8_t) LIT_CHAR_GREATER_THAN)
{
context_p->token.type = LEXER_ARROW;
length = 2;
break;
}
#endif /* JERRY_ESNEXT */
}
context_p->token.type = LEXER_ASSIGN;
@@ -1783,7 +1679,6 @@ lexer_next_token (parser_context_t *context_p) /**< context */
break;
}
#if JERRY_ESNEXT
if (context_p->source_p[1] == (uint8_t) LIT_CHAR_ASTERISK)
{
if (length >= 3 && context_p->source_p[2] == (uint8_t) LIT_CHAR_EQUALS)
@@ -1797,7 +1692,6 @@ lexer_next_token (parser_context_t *context_p) /**< context */
length = 2;
break;
}
#endif /* JERRY_ESNEXT */
}
context_p->token.type = LEXER_MULTIPLY;
@@ -1830,7 +1724,6 @@ lexer_next_token (parser_context_t *context_p) /**< context */
LEXER_TYPE_A_TOKEN (LIT_CHAR_TILDE, LEXER_BIT_NOT);
case (uint8_t) (LIT_CHAR_QUESTION):
{
#if JERRY_ESNEXT
if (length >= 2)
{
if (context_p->source_p[1] == (uint8_t) LIT_CHAR_QUESTION)
@@ -1846,7 +1739,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
break;
}
}
#endif /* JERRY_ESNEXT */
context_p->token.type = LEXER_QUESTION_MARK;
length = 1;
break;
@@ -1856,9 +1749,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
case LIT_CHAR_SINGLE_QUOTE:
case LIT_CHAR_DOUBLE_QUOTE:
#if JERRY_ESNEXT
case LIT_CHAR_GRAVE_ACCENT:
#endif /* JERRY_ESNEXT */
{
lexer_parse_string (context_p, LEXER_STRING_NO_OPTS);
return;
@@ -1963,9 +1854,7 @@ lexer_check_post_primary_exp (parser_context_t *context_p) /**< context */
case LIT_CHAR_DOT:
case LIT_CHAR_LEFT_PAREN:
case LIT_CHAR_LEFT_SQUARE:
#if JERRY_ESNEXT
case LIT_CHAR_GRAVE_ACCENT:
#endif /* JERRY_ESNEXT */
{
return true;
}
@@ -1975,20 +1864,16 @@ lexer_check_post_primary_exp (parser_context_t *context_p) /**< context */
return (!(context_p->token.flags & LEXER_WAS_NEWLINE) && context_p->source_p + 1 < context_p->source_end_p
&& context_p->source_p[1] == context_p->source_p[0]);
}
#if JERRY_ESNEXT
case LIT_CHAR_ASTERISK:
{
return (context_p->source_p + 1 < context_p->source_end_p
&& context_p->source_p[1] == (uint8_t) LIT_CHAR_ASTERISK);
}
#endif /* JERRY_ESNEXT */
}
return false;
} /* lexer_check_post_primary_exp */
#if JERRY_ESNEXT
/**
* Checks whether the next token is a type used for detecting arrow functions.
*
@@ -2181,8 +2066,6 @@ lexer_scan_private_identifier (parser_context_t *context_p) /**< context */
return (context_p->source_p < context_p->source_end_p && lexer_parse_identifier (context_p, LEXER_PARSE_NO_OPTS));
} /* lexer_scan_private_identifier */
#endif /* JERRY_ESNEXT */
/**
* Convert an ident with escapes to a utf8 string.
*/
@@ -2204,7 +2087,6 @@ lexer_convert_ident_to_cesu8 (uint8_t *destination_p, /**< destination string */
continue;
}
#if JERRY_ESNEXT
if (*source_p >= LIT_UTF8_4_BYTE_MARKER)
{
lit_four_byte_utf8_char_to_cesu8 (destination_p, source_p);
@@ -2213,7 +2095,6 @@ lexer_convert_ident_to_cesu8 (uint8_t *destination_p, /**< destination string */
source_p += 4;
continue;
}
#endif /* JERRY_ESNEXT */
*destination_p++ = *source_p++;
} while (destination_p < destination_end_p);
@@ -2258,17 +2139,12 @@ lexer_convert_literal_to_chars (parser_context_t *context_p, /**< context */
uint8_t str_end_character = source_p[-1];
#if JERRY_ESNEXT
if (str_end_character == LIT_CHAR_RIGHT_BRACE)
{
str_end_character = LIT_CHAR_GRAVE_ACCENT;
}
bool is_raw = (opts & LEXER_STRING_RAW) != 0;
#else /* !JERRY_ESNEXT */
JERRY_UNUSED (opts);
bool is_raw = false;
#endif /* JERRY_ESNEXT */
while (true)
{
@@ -2399,7 +2275,6 @@ lexer_convert_literal_to_chars (parser_context_t *context_p, /**< context */
continue;
}
}
#if JERRY_ESNEXT
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT)
{
if (source_p[0] == LIT_CHAR_DOLLAR_SIGN && source_p[1] == LIT_CHAR_LEFT_BRACE)
@@ -2429,7 +2304,6 @@ lexer_convert_literal_to_chars (parser_context_t *context_p, /**< context */
}
}
}
#endif /* JERRY_ESNEXT */
if (*source_p >= LIT_UTF8_4_BYTE_MARKER)
{
@@ -2619,11 +2493,7 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
{
#endif /* JERRY_BUILTIN_BIGINT */
ecma_number_t num;
uint32_t options = 0;
#if JERRY_ESNEXT
options |= ECMA_CONVERSION_ALLOW_UNDERSCORE;
#endif /* JERRY_ESNEXT */
uint32_t options = ECMA_CONVERSION_ALLOW_UNDERSCORE;
if (context_p->token.extra_value == LEXER_NUMBER_OCTAL)
{
@@ -2820,7 +2690,6 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
parser_flush_cbc (context_p);
#if JERRY_ESNEXT
if (JERRY_LIKELY (!(extra_status_flags & PARSER_IS_ARROW_FUNCTION)))
{
compiled_code_p = parser_parse_function (context_p, extra_status_flags);
@@ -2829,9 +2698,6 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
{
compiled_code_p = parser_parse_arrow_function (context_p, extra_status_flags);
}
#else /* !JERRY_ESNEXT */
compiled_code_p = parser_parse_function (context_p, extra_status_flags);
#endif /* JERRY_ESNEXT */
literal_p->u.bytecode_p = compiled_code_p;
literal_p->type = LEXER_FUNCTION_LITERAL;
@@ -2839,7 +2705,6 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
return result_index;
} /* lexer_construct_function_object */
#if JERRY_ESNEXT
/**
* Construct a class static block function literal object.
*
@@ -2864,7 +2729,6 @@ lexer_construct_class_static_block_function (parser_context_t *context_p) /**< c
return result_index;
} /* lexer_construct_class_static_block_function */
#endif /* JERRY_ESNEXT */
/**
* Construct a regular expression object.
@@ -2987,12 +2851,10 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
{
flag = RE_FLAG_STICKY;
}
#if JERRY_ESNEXT
else if (source_p[0] == LIT_CHAR_LOWERCASE_S)
{
flag = RE_FLAG_DOTALL;
}
#endif /* JERRY_ESNEXT */
if (flag == 0)
{
@@ -3126,8 +2988,6 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
return;
}
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_ESNEXT
if (context_p->token.type == LEXER_KEYW_YIELD)
{
parser_raise_error (context_p, PARSER_ERR_YIELD_NOT_ALLOWED);
@@ -3136,7 +2996,6 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
{
parser_raise_error (context_p, PARSER_ERR_AWAIT_NOT_ALLOWED);
}
#endif /* JERRY_ESNEXT */
parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_EXPECTED);
} /* lexer_expect_identifier */
@@ -3175,12 +3034,9 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
lexer_skip_spaces (context_p);
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 JERRY_ESNEXT
&& context_p->source_p[0] != LIT_CHAR_COMMA && context_p->source_p[0] != LIT_CHAR_RIGHT_BRACE
&& context_p->source_p[0] != LIT_CHAR_LEFT_PAREN && context_p->source_p[0] != LIT_CHAR_SEMICOLON
&& context_p->source_p[0] != LIT_CHAR_EQUALS
#endif /* JERRY_ESNEXT */
if (context_p->source_p < context_p->source_end_p && context_p->source_p[0] != LIT_CHAR_COMMA
&& context_p->source_p[0] != LIT_CHAR_RIGHT_BRACE && context_p->source_p[0] != LIT_CHAR_LEFT_PAREN
&& context_p->source_p[0] != LIT_CHAR_SEMICOLON && context_p->source_p[0] != LIT_CHAR_EQUALS
&& context_p->source_p[0] != LIT_CHAR_COLON)
{
if (lexer_compare_literal_to_string (context_p, "get", 3))
@@ -3195,7 +3051,6 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
return;
}
#if JERRY_ESNEXT
if (lexer_compare_literal_to_string (context_p, "async", 5))
{
context_p->token.type = LEXER_KEYW_ASYNC;
@@ -3210,18 +3065,15 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
}
return;
}
#endif /* JERRY_ESNEXT */
}
}
create_literal_object = true;
}
#if JERRY_ESNEXT
else if (ident_opts & LEXER_OBJ_IDENT_CLASS_PRIVATE)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_CHARACTER);
}
#endif /* JERRY_ESNEXT */
else
{
switch (context_p->source_p[0])
@@ -3233,7 +3085,6 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
create_literal_object = true;
break;
}
#if JERRY_ESNEXT
case LIT_CHAR_LEFT_SQUARE:
{
#if JERRY_FUNCTION_TO_STRING
@@ -3276,7 +3127,6 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
break;
}
#endif /* JERRY_ESNEXT */
case LIT_CHAR_LEFT_BRACE:
{
const uint32_t static_block_flags =
@@ -3302,7 +3152,6 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
lexer_consume_next_character (context_p);
return;
}
#if JERRY_ESNEXT
case LIT_CHAR_DOT:
{
if (!(context_p->source_p + 1 >= context_p->source_end_p || lit_char_is_decimal_digit (context_p->source_p[1])))
@@ -3322,7 +3171,6 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
}
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
default:
{
const uint8_t *char_p = context_p->source_p;
@@ -3349,7 +3197,6 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
if (create_literal_object)
{
#if JERRY_ESNEXT
if (ident_opts & LEXER_OBJ_IDENT_CLASS_IDENTIFIER)
{
return;
@@ -3360,7 +3207,6 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
parser_resolve_private_identifier (context_p);
return;
}
#endif /* JERRY_ESNEXT */
lexer_construct_literal_object (context_p, &context_p->token.lit_location, LEXER_STRING_LITERAL);
return;
@@ -3405,12 +3251,9 @@ lexer_check_property_modifier (parser_context_t *context_p) /**< context */
lexer_skip_spaces (context_p);
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 JERRY_ESNEXT
|| context_p->source_p[0] == LIT_CHAR_COMMA || context_p->source_p[0] == LIT_CHAR_RIGHT_BRACE
|| context_p->source_p[0] == LIT_CHAR_LEFT_PAREN || context_p->source_p[0] == LIT_CHAR_EQUALS
#endif /* JERRY_ESNEXT */
|| context_p->source_p[0] == LIT_CHAR_COLON)
if (context_p->source_p >= context_p->source_end_p || context_p->source_p[0] == LIT_CHAR_COMMA
|| context_p->source_p[0] == LIT_CHAR_RIGHT_BRACE || context_p->source_p[0] == LIT_CHAR_LEFT_PAREN
|| context_p->source_p[0] == LIT_CHAR_EQUALS || context_p->source_p[0] == LIT_CHAR_COLON)
{
return;
}
@@ -3427,13 +3270,11 @@ lexer_check_property_modifier (parser_context_t *context_p) /**< context */
return;
}
#if JERRY_ESNEXT
if (lexer_compare_literal_to_string (context_p, "async", 5))
{
context_p->token.type = LEXER_KEYW_ASYNC;
return;
}
#endif /* JERRY_ESNEXT */
} /* lexer_check_property_modifier */
/**
@@ -3632,8 +3473,6 @@ lexer_string_is_directive (parser_context_t *context_p) /**< context */
&& context_p->token.type != LEXER_DOT));
} /* lexer_string_is_directive */
#if JERRY_ESNEXT
/**
* Compares the current token to an expected identifier.
*
@@ -3687,8 +3526,6 @@ lexer_token_is_async (parser_context_t *context_p) /**< context */
&& !(context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE));
} /* lexer_token_is_async */
#endif /* JERRY_ESNEXT */
/**
* Compares the current identifier or string to an expected string.
*
@@ -3749,17 +3586,10 @@ lexer_convert_binary_lvalue_token_to_binary (uint8_t token) /**< binary lvalue t
JERRY_ASSERT (LEXER_IS_BINARY_LVALUE_OP_TOKEN (token));
JERRY_ASSERT (token != LEXER_ASSIGN);
#if JERRY_ESNEXT
if (token <= LEXER_ASSIGN_EXPONENTIATION)
{
return (uint8_t) (LEXER_ADD + (token - LEXER_ASSIGN_ADD));
}
#else /* !JERRY_ESNEXT */
if (token <= LEXER_ASSIGN_MODULO)
{
return (uint8_t) (LEXER_ADD + (token - LEXER_ASSIGN_ADD));
}
#endif /* JERRY_ESNEXT */
if (token <= LEXER_ASSIGN_UNS_RIGHT_SHIFT)
{
+2 -25
View File
@@ -55,10 +55,8 @@ typedef enum
LEXER_LIT_TRUE, /**< true (not a keyword!) */
LEXER_LIT_FALSE, /**< false (not a keyword!) */
LEXER_LIT_NULL, /**< null (not a keyword!) */
#if JERRY_ESNEXT
LEXER_TEMPLATE_LITERAL, /**< multi segment template literal */
LEXER_THREE_DOTS, /**< ... (rest or spread operator) */
#endif /* JERRY_ESNEXT */
/* Unary operators
* IMPORTANT: update CBC_UNARY_OP_TOKEN_TO_OPCODE and
@@ -72,9 +70,7 @@ typedef enum
LEXER_BIT_NOT, /**< "~" */
LEXER_KEYW_VOID, /**< void */
LEXER_KEYW_TYPEOF, /**< typeof */
#if JERRY_ESNEXT
LEXER_KEYW_AWAIT, /**< await */
#endif /* JERRY_ESNEXT */
LEXER_KEYW_DELETE, /**< delete */
LEXER_INCREASE, /**< "++" */
LEXER_DECREASE, /**< "--" */
@@ -87,17 +83,11 @@ typedef enum
* Index of first binary operation opcode.
*/
#define LEXER_FIRST_BINARY_OP LEXER_ASSIGN
#if JERRY_ESNEXT
/**
* Index of last binary operation opcode.
*/
#define LEXER_LAST_BINARY_OP LEXER_EXPONENTIATION
#else /* !JERRY_ESNEXT */
/**
* Index of last binary operation opcode.
*/
#define LEXER_LAST_BINARY_OP LEXER_MODULO
#endif /* JERRY_ESNEXT */
/**
* Checks whether the token is a binary operation token.
@@ -121,12 +111,10 @@ typedef enum
LEXER_ASSIGN_MULTIPLY, /**< "*=" (prec: 3) */
LEXER_ASSIGN_DIVIDE, /**< "/=" (prec: 3) */
LEXER_ASSIGN_MODULO, /**< "%=" (prec: 3) */
#if JERRY_ESNEXT
LEXER_ASSIGN_EXPONENTIATION, /**< "**=" (prec: 3) */
LEXER_ASSIGN_NULLISH_COALESCING, /**< "??=" (prec: 3) */
LEXER_ASSIGN_LOGICAL_OR, /**< "||=" (prec: 3) */
LEXER_ASSIGN_LOGICAL_AND, /**< "&&=" (prec: 3) */
#endif /* JERRY_ESNEXT */
LEXER_ASSIGN_LEFT_SHIFT, /**< "<<=" (prec: 3) */
LEXER_ASSIGN_RIGHT_SHIFT, /**< ">>=" (prec: 3) */
LEXER_ASSIGN_UNS_RIGHT_SHIFT, /**< ">>>=" (prec: 3) */
@@ -134,9 +122,7 @@ typedef enum
LEXER_ASSIGN_BIT_OR, /**< "|=" (prec: 3) */
LEXER_ASSIGN_BIT_XOR, /**< "^=" (prec: 3) */
LEXER_QUESTION_MARK, /**< "?" (prec: 4) */
#if JERRY_ESNEXT
LEXER_NULLISH_COALESCING, /**< "??" (prec: 5) */
#endif /* JERRY_ESNEXT */
LEXER_LOGICAL_OR, /**< "||" (prec: 6) */
LEXER_LOGICAL_AND, /**< "&&" (prec: 7) */
LEXER_BIT_OR, /**< "|" (prec: 8) */
@@ -160,10 +146,7 @@ typedef enum
LEXER_MULTIPLY, /**< "*" (prec: 15) */
LEXER_DIVIDE, /**< "/" (prec: 15) */
LEXER_MODULO, /**< "%" (prec: 15) */
#if JERRY_ESNEXT
LEXER_EXPONENTIATION, /**< "**" (prec: 16) */
#endif /* JERRY_ESNEXT */
LEXER_LEFT_BRACE, /**< "{" */
LEXER_LEFT_PAREN, /**< "(" */
LEXER_LEFT_SQUARE, /**< "[" */
@@ -174,10 +157,8 @@ typedef enum
LEXER_SEMICOLON, /**< ";" */
LEXER_COLON, /**< ":" */
LEXER_COMMA, /**< "," */
#if JERRY_ESNEXT
LEXER_ARROW, /**< "=>" */
LEXER_HASHMARK, /**< "#" */
#endif /* JERRY_ESNEXT */
LEXER_KEYW_BREAK, /**< break */
LEXER_KEYW_DO, /**< do */
@@ -215,18 +196,14 @@ typedef enum
LEXER_PROPERTY_GETTER, /**< property getter function */
LEXER_PROPERTY_SETTER, /**< property setter function */
LEXER_COMMA_SEP_LIST, /**< comma separated bracketed expression list */
#if JERRY_ESNEXT
LEXER_ASSIGN_GROUP_EXPR, /**< indetifier for the assignment is located in a group expression */
LEXER_ASSIGN_CONST, /**< a const binding is reassigned */
LEXER_INVALID_PATTERN, /**< special value for invalid destructuring pattern */
LEXER_PRIVATE_PRIMARY_EXPR, /**< private field in primary expession position */
LEXER_ASSIGN_REFERENCE, /**< special value for reference assignment */
#endif /* JERRY_ESNEXT */
/* Keywords which are not keyword tokens. */
#if JERRY_ESNEXT
/* Keywords which are not keyword tokens. */
LEXER_KEYW_ASYNC, /**< async */
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
LEXER_KEYW_META, /**< meta */
#endif /* JERRY_MODULE_SYSTEM */
File diff suppressed because it is too large Load Diff
+1 -52
View File
@@ -57,7 +57,6 @@ typedef enum
* after the last byte code */
PARSER_DEBUGGER_BREAKPOINT_APPENDED = (1u << 11), /**< pending (unsent) breakpoint
* info is available */
#if JERRY_ESNEXT
PARSER_LEXICAL_BLOCK_NEEDED = (1u << 12), /**< global script: needs a lexical environment for let and const
* function: needs a lexical environment for arguments */
PARSER_IS_ARROW_FUNCTION = (1u << 13), /**< an arrow function is parsed */
@@ -79,7 +78,6 @@ typedef enum
PARSER_IS_CLASS_STATIC_BLOCK = (1u << 26), /**< a class static block is parsed */
PARSER_PRIVATE_FUNCTION_NAME = PARSER_IS_FUNC_EXPRESSION, /**< represents private method for
* parser_set_function_name*/
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
PARSER_MODULE_DEFAULT_CLASS_OR_FUNC = (1u << 27), /**< parsing a function or class default export */
PARSER_MODULE_STORE_IDENT = (1u << 28), /**< store identifier of the current export statement */
@@ -128,14 +126,10 @@ typedef enum
typedef enum
{
PARSER_CHECK_BLOCK_CONTEXT, /**< check block context */
#if JERRY_ESNEXT
PARSER_CHECK_GLOBAL_CONTEXT, /**< check global context */
PARSER_CHECK_FUNCTION_CONTEXT, /**< check function context */
#endif /* JERRY_ESNEXT */
} parser_check_context_type_t;
#if JERRY_ESNEXT
/**
* Class field bits.
*/
@@ -148,8 +142,6 @@ typedef enum
PARSER_CLASS_FIELD_STATIC_BLOCK = (1u << 4), /**< static class field */
} parser_class_field_type_t;
#endif /* JERRY_ESNEXT */
/**
* Mask for strict mode code
*/
@@ -172,7 +164,6 @@ typedef enum
#define PARSER_MAX_BRANCH_LENGTH 3
#endif /* PARSER_MAXIMUM_CODE_SIZE <= UINT16_MAX */
#if JERRY_ESNEXT
/**
* Offset of PARSER_ALLOW_SUPER
*/
@@ -222,15 +213,6 @@ typedef enum
#define PARSER_IS_NORMAL_ASYNC_FUNCTION(status_flags) \
(((status_flags) & (PARSER_IS_GENERATOR_FUNCTION | PARSER_IS_ASYNC_FUNCTION)) == PARSER_IS_ASYNC_FUNCTION)
#else /* !JERRY_ESNEXT */
/**
* All flags that affect exotic arguments object creation.
*/
#define PARSER_ARGUMENTS_RELATED_FLAGS (PARSER_ARGUMENTS_NEEDED | PARSER_IS_STRICT)
#endif /* JERRY_ESNEXT */
/* Checks whether unmapped arguments are needed. */
#define PARSER_NEEDS_MAPPED_ARGUMENTS(status_flags) \
(((status_flags) &PARSER_ARGUMENTS_RELATED_FLAGS) == PARSER_ARGUMENTS_NEEDED)
@@ -403,8 +385,6 @@ typedef struct
*/
#define PARSER_SCOPE_STACK_FUNC 0xffff
#if JERRY_ESNEXT
/**
* Mask for decoding the register index of map_to
*/
@@ -426,8 +406,6 @@ typedef struct
*/
#define PARSER_SCOPE_STACK_IS_LOCAL_CREATED (PARSER_SCOPE_STACK_IS_CONST_REG)
#endif /* JERRY_ESNEXT */
/**
* Starting literal index for registers.
*/
@@ -485,7 +463,6 @@ typedef struct
#endif /* JERRY_LINE_INFO */
#if JERRY_ESNEXT
/**
* List of private field contexts
*/
@@ -495,7 +472,6 @@ typedef struct parser_private_context_t
struct parser_private_context_t *prev_p; /**< previous private field context */
uint8_t opts; /**< options */
} parser_private_context_t;
#endif /* JERRY_ESNEXT */
/**
* Those members of a context which needs
@@ -512,9 +488,7 @@ typedef struct parser_saved_context_t
/* Literal types */
uint16_t argument_count; /**< number of function arguments */
#if JERRY_ESNEXT
uint16_t argument_length; /**< length property of arguments */
#endif /* JERRY_ESNEXT */
uint16_t register_count; /**< number of registers */
uint16_t literal_count; /**< number of literals */
@@ -526,11 +500,8 @@ typedef struct parser_saved_context_t
uint16_t scope_stack_size; /**< size of scope stack */
uint16_t scope_stack_top; /**< preserved top of scope stack */
uint16_t scope_stack_reg_top; /**< preserved top register of scope stack */
#if JERRY_ESNEXT
uint16_t scope_stack_global_end; /**< end of global declarations of a function */
ecma_value_t tagged_template_literal_cp; /**< compessed pointer to the tagged template literal collection */
#endif /* JERRY_ESNEXT */
#ifndef JERRY_NDEBUG
uint16_t context_stack_depth; /**< current context stack depth */
#endif /* !JERRY_NDEBUG */
@@ -602,9 +573,7 @@ typedef struct
/* Literal types */
uint16_t argument_count; /**< number of function arguments */
#if JERRY_ESNEXT
uint16_t argument_length; /**< length property of arguments */
#endif /* JERRY_ESNEXT */
uint16_t register_count; /**< number of registers */
uint16_t literal_count; /**< number of literals */
@@ -618,11 +587,9 @@ typedef struct
uint16_t scope_stack_size; /**< size of scope stack */
uint16_t scope_stack_top; /**< current top of scope stack */
uint16_t scope_stack_reg_top; /**< current top register of scope stack */
#if JERRY_ESNEXT
uint16_t scope_stack_global_end; /**< end of global declarations of a function */
ecma_value_t tagged_template_literal_cp; /**< compessed pointer to the tagged template literal collection */
parser_private_context_t *private_context_p; /**< private context */
#endif /* JERRY_ESNEXT */
uint8_t stack_top_uint8; /**< top byte stored on the stack */
#ifndef JERRY_NDEBUG
@@ -738,6 +705,7 @@ ecma_string_t *parser_new_ecma_string_from_literal (lexer_literal_t *literal_p);
void parser_set_branch_to_current_position (parser_context_t *context_p, parser_branch_t *branch_p);
void parser_set_breaks_to_current_position (parser_context_t *context_p, parser_branch_node_t *current_p);
void parser_set_continues_to_current_position (parser_context_t *context_p, parser_branch_node_t *current_p);
void parser_reverse_class_fields (parser_context_t *context_p, size_t fields_size);
/* Convenience macros. */
#define parser_emit_cbc_ext(context_p, opcode) parser_emit_cbc ((context_p), PARSER_TO_EXT_OPCODE (opcode))
@@ -754,10 +722,6 @@ void parser_set_continues_to_current_position (parser_context_t *context_p, pars
#define parser_emit_cbc_ext_backward_branch(context_p, opcode, offset) \
parser_emit_cbc_backward_branch ((context_p), PARSER_TO_EXT_OPCODE (opcode), (offset))
#if JERRY_ESNEXT
void parser_reverse_class_fields (parser_context_t *context_p, size_t fields_size);
#endif /* JERRY_ESNEXT */
/**
* @}
*
@@ -772,7 +736,6 @@ bool lexer_check_next_character (parser_context_t *context_p, lit_utf8_byte_t ch
bool lexer_check_next_characters (parser_context_t *context_p, lit_utf8_byte_t character1, lit_utf8_byte_t character2);
uint8_t lexer_consume_next_character (parser_context_t *context_p);
bool lexer_check_post_primary_exp (parser_context_t *context_p);
#if JERRY_ESNEXT
void lexer_skip_empty_statements (parser_context_t *context_p);
bool lexer_check_arrow (parser_context_t *context_p);
bool lexer_check_arrow_param (parser_context_t *context_p);
@@ -781,7 +744,6 @@ bool lexer_consume_generator (parser_context_t *context_p);
bool lexer_consume_assign (parser_context_t *context_p);
void lexer_update_await_yield (parser_context_t *context_p, uint32_t status_flags);
bool lexer_scan_private_identifier (parser_context_t *context_p);
#endif /* JERRY_ESNEXT */
void lexer_parse_string (parser_context_t *context_p, lexer_string_options_t opts);
void lexer_expect_identifier (parser_context_t *context_p, uint8_t literal_type);
bool lexer_scan_identifier (parser_context_t *context_p, lexer_parse_options_t opts);
@@ -800,9 +762,7 @@ void lexer_construct_literal_object (parser_context_t *context_p,
bool lexer_construct_number_object (parser_context_t *context_p, bool is_expr, bool is_negative_number);
void lexer_convert_push_number_to_push_literal (parser_context_t *context_p);
uint16_t lexer_construct_function_object (parser_context_t *context_p, uint32_t extra_status_flags);
#if JERRY_ESNEXT
uint16_t lexer_construct_class_static_block_function (parser_context_t *context_p);
#endif /* JERRY_ESNEXT */
void lexer_construct_regexp_object (parser_context_t *context_p, bool parse_only);
bool lexer_compare_identifier_to_string (const lexer_lit_location_t *left_p, const uint8_t *right_p, size_t size);
bool lexer_compare_identifiers (parser_context_t *context_p,
@@ -811,11 +771,9 @@ bool lexer_compare_identifiers (parser_context_t *context_p,
bool lexer_current_is_literal (parser_context_t *context_p, const lexer_lit_location_t *right_ident_p);
bool lexer_string_is_use_strict (parser_context_t *context_p);
bool lexer_string_is_directive (parser_context_t *context_p);
#if JERRY_ESNEXT
bool lexer_token_is_identifier (parser_context_t *context_p, const char *identifier_p, size_t identifier_length);
bool lexer_token_is_let (parser_context_t *context_p);
bool lexer_token_is_async (parser_context_t *context_p);
#endif /* JERRY_ESNEXT */
bool lexer_compare_literal_to_string (parser_context_t *context_p, const char *string_p, size_t string_length);
void lexer_init_line_info (parser_context_t *context_p);
uint8_t lexer_convert_binary_lvalue_token_to_binary (uint8_t token);
@@ -832,7 +790,6 @@ 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 JERRY_ESNEXT
void parser_resolve_private_identifier (parser_context_t *context_p);
void parser_save_private_context (parser_context_t *context_p,
parser_private_context_t *private_ctx_p,
@@ -841,8 +798,6 @@ void parser_restore_private_context (parser_context_t *context_p, parser_private
void parser_parse_class (parser_context_t *context_p, bool is_statement);
void parser_parse_initializer (parser_context_t *context_p, parser_pattern_flags_t flags);
void parser_parse_initializer_by_next_char (parser_context_t *context_p, parser_pattern_flags_t flags);
#endif /* JERRY_ESNEXT */
/**
* @}
*
@@ -861,21 +816,17 @@ void scanner_reverse_info_list (parser_context_t *context_p);
void scanner_cleanup (parser_context_t *context_p);
bool scanner_is_context_needed (parser_context_t *context_p, parser_check_context_type_t check_type);
#if JERRY_ESNEXT
bool scanner_try_scan_new_target (parser_context_t *context_p);
void scanner_check_variables (parser_context_t *context_p);
#endif /* JERRY_ESNEXT */
void scanner_create_variables (parser_context_t *context_p, uint32_t option_flags);
void scanner_get_location (scanner_location_t *location_p, parser_context_t *context_p);
void scanner_set_location (parser_context_t *context_p, scanner_location_t *location_p);
uint16_t scanner_decode_map_to (parser_scope_stack_t *stack_item_p);
#if JERRY_ESNEXT
uint16_t scanner_save_literal (parser_context_t *context_p, uint16_t ident_index);
bool scanner_literal_is_const_reg (parser_context_t *context_p, uint16_t literal_index);
bool scanner_literal_is_created (parser_context_t *context_p, uint16_t literal_index);
bool scanner_literal_exists (parser_context_t *context_p, uint16_t literal_index);
#endif /* JERRY_ESNEXT */
void scanner_scan_all (parser_context_t *context_p);
@@ -935,7 +886,6 @@ uint8_t *parser_line_info_generate (parser_context_t *context_p);
*/
ecma_compiled_code_t *parser_parse_function (parser_context_t *context_p, uint32_t status_flags);
#if JERRY_ESNEXT
ecma_compiled_code_t *parser_parse_class_static_block (parser_context_t *context_p);
ecma_compiled_code_t *parser_parse_arrow_function (parser_context_t *context_p, uint32_t status_flags);
ecma_compiled_code_t *parser_parse_class_fields (parser_context_t *context_p);
@@ -948,7 +898,6 @@ void parser_compiled_code_set_function_name (parser_context_t *context_p,
uint16_t name_index,
uint32_t status_flags);
uint16_t parser_check_anonymous_function_declaration (parser_context_t *context_p);
#endif /* JERRY_ESNEXT */
/* Error management. */
+3 -173
View File
@@ -43,12 +43,10 @@ typedef enum
{
PARSER_STATEMENT_START,
PARSER_STATEMENT_BLOCK,
#if JERRY_ESNEXT
PARSER_STATEMENT_BLOCK_SCOPE,
PARSER_STATEMENT_PRIVATE_SCOPE,
PARSER_STATEMENT_BLOCK_CONTEXT,
PARSER_STATEMENT_PRIVATE_CONTEXT,
#endif /* JERRY_ESNEXT */
PARSER_STATEMENT_LABEL,
PARSER_STATEMENT_IF,
PARSER_STATEMENT_ELSE,
@@ -58,10 +56,8 @@ typedef enum
PARSER_STATEMENT_WHILE,
PARSER_STATEMENT_FOR,
PARSER_STATEMENT_FOR_IN,
#if JERRY_ESNEXT
PARSER_STATEMENT_FOR_OF,
PARSER_STATEMENT_FOR_AWAIT_OF,
#endif /* JERRY_ESNEXT */
PARSER_STATEMENT_WITH,
PARSER_STATEMENT_TRY,
} parser_statement_type_t;
@@ -88,7 +84,6 @@ static const uint8_t parser_statement_flags[] = {
PARSER_STATM_HAS_BLOCK,
/* PARSER_STATEMENT_BLOCK, */
PARSER_STATM_HAS_BLOCK,
#if JERRY_ESNEXT
/* PARSER_STATEMENT_BLOCK_SCOPE, */
PARSER_STATM_HAS_BLOCK,
/* PARSER_STATEMENT_PRIVATE_SCOPE, */
@@ -97,7 +92,6 @@ static const uint8_t parser_statement_flags[] = {
PARSER_STATM_HAS_BLOCK | PARSER_STATM_CONTEXT_BREAK,
/* PARSER_STATEMENT_PRIVATE_CONTEXT, */
PARSER_STATM_CONTEXT_BREAK,
#endif /* JERRY_ESNEXT */
/* PARSER_STATEMENT_LABEL */
PARSER_STATM_SINGLE_STATM,
/* PARSER_STATEMENT_IF */
@@ -116,19 +110,16 @@ static const uint8_t parser_statement_flags[] = {
PARSER_STATM_BREAK_TARGET | PARSER_STATM_CONTINUE_TARGET | PARSER_STATM_SINGLE_STATM,
/* PARSER_STATEMENT_FOR_IN */
PARSER_STATM_BREAK_TARGET | PARSER_STATM_CONTINUE_TARGET | PARSER_STATM_SINGLE_STATM | PARSER_STATM_CONTEXT_BREAK,
#if JERRY_ESNEXT
/* PARSER_STATEMENT_FOR_OF */
PARSER_STATM_BREAK_TARGET | PARSER_STATM_CONTINUE_TARGET | PARSER_STATM_SINGLE_STATM | PARSER_STATM_CONTEXT_BREAK,
/* PARSER_STATEMENT_FOR_AWAIT_OF */
PARSER_STATM_BREAK_TARGET | PARSER_STATM_CONTINUE_TARGET | PARSER_STATM_SINGLE_STATM | PARSER_STATM_CONTEXT_BREAK,
#endif /* JERRY_ESNEXT */
/* PARSER_STATEMENT_WITH */
PARSER_STATM_CONTEXT_BREAK | PARSER_STATM_SINGLE_STATM,
/* PARSER_STATEMENT_TRY */
PARSER_STATM_HAS_BLOCK | PARSER_STATM_CONTEXT_BREAK
};
#if JERRY_ESNEXT
/**
* Block statement.
*/
@@ -146,8 +137,6 @@ typedef struct
parser_branch_t branch; /**< branch to the end */
} parser_block_context_t;
#endif /* !JERRY_ESNEXT */
/**
* Loop statement.
*/
@@ -261,7 +250,6 @@ parser_statement_length (uint8_t type) /**< type of statement */
static const uint8_t statement_lengths[] = {
/* PARSER_STATEMENT_BLOCK */
1,
#if JERRY_ESNEXT
/* PARSER_STATEMENT_BLOCK_SCOPE */
(uint8_t) (sizeof (parser_block_statement_t) + 1),
/* PARSER_STATEMENT_PRIVATE_SCOPE */
@@ -270,7 +258,6 @@ parser_statement_length (uint8_t type) /**< type of statement */
(uint8_t) (sizeof (parser_block_statement_t) + sizeof (parser_block_context_t) + 1),
/* PARSER_STATEMENT_PRIVATE_CONTEXT */
(uint8_t) (sizeof (parser_block_statement_t) + sizeof (parser_block_context_t) + 1),
#endif /* JERRY_ESNEXT */
/* PARSER_STATEMENT_LABEL */
(uint8_t) (sizeof (parser_label_statement_t) + 1),
/* PARSER_STATEMENT_IF */
@@ -289,12 +276,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 JERRY_ESNEXT
/* PARSER_STATEMENT_FOR_OF */
(uint8_t) (sizeof (parser_for_in_of_statement_t) + sizeof (parser_loop_statement_t) + 1),
/* PARSER_STATEMENT_FOR_AWAIT_OF */
(uint8_t) (sizeof (parser_for_in_of_statement_t) + sizeof (parser_loop_statement_t) + 1),
#endif /* JERRY_ESNEXT */
/* PARSER_STATEMENT_WITH */
(uint8_t) (sizeof (parser_with_statement_t) + 1 + 1),
/* PARSER_STATEMENT_TRY */
@@ -328,8 +313,6 @@ parser_parse_enclosed_expr (parser_context_t *context_p) /**< context */
lexer_next_token (context_p);
} /* parser_parse_enclosed_expr */
#if JERRY_ESNEXT
/**
* Create a block context.
*
@@ -431,7 +414,6 @@ parser_validate_lexical_context (parser_context_t *context_p) /**< context */
parser_raise_error (context_p, PARSER_ERR_LEXICAL_SINGLE_STATEMENT);
}
} /* parser_validate_lexical_context */
#endif /* JERRY_ESNEXT */
/**
* Parse var statement.
@@ -442,18 +424,15 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
JERRY_ASSERT (context_p->token.type == LEXER_KEYW_VAR || context_p->token.type == LEXER_KEYW_LET
|| context_p->token.type == LEXER_KEYW_CONST);
#if JERRY_ESNEXT
uint8_t declaration_type = context_p->token.type;
if (declaration_type != LEXER_KEYW_VAR)
{
parser_validate_lexical_context (context_p);
}
#endif /* JERRY_ESNEXT */
while (true)
{
#if JERRY_ESNEXT
if (lexer_check_next_characters (context_p, LIT_CHAR_LEFT_SQUARE, LIT_CHAR_LEFT_BRACE))
{
parser_pattern_flags_t flags = PARSER_PATTERN_BINDING;
@@ -471,7 +450,6 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
}
else
{
#endif /* JERRY_ESNEXT */
lexer_expect_identifier (context_p, LEXER_IDENT_LITERAL);
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
@@ -487,7 +465,6 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
parser_module_append_export_name (context_p);
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_ESNEXT
if (declaration_type != LEXER_KEYW_VAR && context_p->token.keyword_type == LEXER_KEYW_LET)
{
parser_raise_error (context_p, PARSER_ERR_LEXICAL_LET_BINDING);
@@ -498,7 +475,6 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_ERR_REDECLARED);
parser_raise_error (context_p, PARSER_ERR_VARIABLE_REDECLARED);
}
#endif /* JERRY_ESNEXT */
lexer_next_token (context_p);
@@ -528,7 +504,6 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
cbc_opcode_t opcode = CBC_ASSIGN_SET_IDENT;
#if JERRY_ESNEXT
uint16_t function_literal_index = parser_check_anonymous_function_declaration (context_p);
if (function_literal_index == PARSER_ANONYMOUS_CLASS)
@@ -554,11 +529,9 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
opcode = CBC_INIT_CONST;
}
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc_literal (context_p, (uint16_t) opcode, index);
}
#if JERRY_ESNEXT
else if (declaration_type == LEXER_KEYW_LET)
{
parser_emit_cbc (context_p, CBC_PUSH_UNDEFINED);
@@ -578,7 +551,6 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
parser_raise_error (context_p, PARSER_ERR_MISSING_ASSIGN_AFTER_CONST);
}
}
#endif /* JERRY_ESNEXT */
if (context_p->token.type != LEXER_COMMA)
{
@@ -599,7 +571,6 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
{
JERRY_ASSERT (context_p->token.type == LEXER_KEYW_FUNCTION);
#if JERRY_ESNEXT
bool is_single_statement = (parser_statement_flags[context_p->stack_top_uint8] & PARSER_STATM_SINGLE_STATM) != 0;
if (JERRY_UNLIKELY (is_single_statement))
@@ -646,17 +617,11 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
parser_raise_error (context_p, PARSER_ERR_LEXICAL_SINGLE_STATEMENT);
}
}
#endif /* JERRY_ESNEXT */
#if JERRY_FUNCTION_TO_STRING
#if JERRY_ESNEXT
if (!(context_p->next_scanner_info_p->u8_arg & SCANNER_FUNCTION_ASYNC))
{
context_p->function_start_p = context_p->token.lit_location.char_p;
}
#else /* !JERRY_ESNEXT */
context_p->function_start_p = context_p->token.lit_location.char_p;
#endif /* JERRY_ESNEXT */
#endif /* JERRY_FUNCTION_TO_STRING */
#if JERRY_DEBUGGER
@@ -664,7 +629,6 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
parser_line_counter_t debugger_column = context_p->token.column;
#endif /* JERRY_DEBUGGER */
#if JERRY_ESNEXT
bool is_generator_function = false;
if (lexer_consume_generator (context_p))
@@ -675,12 +639,10 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
}
is_generator_function = true;
}
#endif /* JERRY_ESNEXT */
lexer_expect_identifier (context_p, LEXER_NEW_IDENT_LITERAL);
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL && context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
#if JERRY_ESNEXT
if (context_p->next_scanner_info_p->source_p == context_p->source_p
&& context_p->next_scanner_info_p->type == SCANNER_TYPE_ERR_REDECLARED)
{
@@ -688,7 +650,6 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
}
uint16_t function_name_index = context_p->lit_object.index;
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
parser_module_append_export_name (context_p);
@@ -702,7 +663,6 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
status_flags |= PARSER_HAS_NON_STRICT_ARG;
}
#if JERRY_ESNEXT
if (is_generator_function)
{
status_flags |= PARSER_IS_GENERATOR_FUNCTION | PARSER_DISALLOW_AWAIT_YIELD;
@@ -712,7 +672,6 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
{
status_flags |= PARSER_IS_ASYNC_FUNCTION | PARSER_DISALLOW_AWAIT_YIELD;
}
#endif /* JERRY_ESNEXT */
#if JERRY_DEBUGGER
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
@@ -743,7 +702,6 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
JERRY_ASSERT (scope_stack_p[1].map_from == PARSER_SCOPE_STACK_FUNC);
#if JERRY_ESNEXT
if (!(context_p->status_flags & PARSER_IS_STRICT)
&& (scope_stack_p >= context_p->scope_stack_p + context_p->scope_stack_global_end))
{
@@ -789,7 +747,6 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
parser_pop_block_context (context_p);
}
}
#endif /* JERRY_ESNEXT */
lexer_literal_t *literal_p = PARSER_GET_LITERAL ((size_t) scope_stack_p[1].map_to);
@@ -806,10 +763,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
literal_p->u.bytecode_p = compiled_code_p;
literal_p->type = LEXER_FUNCTION_LITERAL;
#if JERRY_ESNEXT
parser_compiled_code_set_function_name (context_p, compiled_code_p, function_name_index, 0);
#endif /* JERRY_ESNEXT */
lexer_next_token (context_p);
} /* parser_parse_function_statement */
@@ -1140,12 +1094,7 @@ parser_check_left_hand_side_expression (parser_context_t *context_p, /**< contex
else
{
/* Invalid LeftHandSide expression. */
#if JERRY_ESNEXT
parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_FOR_LOOP);
#else /* !JERRY_ESNEXT */
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR);
#endif /* JERRY_ESNEXT */
return CBC_ASSIGN;
}
@@ -1162,8 +1111,6 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
JERRY_ASSERT (context_p->token.type == LEXER_KEYW_FOR);
lexer_next_token (context_p);
#if JERRY_ESNEXT
bool is_for_await = false;
if (context_p->token.type == LEXER_KEYW_AWAIT)
@@ -1175,17 +1122,15 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
lexer_next_token (context_p);
is_for_await = true;
}
#endif /* JERRY_ESNEXT */
if (context_p->token.type != LEXER_LEFT_PAREN)
{
#if JERRY_ESNEXT
if (context_p->token.type == LEXER_LITERAL && context_p->token.keyword_type == LEXER_KEYW_AWAIT
&& !(context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))
{
parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_ASYNC);
}
#endif /* JERRY_ESNEXT */
parser_raise_error (context_p, PARSER_ERR_LEFT_PAREN_EXPECTED);
}
@@ -1194,7 +1139,6 @@ 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 JERRY_ESNEXT
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN
|| context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_OF);
@@ -1245,29 +1189,18 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
}
scanner_set_location (context_p, &end_location);
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN);
bool is_for_in = true;
scanner_get_location (&start_location, context_p);
scanner_set_location (context_p, &((scanner_location_info_t *) context_p->next_scanner_info_p)->location);
scanner_release_next (context_p, sizeof (scanner_location_info_t));
#endif /* JERRY_ESNEXT */
/* The length of both 'in' and 'of' is two. */
const uint8_t *source_end_p = context_p->source_p - 2;
scanner_seek (context_p);
#if JERRY_ESNEXT
if (is_for_in && is_for_await)
{
context_p->token.line = context_p->line;
context_p->token.column = context_p->column - 2;
parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_OF);
}
#endif /* JERRY_ESNEXT */
lexer_next_token (context_p);
int options = is_for_in ? PARSE_EXPR : PARSE_EXPR_NO_COMMA;
@@ -1285,24 +1218,20 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
cbc_ext_opcode_t init_opcode = CBC_EXT_FOR_IN_INIT;
#if JERRY_ESNEXT
if (!is_for_in)
{
init_opcode = is_for_await ? CBC_EXT_FOR_AWAIT_OF_INIT : CBC_EXT_FOR_OF_INIT;
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc_ext_forward_branch (context_p, init_opcode, &for_in_of_statement.branch);
JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
for_in_of_statement.start_offset = context_p->byte_code_size;
#if JERRY_ESNEXT
if (has_context)
{
parser_emit_cbc_ext (context_p, CBC_EXT_CLONE_CONTEXT);
}
#endif /* JERRY_ESNEXT */
/* The expression parser must not read the 'in' or 'of' tokens. */
scanner_get_location (&end_location, context_p);
@@ -1312,7 +1241,6 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
context_p->source_end_p = source_end_p;
scanner_seek (context_p);
#if JERRY_ESNEXT
if (token_type == LEXER_EOS)
{
lexer_next_token (context_p);
@@ -1322,21 +1250,13 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
token_type = context_p->token.type;
}
}
#else /* !JERRY_ESNEXT */
lexer_next_token (context_p);
uint8_t token_type = context_p->token.type;
#endif /* JERRY_ESNEXT */
switch (token_type)
{
#if JERRY_ESNEXT
case LEXER_KEYW_LET:
case LEXER_KEYW_CONST:
#endif /* JERRY_ESNEXT */
case LEXER_KEYW_VAR:
{
#if JERRY_ESNEXT
if (lexer_check_next_characters (context_p, LIT_CHAR_LEFT_SQUARE, LIT_CHAR_LEFT_BRACE))
{
parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT : CBC_EXT_FOR_OF_GET_NEXT);
@@ -1373,16 +1293,13 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
parser_parse_initializer_by_next_char (context_p, flags);
break;
}
#endif /* JERRY_ESNEXT */
lexer_expect_identifier (context_p, LEXER_IDENT_LITERAL);
#if JERRY_ESNEXT
if (context_p->token.keyword_type == LEXER_KEYW_LET && token_type != LEXER_KEYW_VAR)
{
parser_raise_error (context_p, PARSER_ERR_LEXICAL_LET_BINDING);
}
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
@@ -1392,12 +1309,10 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
if (context_p->token.type == LEXER_ASSIGN)
{
#if JERRY_ESNEXT
if ((context_p->status_flags & PARSER_IS_STRICT) || !is_for_in)
{
parser_raise_error (context_p, PARSER_ERR_FOR_IN_OF_DECLARATION);
}
#endif /* JERRY_ESNEXT */
parser_branch_t branch;
/* Initialiser is never executed. */
@@ -1408,7 +1323,6 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
}
parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT : CBC_EXT_FOR_OF_GET_NEXT);
#if JERRY_ESNEXT
#ifndef JERRY_NDEBUG
if (literal_index < PARSER_REGISTER_START && has_context
&& !scanner_literal_is_created (context_p, literal_index))
@@ -1419,12 +1333,8 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
uint16_t opcode = (has_context ? CBC_ASSIGN_LET_CONST : CBC_ASSIGN_SET_IDENT);
parser_emit_cbc_literal (context_p, opcode, literal_index);
#else /* !JERRY_ESNEXT */
parser_emit_cbc_literal (context_p, CBC_ASSIGN_SET_IDENT, literal_index);
#endif /* JERRY_ESNEXT */
break;
}
#if JERRY_ESNEXT
case LEXER_LEFT_BRACE:
case LEXER_LEFT_SQUARE:
{
@@ -1449,7 +1359,6 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
}
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
default:
{
uint16_t opcode;
@@ -1473,11 +1382,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
if (context_p->token.type != LEXER_EOS)
{
#if JERRY_ESNEXT
parser_raise_error (context_p, is_for_in ? PARSER_ERR_IN_EXPECTED : PARSER_ERR_OF_EXPECTED);
#else /* !JERRY_ESNEXT */
parser_raise_error (context_p, PARSER_ERR_IN_EXPECTED);
#endif /* JERRY_ESNEXT */
}
parser_flush_cbc (context_p);
@@ -1492,12 +1397,10 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
uint8_t for_type = PARSER_STATEMENT_FOR_IN;
#if JERRY_ESNEXT
if (!is_for_in)
{
for_type = is_for_await ? PARSER_STATEMENT_FOR_AWAIT_OF : PARSER_STATEMENT_FOR_OF;
}
#endif /* JERRY_ESNEXT */
parser_stack_push_uint8 (context_p, for_type);
parser_stack_iterator_init (context_p, &context_p->last_statement);
@@ -1508,13 +1411,10 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
if (context_p->token.type != LEXER_SEMICOLON)
{
#if JERRY_ESNEXT
const uint8_t *source_p = context_p->source_p;
#endif /* JERRY_ESNEXT */
switch (context_p->token.type)
{
#if JERRY_ESNEXT
case LEXER_LITERAL:
{
if (!lexer_token_is_let (context_p))
@@ -1551,7 +1451,6 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
}
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
case LEXER_KEYW_VAR:
{
parser_parse_var_statement (context_p);
@@ -1570,12 +1469,10 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
}
}
#if JERRY_ESNEXT
if (is_for_await)
{
parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_OF);
}
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (context_p->next_scanner_info_p->source_p != context_p->source_p
|| context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR);
@@ -1652,7 +1549,6 @@ parser_parse_for_statement_end (parser_context_t *context_p) /**< context */
parser_stack_iterator_skip (&iterator, sizeof (parser_loop_statement_t));
parser_stack_iterator_read (&iterator, &for_statement, sizeof (parser_for_statement_t));
#if JERRY_ESNEXT
bool has_block_context = false;
uint8_t next_statement_type;
@@ -1663,7 +1559,6 @@ parser_parse_for_statement_end (parser_context_t *context_p) /**< context */
{
has_block_context = true;
}
#endif /* JERRY_ESNEXT */
scanner_get_location (&location, context_p);
current_token = context_p->token;
@@ -1674,12 +1569,10 @@ parser_parse_for_statement_end (parser_context_t *context_p) /**< context */
parser_set_continues_to_current_position (context_p, loop.branch_list_p);
#if JERRY_ESNEXT
if (has_block_context)
{
parser_emit_cbc_ext (context_p, CBC_EXT_CLONE_FULL_CONTEXT);
}
#endif /* JERRY_ESNEXT */
if (context_p->token.type != LEXER_RIGHT_PAREN)
{
@@ -1729,13 +1622,11 @@ parser_parse_for_statement_end (parser_context_t *context_p) /**< context */
parser_emit_cbc_backward_branch (context_p, (uint16_t) opcode, for_statement.start_offset);
parser_set_breaks_to_current_position (context_p, loop.branch_list_p);
#if JERRY_ESNEXT
if (context_p->stack_top_uint8 == PARSER_STATEMENT_PRIVATE_SCOPE
|| context_p->stack_top_uint8 == PARSER_STATEMENT_PRIVATE_CONTEXT)
{
parser_pop_block_context (context_p);
}
#endif /* JERRY_ESNEXT */
/* Calling scanner_seek is unnecessary because all
* info blocks inside the for statement should be processed. */
@@ -1766,12 +1657,10 @@ parser_parse_switch_statement_start (parser_context_t *context_p) /**< context *
parser_raise_error (context_p, PARSER_ERR_LEFT_BRACE_EXPECTED);
}
#if JERRY_ESNEXT
if (context_p->next_scanner_info_p->source_p == context_p->source_p - 1)
{
parser_push_block_context (context_p, true);
}
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (context_p->next_scanner_info_p->source_p == context_p->source_p
&& context_p->next_scanner_info_p->type == SCANNER_TYPE_SWITCH);
@@ -1925,10 +1814,8 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
parser_stack_iterator_skip (&iterator, 1);
parser_stack_iterator_read (&iterator, &try_statement, sizeof (parser_try_statement_t));
#if JERRY_ESNEXT
context_p->scope_stack_top = try_statement.scope_stack_top;
context_p->scope_stack_reg_top = try_statement.scope_stack_reg_top;
#endif /* JERRY_ESNEXT */
lexer_next_token (context_p);
@@ -1949,11 +1836,6 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
if (try_statement.type == parser_catch_block)
{
#if !JERRY_ESNEXT
context_p->scope_stack_top = try_statement.scope_stack_top;
context_p->scope_stack_reg_top = try_statement.scope_stack_reg_top;
#endif /* !JERRY_ESNEXT */
if (context_p->token.type != LEXER_KEYW_FINALLY)
{
parser_flush_cbc (context_p);
@@ -2017,7 +1899,6 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
if (context_p->token.type == LEXER_LEFT_PAREN)
{
#if JERRY_ESNEXT
if (lexer_check_next_characters (context_p, LIT_CHAR_LEFT_SQUARE, LIT_CHAR_LEFT_BRACE))
{
parser_pattern_flags_t flags = (PARSER_PATTERN_BINDING | PARSER_PATTERN_TARGET_ON_STACK | PARSER_PATTERN_LET);
@@ -2026,28 +1907,21 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
}
else
{
#endif /* JERRY_ESNEXT */
lexer_expect_identifier (context_p, LEXER_IDENT_LITERAL);
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
#if JERRY_ESNEXT
uint16_t literal_index = context_p->lit_object.index;
parser_emit_cbc_literal (context_p,
(literal_index >= PARSER_REGISTER_START) ? CBC_ASSIGN_SET_IDENT : CBC_ASSIGN_LET_CONST,
literal_index);
#else /* !JERRY_ESNEXT */
parser_emit_cbc_literal (context_p, CBC_ASSIGN_SET_IDENT, context_p->lit_object.index);
#endif /* JERRY_ESNEXT */
lexer_next_token (context_p);
#ifndef JERRY_NDEBUG
JERRY_ASSERT (block_found);
#endif /* !JERRY_NDEBUG */
#if JERRY_ESNEXT
}
#endif /* JERRY_ESNEXT */
if (context_p->token.type != LEXER_RIGHT_PAREN)
{
@@ -2061,12 +1935,10 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
parser_raise_error (context_p, PARSER_ERR_LEFT_BRACE_EXPECTED);
}
}
#if JERRY_ESNEXT
else if (context_p->token.type == LEXER_LEFT_BRACE)
{
parser_emit_cbc (context_p, CBC_POP);
}
#endif /* JERRY_ESNEXT */
else
{
parser_raise_error (context_p, PARSER_ERR_LEFT_PAREN_EXPECTED);
@@ -2092,7 +1964,6 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
try_statement.type = parser_finally_block;
parser_emit_cbc_ext_forward_branch (context_p, CBC_EXT_FINALLY, &try_statement.branch);
#if JERRY_ESNEXT
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
{
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_BLOCK);
@@ -2104,7 +1975,6 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
}
#endif /* JERRY_ESNEXT */
}
lexer_next_token (context_p);
@@ -2326,12 +2196,8 @@ parser_parse_continue_statement (parser_context_t *context_p) /**< context */
opcode = CBC_JUMP_FORWARD_EXIT_CONTEXT;
}
#if JERRY_ESNEXT
const bool is_private_scope =
(type == PARSER_STATEMENT_PRIVATE_SCOPE || type == PARSER_STATEMENT_PRIVATE_CONTEXT);
#else /* !JERRY_ESNEXT */
const bool is_private_scope = false;
#endif /* !JERRY_ESNEXT */
if (parser_statement_flags[type] & PARSER_STATM_CONTINUE_TARGET)
{
@@ -2812,12 +2678,10 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
}
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
#if JERRY_ESNEXT
if (strict_mode != PARSER_USE_STRICT_NOT_FOUND && (context_p->status_flags & PARSER_FUNCTION_HAS_COMPLEX_ARGUMENT))
{
parser_raise_error (context_p, PARSER_ERR_USE_STRICT_NOT_ALLOWED);
}
#endif /* JERRY_ESNEXT */
if (context_p->token.type == LEXER_SEMICOLON)
{
@@ -2847,10 +2711,8 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
JERRY_ASSERT (context_p->stack_depth == context_p->context_stack_depth);
#endif /* !JERRY_NDEBUG */
#if JERRY_ESNEXT
JERRY_ASSERT (context_p->stack_top_uint8 != PARSER_STATEMENT_PRIVATE_SCOPE
&& context_p->stack_top_uint8 != PARSER_STATEMENT_PRIVATE_CONTEXT);
#endif /* JERRY_ESNEXT */
#if JERRY_DEBUGGER
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
@@ -2898,7 +2760,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
case LEXER_LEFT_BRACE:
{
#if JERRY_ESNEXT
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
{
parser_push_block_context (context_p, false);
@@ -2907,9 +2768,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
{
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_BLOCK);
}
#else /* !JERRY_ESNEXT */
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_BLOCK);
#endif /* JERRY_ESNEXT */
parser_stack_iterator_init (context_p, &context_p->last_statement);
lexer_next_token (context_p);
@@ -2917,24 +2775,18 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
}
case LEXER_KEYW_VAR:
#if JERRY_ESNEXT
case LEXER_KEYW_LET:
case LEXER_KEYW_CONST:
#endif /* JERRY_ESNEXT */
{
parser_parse_var_statement (context_p);
break;
}
#if JERRY_ESNEXT
case LEXER_KEYW_CLASS:
{
parser_validate_lexical_context (context_p);
parser_parse_class (context_p, true);
goto consume_last_statement;
}
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
case LEXER_KEYW_IMPORT:
{
@@ -3024,7 +2876,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
try_statement.type = parser_try_block;
parser_emit_cbc_ext_forward_branch (context_p, CBC_EXT_TRY_CREATE_CONTEXT, &try_statement.branch);
#if JERRY_ESNEXT
try_statement.scope_stack_top = context_p->scope_stack_top;
try_statement.scope_stack_reg_top = context_p->scope_stack_reg_top;
@@ -3039,7 +2890,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
}
#endif /* JERRY_ESNEXT */
parser_stack_push (context_p, &try_statement, sizeof (parser_try_statement_t));
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_TRY);
@@ -3090,25 +2940,21 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
{
parser_raise_error (context_p, PARSER_ERR_INVALID_RETURN);
}
#if JERRY_ESNEXT
if (context_p->status_flags & PARSER_IS_CLASS_STATIC_BLOCK)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_RETURN);
}
#endif /* JERRY_ESNEXT */
lexer_next_token (context_p);
if ((context_p->token.flags & LEXER_WAS_NEWLINE) || context_p->token.type == LEXER_SEMICOLON
|| context_p->token.type == LEXER_EOS || context_p->token.type == LEXER_RIGHT_BRACE)
{
#if JERRY_ESNEXT
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
{
parser_emit_cbc_ext (context_p, CBC_EXT_RETURN_UNDEFINED);
break;
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc (context_p, CBC_RETURN_FUNCTION_END);
break;
@@ -3151,7 +2997,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
lexer_next_token (context_p);
continue;
}
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (lexer_token_is_let (context_p)))
{
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
@@ -3209,7 +3055,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
continue;
}
}
#endif /* JERRY_ESNEXT */
}
/* FALLTHRU */
}
@@ -3248,14 +3093,12 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
parser_stack_iterator_init (context_p, &context_p->last_statement);
lexer_next_token (context_p);
}
#if JERRY_ESNEXT
else if (context_p->stack_top_uint8 == PARSER_STATEMENT_BLOCK_SCOPE
|| context_p->stack_top_uint8 == PARSER_STATEMENT_BLOCK_CONTEXT)
{
parser_pop_block_context (context_p);
lexer_next_token (context_p);
}
#endif /* JERRY_ESNEXT */
else if (context_p->stack_top_uint8 == PARSER_STATEMENT_SWITCH
|| context_p->stack_top_uint8 == PARSER_STATEMENT_SWITCH_NO_DEFAULT)
{
@@ -3278,13 +3121,11 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
parser_set_breaks_to_current_position (context_p, loop.branch_list_p);
lexer_next_token (context_p);
#if JERRY_ESNEXT
if (context_p->stack_top_uint8 == PARSER_STATEMENT_PRIVATE_SCOPE
|| context_p->stack_top_uint8 == PARSER_STATEMENT_PRIVATE_CONTEXT)
{
parser_pop_block_context (context_p);
}
#endif /* JERRY_ESNEXT */
}
else if (context_p->stack_top_uint8 == PARSER_STATEMENT_TRY)
{
@@ -3384,17 +3225,13 @@ consume_last_statement:
}
case PARSER_STATEMENT_FOR_IN:
#if JERRY_ESNEXT
case PARSER_STATEMENT_FOR_OF:
case PARSER_STATEMENT_FOR_AWAIT_OF:
#endif /* JERRY_ESNEXT */
{
parser_for_in_of_statement_t for_in_of_statement;
parser_loop_statement_t loop;
#if JERRY_ESNEXT
uint8_t for_type = context_p->stack_top_uint8;
#endif /* JERRY_ESNEXT */
parser_stack_pop_uint8 (context_p);
parser_stack_pop (context_p, &loop, sizeof (parser_loop_statement_t));
@@ -3406,13 +3243,11 @@ consume_last_statement:
parser_flush_cbc (context_p);
uint16_t stack_allocation = PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION;
#if JERRY_ESNEXT
if (for_type != PARSER_STATEMENT_FOR_IN)
{
stack_allocation = (for_type == PARSER_STATEMENT_FOR_OF ? PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION
: PARSER_FOR_AWAIT_OF_CONTEXT_STACK_ALLOCATION);
}
#endif /* JERRY_ESNEXT */
PARSER_MINUS_EQUAL_U16 (context_p->stack_depth, stack_allocation);
#ifndef JERRY_NDEBUG
@@ -3421,26 +3256,23 @@ consume_last_statement:
cbc_ext_opcode_t opcode = CBC_EXT_BRANCH_IF_FOR_IN_HAS_NEXT;
#if JERRY_ESNEXT
if (for_type != PARSER_STATEMENT_FOR_IN)
{
opcode = (for_type == PARSER_STATEMENT_FOR_OF ? CBC_EXT_BRANCH_IF_FOR_OF_HAS_NEXT
: CBC_EXT_BRANCH_IF_FOR_AWAIT_OF_HAS_NEXT);
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc_ext_backward_branch (context_p, opcode, for_in_of_statement.start_offset);
parser_set_breaks_to_current_position (context_p, loop.branch_list_p);
parser_set_branch_to_current_position (context_p, &for_in_of_statement.branch);
#if JERRY_ESNEXT
if (context_p->stack_top_uint8 == PARSER_STATEMENT_PRIVATE_SCOPE
|| context_p->stack_top_uint8 == PARSER_STATEMENT_PRIVATE_CONTEXT)
{
parser_pop_block_context (context_p);
}
#endif /* JERRY_ESNEXT */
continue;
}
@@ -3531,9 +3363,7 @@ parser_free_jumps (parser_stack_iterator_t iterator) /**< iterator position */
case PARSER_STATEMENT_WHILE:
case PARSER_STATEMENT_FOR:
case PARSER_STATEMENT_FOR_IN:
#if JERRY_ESNEXT
case PARSER_STATEMENT_FOR_OF:
#endif /* JERRY_ESNEXT */
{
parser_loop_statement_t loop;
@@ -33,7 +33,6 @@
* @{
*/
#if JERRY_ESNEXT
/**
* Append the cooked and raw string to the corresponding array
*/
@@ -154,7 +153,6 @@ parser_tagged_template_literal_finalize (ecma_object_t *template_obj_p, /**< tem
parser_tagged_template_literal_freeze_array (template_obj_p);
parser_tagged_template_literal_freeze_array (raw_strings_p);
} /* parser_tagged_template_literal_finalize */
#endif /* JERRY_ESNEXT */
/**
* @}
@@ -31,7 +31,6 @@
#include "common.h"
#include "js-parser-internal.h"
#if JERRY_ESNEXT
ecma_object_t *parser_new_tagged_template_literal (ecma_object_t **raw_strings_p);
void parser_tagged_template_literal_append_strings (parser_context_t *context_p,
@@ -40,7 +39,6 @@ void parser_tagged_template_literal_append_strings (parser_context_t *context_p,
uint32_t prop_index);
void parser_tagged_template_literal_finalize (ecma_object_t *template_obj_p, ecma_object_t *raw_strings_p);
#endif /* JERRY_ESNEXT */
#endif /* ECMA_TAGGED_TEMPLATE_LITERAL_H */
-4
View File
@@ -752,8 +752,6 @@ parser_set_continues_to_current_position (parser_context_t *context_p, /**< cont
}
} /* parser_set_continues_to_current_position */
#if JERRY_ESNEXT
/**
* Return the size of internal record corresponding to a class field
*
@@ -867,8 +865,6 @@ parser_reverse_class_fields (parser_context_t *context_p, /**< context */
parser_free (data_p, fields_size);
} /* parser_reverse_class_fields */
#endif /* JERRY_ESNEXT */
/**
* @}
* @}
+2 -97
View File
@@ -29,14 +29,12 @@
JERRY_STATIC_ASSERT ((int) ECMA_PARSE_STRICT_MODE == (int) PARSER_IS_STRICT,
ecma_parse_strict_mode_must_be_equal_to_parser_is_strict);
#if JERRY_ESNEXT
JERRY_STATIC_ASSERT (PARSER_SAVE_STATUS_FLAGS (PARSER_ALLOW_SUPER) == 0x1, incorrect_saving_of_ecma_parse_allow_super);
JERRY_STATIC_ASSERT (PARSER_RESTORE_STATUS_FLAGS (ECMA_PARSE_ALLOW_SUPER) == PARSER_ALLOW_SUPER,
incorrect_restoring_of_ecma_parse_allow_super);
JERRY_STATIC_ASSERT (PARSER_RESTORE_STATUS_FLAGS (ECMA_PARSE_FUNCTION_CONTEXT) == 0,
ecma_parse_function_context_must_not_be_transformed);
#endif /* JERRY_ESNEXT */
/** \addtogroup parser Parser
* @{
@@ -590,7 +588,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
ecma_value_t *literal_pool_p;
uint8_t *dst_p;
#if JERRY_ESNEXT
if ((context_p->status_flags & (PARSER_IS_FUNCTION | PARSER_LEXICAL_BLOCK_NEEDED))
== (PARSER_IS_FUNCTION | PARSER_LEXICAL_BLOCK_NEEDED))
{
@@ -629,7 +626,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
JERRY_ASSERT (!(context_p->status_flags & PARSER_NO_END_LABEL));
}
#endif /* JERRY_ESNEXT */
#if JERRY_LINE_INFO
JERRY_ASSERT (context_p->line_info_p != NULL);
@@ -867,12 +863,10 @@ parser_post_processing (parser_context_t *context_p) /**< context */
{
context_p->status_flags &= (uint32_t) ~PARSER_NO_END_LABEL;
#if JERRY_ESNEXT
if (PARSER_IS_NORMAL_ASYNC_FUNCTION (context_p->status_flags))
{
length++;
}
#endif /* JERRY_ESNEXT */
length++;
}
@@ -896,7 +890,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
total_size += context_p->argument_count * sizeof (ecma_value_t);
}
#if JERRY_ESNEXT
/* function.name */
if (!(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR))
{
@@ -907,24 +900,17 @@ parser_post_processing (parser_context_t *context_p) /**< context */
{
total_size += sizeof (ecma_value_t);
}
#endif /* JERRY_ESNEXT */
#if JERRY_LINE_INFO
total_size += sizeof (ecma_value_t);
#endif /* JERRY_LINE_INFO */
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
uint8_t extended_info = 0;
#endif /* JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING */
#if JERRY_ESNEXT
if (context_p->argument_length != UINT16_MAX)
{
extended_info |= CBC_EXTENDED_CODE_FLAGS_HAS_ARGUMENT_LENGTH;
total_size += ecma_extended_info_get_encoded_length (context_p->argument_length);
}
#endif /* JERRY_ESNEXT */
#if JERRY_FUNCTION_TO_STRING
if (context_p->last_context_p != NULL)
{
@@ -946,16 +932,12 @@ parser_post_processing (parser_context_t *context_p) /**< context */
total_size += ecma_extended_info_get_encoded_length ((uint32_t) (context_p->function_end_p - function_start_p));
}
#endif /* JERRY_FUNCTION_TO_STRING */
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
if (extended_info != 0)
{
total_size += sizeof (uint8_t);
}
#endif /* JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING */
total_size = JERRY_ALIGNUP (total_size, JMEM_ALIGNMENT);
compiled_code_p = (ecma_compiled_code_t *) parser_malloc (context_p, total_size);
#if JERRY_SNAPSHOT_SAVE || JERRY_PARSER_DUMP_BYTE_CODE
@@ -972,13 +954,11 @@ parser_post_processing (parser_context_t *context_p) /**< context */
compiled_code_p->refs = 1;
compiled_code_p->status_flags = 0;
#if JERRY_ESNEXT
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
JERRY_ASSERT (context_p->argument_count > 0);
context_p->argument_count--;
}
#endif /* JERRY_ESNEXT */
if (needs_uint16_arguments)
{
@@ -1050,7 +1030,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
{
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_SCRIPT);
}
#if JERRY_ESNEXT
else if (context_p->status_flags & PARSER_IS_ARROW_FUNCTION)
{
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
@@ -1091,7 +1070,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
JERRY_ASSERT (!(context_p->status_flags & PARSER_IS_FUNCTION));
compiled_code_p->status_flags |= CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED;
}
#endif /* JERRY_ESNEXT */
compiled_code_p->status_flags |= function_type;
@@ -1266,14 +1244,12 @@ parser_post_processing (parser_context_t *context_p) /**< context */
{
*dst_p++ = CBC_RETURN_FUNCTION_END;
#if JERRY_ESNEXT
if (PARSER_IS_NORMAL_ASYNC_FUNCTION (context_p->status_flags))
{
dst_p[-1] = CBC_EXT_OPCODE;
dst_p[0] = CBC_EXT_ASYNC_EXIT;
dst_p++;
}
#endif /* JERRY_ESNEXT */
}
JERRY_ASSERT (dst_p == byte_code_p + length);
@@ -1345,7 +1321,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
}
}
#if JERRY_ESNEXT
if (!(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR))
{
*(--base_p) = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
@@ -1356,13 +1331,11 @@ parser_post_processing (parser_context_t *context_p) /**< context */
compiled_code_p->status_flags |= CBC_CODE_FLAGS_HAS_TAGGED_LITERALS;
*(--base_p) = (ecma_value_t) context_p->tagged_template_literal_cp;
}
#endif /* JERRY_ESNEXT */
#if JERRY_LINE_INFO
ECMA_SET_INTERNAL_VALUE_POINTER (base_p[-1], line_info_p);
#endif /* JERRY_LINE_INFO */
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
if (extended_info != 0)
{
#if JERRY_LINE_INFO
@@ -1374,12 +1347,10 @@ parser_post_processing (parser_context_t *context_p) /**< context */
compiled_code_p->status_flags |= CBC_CODE_FLAGS_HAS_EXTENDED_INFO;
*extended_info_p = extended_info;
#if JERRY_ESNEXT
if (context_p->argument_length != UINT16_MAX)
{
ecma_extended_info_encode_vlq (&extended_info_p, context_p->argument_length);
}
#endif /* JERRY_ESNEXT */
#if JERRY_FUNCTION_TO_STRING
if (context_p->last_context_p != NULL)
@@ -1398,7 +1369,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
}
#endif /* JERRY_FUNCTION_TO_STRING */
}
#endif /* JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING */
#if JERRY_PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes)
@@ -1422,7 +1392,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
#undef PARSER_NEXT_BYTE
#undef PARSER_NEXT_BYTE_UPDATE
#if JERRY_ESNEXT
/**
* Resolve private identifier in direct eval context
*/
@@ -1589,7 +1558,6 @@ parser_restore_private_context (parser_context_t *context_p, /**< context */
scanner_release_private_fields (context_p->private_context_p->members_p);
context_p->private_context_p = private_ctx_p->prev_p;
} /* parser_restore_private_context */
#endif /* JERRY_ESNEXT */
/**
* Free identifiers and literals.
@@ -1618,7 +1586,6 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
{
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
#if JERRY_ESNEXT
JERRY_ASSERT (context_p->status_flags & PARSER_IS_FUNCTION);
JERRY_ASSERT (!(context_p->status_flags & PARSER_LEXICAL_BLOCK_NEEDED));
@@ -1634,11 +1601,9 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
context_p->context_stack_depth = PARSER_TRY_CONTEXT_STACK_ALLOCATION;
#endif /* !JERRY_NDEBUG */
}
#endif /* JERRY_ESNEXT */
if (context_p->token.type == end_type)
{
#if JERRY_ESNEXT
context_p->status_flags &= (uint32_t) ~PARSER_DISALLOW_AWAIT_YIELD;
if (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION)
@@ -1649,26 +1614,21 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_BODY);
return;
}
#endif /* JERRY_ESNEXT */
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
return;
}
#if JERRY_ESNEXT
bool has_complex_argument = (context_p->next_scanner_info_p->u8_arg & SCANNER_FUNCTION_HAS_COMPLEX_ARGUMENT) != 0;
#endif /* JERRY_ESNEXT */
bool is_strict = (context_p->next_scanner_info_p->u8_arg & SCANNER_FUNCTION_IS_STRICT) != 0;
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_ARGS);
scanner_set_active (context_p);
#if JERRY_ESNEXT
context_p->status_flags |= PARSER_FUNCTION_IS_PARSING_ARGS;
#endif /* JERRY_ESNEXT */
while (true)
{
#if JERRY_ESNEXT
if (context_p->token.type == LEXER_THREE_DOTS)
{
if (context_p->status_flags & PARSER_IS_PROPERTY_SETTER)
@@ -1771,7 +1731,6 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
}
continue;
}
#endif /* JERRY_ESNEXT */
if (context_p->token.type != LEXER_LITERAL || context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
{
@@ -1787,14 +1746,12 @@ 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 JERRY_ESNEXT
if ((context_p->status_flags & PARSER_FUNCTION_HAS_COMPLEX_ARGUMENT)
|| (context_p->status_flags & PARSER_IS_ARROW_FUNCTION))
{
parser_raise_error (context_p, PARSER_ERR_DUPLICATED_ARGUMENT_NAMES);
}
has_duplicated_arg_names = true;
#endif /* JERRY_ESNEXT */
context_p->status_flags |= PARSER_HAS_NON_STRICT_ARG;
}
@@ -1805,7 +1762,6 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
lexer_next_token (context_p);
#if JERRY_ESNEXT
uint16_t literal_index = context_p->lit_object.index;
if (context_p->token.type == LEXER_ASSIGN)
@@ -1887,7 +1843,6 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
(uint16_t) (PARSER_REGISTER_START + context_p->argument_count),
literal_index);
}
#endif /* JERRY_ESNEXT */
context_p->argument_count++;
if (context_p->argument_count >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
@@ -1907,26 +1862,21 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
break;
}
#if JERRY_ESNEXT
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
parser_raise_error (context_p, PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER);
}
#endif /* JERRY_ESNEXT */
lexer_next_token (context_p);
#if JERRY_ESNEXT
if (context_p->token.type == end_type)
{
break;
}
#endif /* JERRY_ESNEXT */
}
scanner_revert_active (context_p);
#if JERRY_ESNEXT
JERRY_ASSERT (has_complex_argument || !(context_p->status_flags & PARSER_FUNCTION_HAS_COMPLEX_ARGUMENT));
if (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION)
@@ -1957,8 +1907,6 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
}
context_p->status_flags &= (uint32_t) ~(PARSER_DISALLOW_AWAIT_YIELD | PARSER_FUNCTION_IS_PARSING_ARGS);
#endif /* JERRY_ESNEXT */
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_BODY);
if (is_strict)
@@ -2044,10 +1992,8 @@ parser_parse_source (void *source_p, /**< source code */
context.status_flags = parse_opts & PARSER_STRICT_MODE_MASK;
context.global_status_flags = parse_opts;
#if JERRY_ESNEXT
context.status_flags |= PARSER_RESTORE_STATUS_FLAGS (parse_opts);
context.tagged_template_literal_cp = JMEM_CP_NULL;
#endif /* JERRY_ESNEXT */
context.stack_depth = 0;
context.stack_limit = 0;
@@ -2081,7 +2027,7 @@ parser_parse_source (void *source_p, /**< source code */
JERRY_ASSERT (ecma_is_value_string (context.argument_list));
context.status_flags |= PARSER_IS_FUNCTION;
#if JERRY_ESNEXT
if (parse_opts & ECMA_PARSE_GENERATOR_FUNCTION)
{
context.status_flags |= PARSER_IS_GENERATOR_FUNCTION;
@@ -2090,7 +2036,6 @@ parser_parse_source (void *source_p, /**< source code */
{
context.status_flags |= PARSER_IS_ASYNC_FUNCTION;
}
#endif /* JERRY_ESNEXT */
ecma_string_t *string_p = ecma_get_string_from_value (context.argument_list);
uint8_t flags = ECMA_STRING_FLAG_EMPTY;
@@ -2179,9 +2124,7 @@ parser_parse_source (void *source_p, /**< source code */
context.last_cbc_opcode = PARSER_CBC_UNAVAILABLE;
context.argument_count = 0;
#if JERRY_ESNEXT
context.argument_length = UINT16_MAX;
#endif /* JERRY_ESNEXT */
context.register_count = 0;
context.literal_count = 0;
@@ -2194,11 +2137,9 @@ parser_parse_source (void *source_p, /**< source code */
context.scope_stack_size = 0;
context.scope_stack_top = 0;
context.scope_stack_reg_top = 0;
#if JERRY_ESNEXT
context.scope_stack_global_end = 0;
context.tagged_template_literal_cp = JMEM_CP_NULL;
context.private_context_p = NULL;
#endif /* JERRY_ESNEXT */
#ifndef JERRY_NDEBUG
context.context_stack_depth = 0;
@@ -2323,7 +2264,6 @@ parser_parse_source (void *source_p, /**< source code */
JERRY_ASSERT (context.next_scanner_info_p->source_p == context.source_start_p
&& context.next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
#if JERRY_ESNEXT
if (scanner_is_context_needed (&context, PARSER_CHECK_GLOBAL_CONTEXT))
{
context.status_flags |= PARSER_LEXICAL_BLOCK_NEEDED;
@@ -2333,7 +2273,6 @@ parser_parse_source (void *source_p, /**< source code */
{
scanner_check_variables (&context);
}
#endif /* JERRY_ESNEXT */
scanner_create_variables (&context, SCANNER_CREATE_VARS_IS_SCRIPT);
}
@@ -2578,12 +2517,10 @@ parser_save_context (parser_context_t *context_p, /**< context */
}
#endif /* JERRY_DEBUGGER */
#if JERRY_ESNEXT
if (context_p->status_flags & PARSER_FUNCTION_IS_PARSING_ARGS)
{
context_p->status_flags |= PARSER_LEXICAL_BLOCK_NEEDED;
}
#endif /* JERRY_ESNEXT */
/* Save private part of the context. */
@@ -2594,9 +2531,7 @@ parser_save_context (parser_context_t *context_p, /**< context */
saved_context_p->last_statement = context_p->last_statement;
saved_context_p->argument_count = context_p->argument_count;
#if JERRY_ESNEXT
saved_context_p->argument_length = context_p->argument_length;
#endif /* JERRY_ESNEXT */
saved_context_p->register_count = context_p->register_count;
saved_context_p->literal_count = context_p->literal_count;
@@ -2607,10 +2542,8 @@ parser_save_context (parser_context_t *context_p, /**< context */
saved_context_p->scope_stack_size = context_p->scope_stack_size;
saved_context_p->scope_stack_top = context_p->scope_stack_top;
saved_context_p->scope_stack_reg_top = context_p->scope_stack_reg_top;
#if JERRY_ESNEXT
saved_context_p->scope_stack_global_end = context_p->scope_stack_global_end;
saved_context_p->tagged_template_literal_cp = context_p->tagged_template_literal_cp;
#endif /* JERRY_ESNEXT */
#ifndef JERRY_NDEBUG
saved_context_p->context_stack_depth = context_p->context_stack_depth;
@@ -2633,9 +2566,7 @@ parser_save_context (parser_context_t *context_p, /**< context */
context_p->last_statement.current_p = NULL;
context_p->argument_count = 0;
#if JERRY_ESNEXT
context_p->argument_length = UINT16_MAX;
#endif /* JERRY_ESNEXT */
context_p->register_count = 0;
context_p->literal_count = 0;
@@ -2646,10 +2577,8 @@ parser_save_context (parser_context_t *context_p, /**< context */
context_p->scope_stack_size = 0;
context_p->scope_stack_top = 0;
context_p->scope_stack_reg_top = 0;
#if JERRY_ESNEXT
context_p->scope_stack_global_end = 0;
context_p->tagged_template_literal_cp = JMEM_CP_NULL;
#endif /* JERRY_ESNEXT */
#ifndef JERRY_NDEBUG
context_p->context_stack_depth = 0;
@@ -2689,9 +2618,7 @@ parser_restore_context (parser_context_t *context_p, /**< context */
context_p->last_statement = saved_context_p->last_statement;
context_p->argument_count = saved_context_p->argument_count;
#if JERRY_ESNEXT
context_p->argument_length = saved_context_p->argument_length;
#endif /* JERRY_ESNEXT */
context_p->register_count = saved_context_p->register_count;
context_p->literal_count = saved_context_p->literal_count;
@@ -2702,10 +2629,8 @@ parser_restore_context (parser_context_t *context_p, /**< context */
context_p->scope_stack_size = saved_context_p->scope_stack_size;
context_p->scope_stack_top = saved_context_p->scope_stack_top;
context_p->scope_stack_reg_top = saved_context_p->scope_stack_reg_top;
#if JERRY_ESNEXT
context_p->scope_stack_global_end = saved_context_p->scope_stack_global_end;
context_p->tagged_template_literal_cp = saved_context_p->tagged_template_literal_cp;
#endif /* JERRY_ESNEXT */
#ifndef JERRY_NDEBUG
context_p->context_stack_depth = saved_context_p->context_stack_depth;
@@ -2731,19 +2656,13 @@ parser_parse_function (parser_context_t *context_p, /**< context */
JERRY_ASSERT (status_flags & PARSER_IS_FUNCTION);
parser_save_context (context_p, &saved_context);
context_p->status_flags |= status_flags;
#if JERRY_ESNEXT
context_p->status_flags |= PARSER_ALLOW_NEW_TARGET;
#endif /* JERRY_ESNEXT */
#if JERRY_PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes)
{
#if JERRY_ESNEXT
JERRY_DEBUG_MSG ("\n--- %s parsing start ---\n\n",
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor" : "Function");
#else /* !JERRY_ESNEXT */
JERRY_DEBUG_MSG ("\n--- Function parsing start ---\n\n");
#endif /* JERRY_ESNEXT */
}
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
@@ -2776,13 +2695,11 @@ parser_parse_function (parser_context_t *context_p, /**< context */
parser_raise_error (context_p, PARSER_ERR_ONE_ARGUMENT_EXPECTED);
}
#if JERRY_ESNEXT
if ((context_p->status_flags & (PARSER_CLASS_CONSTRUCTOR | PARSER_ALLOW_SUPER_CALL)) == PARSER_CLASS_CONSTRUCTOR)
{
parser_emit_cbc_ext (context_p, CBC_EXT_RUN_FIELD_INIT);
parser_flush_cbc (context_p);
}
#endif /* JERRY_ESNEXT */
#if JERRY_PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes && (context_p->status_flags & PARSER_HAS_NON_STRICT_ARG))
@@ -2803,12 +2720,8 @@ parser_parse_function (parser_context_t *context_p, /**< context */
#if JERRY_PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes)
{
#if JERRY_ESNEXT
JERRY_DEBUG_MSG ("\n--- %s parsing end ---\n\n",
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor" : "Function");
#else /* !JERRY_ESNEXT */
JERRY_DEBUG_MSG ("\n--- Function parsing end ---\n\n");
#endif /* JERRY_ESNEXT */
}
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
@@ -2817,8 +2730,6 @@ parser_parse_function (parser_context_t *context_p, /**< context */
return compiled_code_p;
} /* parser_parse_function */
#if JERRY_ESNEXT
/**
* Parse static class block code
*
@@ -3330,8 +3241,6 @@ parser_compiled_code_set_function_name (parser_context_t *context_p, /**< contex
}
} /* parser_compiled_code_set_function_name */
#endif /* JERRY_ESNEXT */
/**
* Raise a parse error.
*/
@@ -3367,14 +3276,12 @@ parser_raise_error (parser_context_t *context_p, /**< context */
parser_free_jumps (saved_context_p->last_statement);
}
#if JERRY_ESNEXT
if (saved_context_p->tagged_template_literal_cp != JMEM_CP_NULL)
{
ecma_collection_t *collection =
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, saved_context_p->tagged_template_literal_cp);
ecma_collection_free_template_literal (collection);
}
#endif /* JERRY_ESNEXT */
#if JERRY_LINE_INFO
parser_line_info_free (saved_context_p->line_info_p);
@@ -3383,7 +3290,6 @@ parser_raise_error (parser_context_t *context_p, /**< context */
saved_context_p = saved_context_p->prev_context_p;
}
#if JERRY_ESNEXT
parser_free_private_fields (context_p);
if (context_p->tagged_template_literal_cp != JMEM_CP_NULL)
@@ -3392,7 +3298,6 @@ parser_raise_error (parser_context_t *context_p, /**< context */
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, context_p->tagged_template_literal_cp);
ecma_collection_free_template_literal (collection);
}
#endif /* JERRY_ESNEXT */
context_p->error = error;
PARSER_THROW (context_p->try_buffer);
@@ -41,13 +41,11 @@ typedef enum
SCAN_MODE_VAR_STATEMENT, /**< scanning var statement */
SCAN_MODE_PROPERTY_NAME, /**< scanning property name */
SCAN_MODE_FUNCTION_ARGUMENTS, /**< scanning function arguments */
#if JERRY_ESNEXT
SCAN_MODE_CONTINUE_FUNCTION_ARGUMENTS, /**< continue scanning function arguments */
SCAN_MODE_BINDING, /**< array or object binding */
SCAN_MODE_CLASS_DECLARATION, /**< scanning class declaration */
SCAN_MODE_CLASS_BODY, /**< scanning class body */
SCAN_MODE_CLASS_BODY_NO_SCAN, /**< scanning class body without calling lexer_scan_identifier */
#endif /* JERRY_ESNEXT */
} scan_modes_t;
/**
@@ -61,9 +59,7 @@ typedef enum
SCAN_STACK_FUNCTION_STATEMENT, /**< function statement */
SCAN_STACK_FUNCTION_EXPRESSION, /**< function expression */
SCAN_STACK_FUNCTION_PROPERTY, /**< function expression in an object literal */
#if JERRY_ESNEXT
SCAN_STACK_FUNCTION_ARROW, /**< arrow function expression */
#endif /* JERRY_ESNEXT */
SCAN_STACK_SWITCH_BLOCK, /**< block part of "switch" statement */
SCAN_STACK_IF_STATEMENT, /**< statement part of "if" statements */
SCAN_STACK_WITH_STATEMENT, /**< statement part of "with" statements */
@@ -73,19 +69,15 @@ typedef enum
SCAN_STACK_WHILE_EXPRESSION, /**< expression part of "while" iterator */
SCAN_STACK_PAREN_EXPRESSION, /**< expression in brackets */
SCAN_STACK_STATEMENT_WITH_EXPR, /**< statement which starts with expression enclosed in brackets */
#if JERRY_ESNEXT
SCAN_STACK_BINDING_INIT, /**< post processing after a single initializer */
SCAN_STACK_BINDING_LIST_INIT, /**< post processing after an initializer list */
SCAN_STACK_LET, /**< let statement */
SCAN_STACK_CONST, /**< const statement */
#endif /* JERRY_ESNEXT */
/* The SCANNER_IS_FOR_START macro needs to be updated when the following constants are reordered. */
SCAN_STACK_VAR, /**< var statement */
SCAN_STACK_FOR_VAR_START, /**< start of "for" iterator with var statement */
#if JERRY_ESNEXT
SCAN_STACK_FOR_LET_START, /**< start of "for" iterator with let statement */
SCAN_STACK_FOR_CONST_START, /**< start of "for" iterator with const statement */
#endif /* JERRY_ESNEXT */
SCAN_STACK_FOR_START, /**< start of "for" iterator */
SCAN_STACK_FOR_CONDITION, /**< condition part of "for" iterator */
SCAN_STACK_FOR_EXPRESSION, /**< expression part of "for" iterator */
@@ -97,7 +89,6 @@ typedef enum
SCAN_STACK_ARRAY_LITERAL, /**< array literal or destructuring assignment or binding */
SCAN_STACK_OBJECT_LITERAL, /**< object literal group */
SCAN_STACK_PROPERTY_ACCESSOR, /**< property accessor in square brackets */
#if JERRY_ESNEXT
/* These four must be in this order. */
SCAN_STACK_COMPUTED_PROPERTY, /**< computed property name */
SCAN_STACK_COMPUTED_GENERATOR, /**< computed generator function */
@@ -119,7 +110,6 @@ typedef enum
SCAN_STACK_FOR_START_PATTERN, /**< possible assignment pattern for "for" iterator */
SCAN_STACK_USE_ASYNC, /**< an "async" identifier is used */
SCAN_STACK_CLASS_STATIC_BLOCK, /**< class static block */
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
SCAN_STACK_EXPORT_DEFAULT, /**< scan primary expression after export default */
#endif /* JERRY_MODULE_SYSTEM */
@@ -131,9 +121,7 @@ typedef enum
typedef enum
{
SCANNER_CONTEXT_NO_FLAGS = 0, /**< no flags are set */
#if JERRY_ESNEXT
SCANNER_CONTEXT_THROW_ERR_ASYNC_FUNCTION = (1 << 0), /**< throw async function error */
#endif /* JERRY_ESNEXT */
#if JERRY_DEBUGGER
SCANNER_CONTEXT_DEBUGGER_ENABLED = (1 << 1), /**< debugger is enabled */
#endif /* JERRY_DEBUGGER */
@@ -167,24 +155,18 @@ typedef enum
{
SCANNER_LITERAL_IS_ARG = (1 << 0), /**< literal is argument */
SCANNER_LITERAL_IS_VAR = (1 << 1), /**< literal is var */
#if JERRY_ESNEXT
/** literal is a destructured argument binding of a possible arrow function */
SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG = SCANNER_LITERAL_IS_VAR,
#endif /* JERRY_ESNEXT */
SCANNER_LITERAL_IS_FUNC = (1 << 2), /**< literal is function */
SCANNER_LITERAL_NO_REG = (1 << 3), /**< literal cannot be stored in a register */
SCANNER_LITERAL_IS_LET = (1 << 4), /**< literal is let */
#if JERRY_ESNEXT
/** literal is a function declared in this block (prevents declaring let/const with the same name) */
SCANNER_LITERAL_IS_FUNC_DECLARATION = SCANNER_LITERAL_IS_LET,
#endif /* JERRY_ESNEXT */
SCANNER_LITERAL_IS_CONST = (1 << 5), /**< literal is const */
#if JERRY_ESNEXT
/** literal is a destructured argument binding */
SCANNER_LITERAL_IS_DESTRUCTURED_ARG = SCANNER_LITERAL_IS_CONST,
SCANNER_LITERAL_IS_USED = (1 << 6), /**< literal is used */
SCANNER_LITERAL_EARLY_CREATE = (1 << 7), /**< binding should be created early with ECMA_VALUE_UNINITIALIZED */
#endif /* JERRY_ESNEXT */
} scanner_literal_type_flags_t;
/*
@@ -233,8 +215,6 @@ typedef struct
scanner_case_info_t **last_case_p; /**< last case info */
} scanner_switch_statement_t;
#if JERRY_ESNEXT
/**
* Types of scanner destructuring bindings.
*/
@@ -274,35 +254,27 @@ typedef struct scanner_binding_list_t
bool is_nested; /**< is nested binding declaration */
} scanner_binding_list_t;
#endif /* JERRY_ESNEXT */
/**
* Flags for scanner_literal_pool_t structure.
*/
typedef enum
{
SCANNER_LITERAL_POOL_FUNCTION = (1 << 0), /**< literal pool represents a function */
#if JERRY_ESNEXT
SCANNER_LITERAL_POOL_CLASS_NAME = (1 << 1), /**< literal pool which contains a class name */
SCANNER_LITERAL_POOL_CLASS_FIELD = (1 << 2), /**< literal pool is created for a class field initializer */
#endif /* JERRY_ESNEXT */
SCANNER_LITERAL_POOL_IS_STRICT = (1 << 3), /**< literal pool represents a strict mode code block */
SCANNER_LITERAL_POOL_CAN_EVAL = (1 << 4), /**< prepare for executing eval in this block */
SCANNER_LITERAL_POOL_NO_ARGUMENTS = (1 << 5), /**< arguments object must not be constructed,
* or arguments cannot be stored in registers if
* SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS is set */
#if JERRY_ESNEXT
SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS = (1 << 6), /**< arguments is referenced in function args */
SCANNER_LITERAL_POOL_HAS_COMPLEX_ARGUMENT = (1 << 7), /**< function has complex (ES2015+) argument definition */
#endif /* JERRY_ESNEXT */
SCANNER_LITERAL_POOL_IN_WITH = (1 << 8), /**< literal pool is in a with statement */
#if JERRY_ESNEXT
SCANNER_LITERAL_POOL_ARROW = (1 << 9), /**< arrow function */
SCANNER_LITERAL_POOL_GENERATOR = (1 << 10), /**< generator function */
SCANNER_LITERAL_POOL_ASYNC = (1 << 11), /**< async function */
SCANNER_LITERAL_POOL_FUNCTION_STATEMENT = (1 << 12), /**< function statement */
SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE = (1 << 13), /**< function body contains super reference */
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
SCANNER_LITERAL_POOL_IN_EXPORT = (1 << 14), /**< the declared variables are exported by the module system */
#endif /* JERRY_MODULE_SYSTEM */
@@ -331,23 +303,12 @@ typedef enum
*/
#define SCANNER_FROM_COMPUTED_TO_LITERAL_POOL(mode) (((mode) -SCAN_STACK_COMPUTED_PROPERTY) << 10)
#if JERRY_ESNEXT
/**
* Literal pool which may contains function argument identifiers
*/
#define SCANNER_LITERAL_POOL_MAY_HAVE_ARGUMENTS(status_flags) \
(!((status_flags) & (SCANNER_LITERAL_POOL_CLASS_NAME | SCANNER_LITERAL_POOL_CLASS_FIELD)))
#else /* !JERRY_ESNEXT */
/**
* Literal pool which may contains function argument identifiers
*/
#define SCANNER_LITERAL_POOL_MAY_HAVE_ARGUMENTS(status_flags) true
#endif /* JERRY_ESNEXT */
/**
* Local literal pool.
*/
@@ -367,27 +328,19 @@ struct scanner_context_t
{
uint32_t context_status_flags; /**< original status flags of the context */
uint8_t mode; /**< scanner mode */
#if JERRY_ESNEXT
uint8_t binding_type; /**< current destructuring binding type */
#endif /* JERRY_ESNEXT */
uint16_t status_flags; /**< scanner status flags */
#if JERRY_ESNEXT
scanner_binding_list_t *active_binding_list_p; /**< currently active binding list */
#endif /* JERRY_ESNEXT */
scanner_literal_pool_t *active_literal_pool_p; /**< currently active literal pool */
scanner_switch_statement_t active_switch_statement; /**< currently active switch statement */
scanner_info_t *end_arguments_p; /**< position of end arguments */
#if JERRY_ESNEXT
const uint8_t *async_source_p; /**< source position for async functions */
#endif /* JERRY_ESNEXT */
};
/* Scanner utils. */
void scanner_raise_error (parser_context_t *context_p);
#if JERRY_ESNEXT
void scanner_raise_redeclaration_error (parser_context_t *context_p);
#endif /* JERRY_ESNEXT */
void *scanner_malloc (parser_context_t *context_p, size_t size);
void scanner_free (void *ptr, size_t size);
@@ -401,10 +354,8 @@ scanner_info_t *scanner_insert_info_before (parser_context_t *context_p,
scanner_literal_pool_t *
scanner_push_literal_pool (parser_context_t *context_p, scanner_context_t *scanner_context_p, uint16_t status_flags);
void scanner_pop_literal_pool (parser_context_t *context_p, scanner_context_t *scanner_context_p);
#if JERRY_ESNEXT
void scanner_filter_arguments (parser_context_t *context_p, scanner_context_t *scanner_context_p);
void scanner_construct_global_block (parser_context_t *context_p, scanner_context_t *scanner_context_p);
#endif /* JERRY_ESNEXT */
lexer_lit_location_t *scanner_add_custom_literal (parser_context_t *context_p,
scanner_literal_pool_t *literal_pool_p,
const lexer_lit_location_t *literal_location_p);
@@ -412,15 +363,12 @@ lexer_lit_location_t *scanner_add_literal (parser_context_t *context_p, scanner_
void scanner_add_reference (parser_context_t *context_p, scanner_context_t *scanner_context_p);
lexer_lit_location_t *scanner_append_argument (parser_context_t *context_p, scanner_context_t *scanner_context_p);
void scanner_add_private_identifier (parser_context_t *context_p, scanner_private_field_flags_t opts);
#if JERRY_ESNEXT
void scanner_detect_invalid_var (parser_context_t *context_p,
scanner_context_t *scanner_context_p,
lexer_lit_location_t *var_literal_p);
void scanner_detect_invalid_let (parser_context_t *context_p, lexer_lit_location_t *let_literal_p);
#endif /* JERRY_ESNEXT */
void scanner_detect_eval_call (parser_context_t *context_p, scanner_context_t *scanner_context_p);
#if JERRY_ESNEXT
lexer_lit_location_t *
scanner_push_class_declaration (parser_context_t *context_p, scanner_context_t *scanner_context_p, uint8_t stack_mode);
void scanner_push_class_field_initializer (parser_context_t *context_p, scanner_context_t *scanner_context_p);
@@ -430,11 +378,9 @@ void scanner_push_destructuring_pattern (parser_context_t *context_p,
bool is_nested);
void scanner_pop_binding_list (scanner_context_t *scanner_context_p);
void scanner_append_hole (parser_context_t *context_p, scanner_context_t *scanner_context_p);
#endif /* JERRY_ESNEXT */
/* Scanner operations. */
#if JERRY_ESNEXT
void scanner_add_async_literal (parser_context_t *context_p, scanner_context_t *scanner_context_p);
void scanner_check_arrow (parser_context_t *context_p, scanner_context_t *scanner_context_p);
void
@@ -442,7 +388,6 @@ scanner_scan_simple_arrow (parser_context_t *context_p, scanner_context_t *scann
void scanner_check_arrow_arg (parser_context_t *context_p, scanner_context_t *scanner_context_p);
bool scanner_check_async_function (parser_context_t *context_p, scanner_context_t *scanner_context_p);
void scanner_check_function_after_if (parser_context_t *context_p, scanner_context_t *scanner_context_p);
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
void scanner_check_import_meta (parser_context_t *context_p);
#endif /* JERRY_MODULE_SYSTEM */
-32
View File
@@ -29,8 +29,6 @@
* @{
*/
#if JERRY_ESNEXT
/**
* Add the "async" literal to the literal pool.
*/
@@ -242,9 +240,7 @@ scanner_check_arrow_arg (parser_context_t *context_p, /**< context */
if (context_p->token.type == LEXER_LEFT_BRACE)
{
#if JERRY_ESNEXT
parser_stack_push_uint8 (context_p, 0);
#endif /* JERRY_ESNEXT */
parser_stack_push_uint8 (context_p, SCAN_STACK_OBJECT_LITERAL);
scanner_context_p->mode = SCAN_MODE_PROPERTY_NAME;
return;
@@ -352,8 +348,6 @@ scanner_check_function_after_if (parser_context_t *context_p, /**< context */
}
} /* scanner_check_function_after_if */
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
/**
@@ -378,8 +372,6 @@ scanner_check_import_meta (parser_context_t *context_p) /**< context */
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_ESNEXT
/**
* Arrow types for scanner_scan_bracket() function.
*/
@@ -390,8 +382,6 @@ typedef enum
SCANNER_SCAN_BRACKET_ARROW_WITH_ONE_ARG, /**< arrow function with one argument */
} scanner_scan_bracket_arrow_type_t;
#endif /* JERRY_ESNEXT */
/**
* Scan bracketed expressions.
*/
@@ -400,19 +390,15 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
scanner_context_t *scanner_context_p) /**< scanner context */
{
size_t depth = 0;
#if JERRY_ESNEXT
const uint8_t *arrow_source_p;
const uint8_t *async_source_p = NULL;
scanner_scan_bracket_arrow_type_t arrow_type = SCANNER_SCAN_BRACKET_NO_ARROW;
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (context_p->token.type == LEXER_LEFT_PAREN);
do
{
#if JERRY_ESNEXT
arrow_source_p = context_p->source_p;
#endif /* JERRY_ESNEXT */
depth++;
lexer_next_token (context_p);
} while (context_p->token.type == LEXER_LEFT_PAREN);
@@ -425,13 +411,10 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
{
if (context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
{
#if JERRY_ESNEXT
arrow_source_p = NULL;
#endif /* JERRY_ESNEXT */
break;
}
#if JERRY_ESNEXT
const uint8_t *source_p = context_p->source_p;
if (lexer_check_arrow (context_p))
@@ -442,7 +425,6 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
}
size_t total_depth = depth;
#endif /* JERRY_ESNEXT */
while (depth > 0 && lexer_check_next_character (context_p, LIT_CHAR_RIGHT_PAREN))
{
@@ -453,19 +435,14 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
if (context_p->token.keyword_type == LEXER_KEYW_EVAL
&& lexer_check_next_character (context_p, LIT_CHAR_LEFT_PAREN))
{
#if JERRY_ESNEXT
/* A function call cannot be an eval function. */
arrow_source_p = NULL;
const uint16_t flags = (uint16_t) (SCANNER_LITERAL_POOL_CAN_EVAL | SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE);
#else /* !JERRY_ESNEXT */
const uint16_t flags = SCANNER_LITERAL_POOL_CAN_EVAL;
#endif /* JERRY_ESNEXT */
scanner_context_p->active_literal_pool_p->status_flags |= flags;
break;
}
#if JERRY_ESNEXT
if (total_depth == depth)
{
if (lexer_check_arrow_param (context_p))
@@ -493,10 +470,8 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
}
arrow_source_p = NULL;
#endif /* JERRY_ESNEXT */
break;
}
#if JERRY_ESNEXT
case LEXER_THREE_DOTS:
case LEXER_LEFT_SQUARE:
case LEXER_LEFT_BRACE:
@@ -506,22 +481,17 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
depth--;
break;
}
#endif /* JERRY_ESNEXT */
default:
{
#if JERRY_ESNEXT
arrow_source_p = NULL;
#endif /* JERRY_ESNEXT */
break;
}
}
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (scanner_context_p->async_source_p != NULL) && (arrow_source_p == NULL || depth > 0))
{
scanner_context_p->async_source_p = NULL;
}
#endif /* JERRY_ESNEXT */
while (depth > 0)
{
@@ -529,7 +499,6 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
depth--;
}
#if JERRY_ESNEXT
if (arrow_source_p != NULL)
{
JERRY_ASSERT (async_source_p == NULL);
@@ -577,7 +546,6 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
scanner_context_p->async_source_p = async_source_p;
scanner_check_async_function (context_p, scanner_context_p);
}
#endif /* JERRY_ESNEXT */
} /* scanner_scan_bracket */
/**
+7 -201
View File
@@ -36,8 +36,6 @@
JERRY_STATIC_ASSERT (PARSER_MAXIMUM_NUMBER_OF_LITERALS + PARSER_MAXIMUM_NUMBER_OF_REGISTERS < PARSER_REGISTER_START,
maximum_number_of_literals_plus_registers_must_be_less_than_register_start);
#if JERRY_ESNEXT
JERRY_STATIC_ASSERT ((SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG & SCANNER_LITERAL_IS_LOCAL) == 0,
is_arrow_arg_binding_flag_must_not_use_local_flags);
@@ -57,8 +55,6 @@ JERRY_STATIC_ASSERT (SCANNER_LITERAL_IS_FUNC_DECLARATION != SCANNER_LITERAL_IS_D
JERRY_STATIC_ASSERT (PARSER_SCOPE_STACK_IS_CONST_REG == PARSER_SCOPE_STACK_IS_LOCAL_CREATED,
scope_stack_is_const_reg_and_scope_stack_is_local_created_must_be_the_same);
#endif /* JERRY_ESNEXT */
/**
* Raise a scanner error.
*/
@@ -70,8 +66,6 @@ scanner_raise_error (parser_context_t *context_p) /**< context */
JERRY_ASSERT (0);
} /* scanner_raise_error */
#if JERRY_ESNEXT
/**
* Raise a variable redeclaration error.
*/
@@ -84,8 +78,6 @@ scanner_raise_redeclaration_error (parser_context_t *context_p) /**< context */
scanner_raise_error (context_p);
} /* scanner_raise_redeclaration_error */
#endif /* JERRY_ESNEXT */
/**
* Allocate memory for scanner.
*
@@ -138,24 +130,18 @@ scanner_get_stream_size (scanner_info_t *info_p, /**< scanner info block */
switch (data_p[0] & SCANNER_STREAM_TYPE_MASK)
{
case SCANNER_STREAM_TYPE_VAR:
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_LET:
case SCANNER_STREAM_TYPE_CONST:
case SCANNER_STREAM_TYPE_LOCAL:
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
case SCANNER_STREAM_TYPE_IMPORT:
#endif /* JERRY_MODULE_SYSTEM */
case SCANNER_STREAM_TYPE_ARG:
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_ARG_VAR:
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG:
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR:
#endif /* JERRY_MODULE_SYSTEM */
case SCANNER_STREAM_TYPE_ARG_FUNC:
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC:
#endif /* JERRY_ESNEXT */
case SCANNER_STREAM_TYPE_FUNC:
{
break;
@@ -409,8 +395,6 @@ scanner_literal_is_arguments (lexer_lit_location_t *literal_p) /**< literal */
return lexer_compare_identifier_to_string (literal_p, (const uint8_t *) "arguments", 9);
} /* scanner_literal_is_arguments */
#if JERRY_ESNEXT
/**
* Find if there is a duplicated argument in the given context
*
@@ -577,8 +561,6 @@ scanner_scope_find_lexical_declaration (parser_context_t *context_p, /**< contex
return false;
} /* scanner_scope_find_lexical_declaration */
#endif /* JERRY_ESNEXT */
/**
* Push a new literal pool.
*
@@ -599,16 +581,11 @@ scanner_push_literal_pool (parser_context_t *context_p, /**< context */
JERRY_ASSERT (prev_literal_pool_p != NULL);
status_flags |= SCANNER_LITERAL_POOL_NO_ARGUMENTS;
#if JERRY_ESNEXT
const uint16_t copied_flags =
(SCANNER_LITERAL_POOL_IN_WITH | SCANNER_LITERAL_POOL_GENERATOR | SCANNER_LITERAL_POOL_ASYNC);
#else /* !JERRY_ESNEXT */
const uint16_t copied_flags = SCANNER_LITERAL_POOL_IN_WITH;
#endif /* JERRY_ESNEXT */
status_flags |= (uint16_t) (prev_literal_pool_p->status_flags & copied_flags);
}
#if JERRY_ESNEXT
else
{
context_p->status_flags &= (uint32_t) ~(PARSER_IS_GENERATOR_FUNCTION | PARSER_IS_ASYNC_FUNCTION);
@@ -623,7 +600,6 @@ scanner_push_literal_pool (parser_context_t *context_p, /**< context */
context_p->status_flags |= PARSER_IS_ASYNC_FUNCTION;
}
}
#endif /* JERRY_ESNEXT */
if (prev_literal_pool_p != NULL)
{
@@ -671,13 +647,11 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
scanner_literal_pool_t *literal_pool_p = scanner_context_p->active_literal_pool_p;
scanner_literal_pool_t *prev_literal_pool_p = literal_pool_p->prev_p;
#if JERRY_ESNEXT
const uint32_t arrow_super_flags = (SCANNER_LITERAL_POOL_ARROW | SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE);
if ((literal_pool_p->status_flags & arrow_super_flags) == arrow_super_flags)
{
prev_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE;
}
#endif /* JERRY_ESNEXT */
if (JERRY_UNLIKELY (literal_pool_p->source_p == NULL))
{
@@ -702,7 +676,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
arguments_type = SCANNER_ARGUMENTS_MAY_PRESENT_IN_EVAL;
}
#if JERRY_ESNEXT
if (status_flags & SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS)
{
arguments_type = SCANNER_ARGUMENTS_PRESENT;
@@ -713,15 +686,13 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
status_flags &= (uint16_t) ~SCANNER_LITERAL_POOL_NO_ARGUMENTS;
}
}
#endif /* JERRY_ESNEXT */
uint8_t can_eval_types = 0;
#if JERRY_ESNEXT
if (prev_literal_pool_p == NULL && !(context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL))
{
can_eval_types |= SCANNER_LITERAL_IS_FUNC;
}
#endif /* JERRY_ESNEXT */
if ((status_flags & SCANNER_LITERAL_POOL_CAN_EVAL) && prev_literal_pool_p != NULL)
{
@@ -759,13 +730,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
if (!(status_flags & SCANNER_LITERAL_POOL_NO_ARGUMENTS) && scanner_literal_is_arguments (literal_p))
{
#if JERRY_ESNEXT
JERRY_ASSERT (arguments_type != SCANNER_ARGUMENTS_NOT_PRESENT);
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT
|| arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT_IN_EVAL);
#endif /* JERRY_ESNEXT */
status_flags |= SCANNER_LITERAL_POOL_NO_ARGUMENTS;
if (type & SCANNER_LITERAL_IS_ARG)
@@ -775,7 +740,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
arguments_type = SCANNER_ARGUMENTS_NOT_PRESENT;
last_argument_p = literal_p;
}
#if JERRY_ESNEXT
else if (type & SCANNER_LITERAL_IS_LOCAL)
{
if (arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT || arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT_IN_EVAL)
@@ -806,15 +770,8 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
}
}
}
#else /* !JERRY_ESNEXT */
else if (type & SCANNER_LITERAL_IS_FUNC)
{
arguments_type = SCANNER_ARGUMENTS_NOT_PRESENT;
}
#endif /* JERRY_ESNEXT */
else
{
#if JERRY_ESNEXT
if ((type & SCANNER_LITERAL_IS_VAR)
&& (arguments_type == SCANNER_ARGUMENTS_PRESENT || arguments_type == SCANNER_ARGUMENTS_PRESENT_NO_REG))
{
@@ -831,7 +788,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
literal_p->type = type;
no_declarations--;
}
#endif /* JERRY_ESNEXT */
if ((type & SCANNER_LITERAL_NO_REG) || arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT_IN_EVAL)
{
@@ -842,17 +798,12 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
arguments_type = SCANNER_ARGUMENTS_PRESENT;
}
#if JERRY_ESNEXT
/* The SCANNER_LITERAL_IS_ARG may be set above. */
if (!(type & SCANNER_LITERAL_IS_ARG))
{
literal_p->type = 0;
continue;
}
#else /* !JERRY_ESNEXT */
literal_p->type = 0;
continue;
#endif /* JERRY_ESNEXT */
}
}
else if (type & SCANNER_LITERAL_IS_ARG)
@@ -860,7 +811,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
last_argument_p = literal_p;
}
#if JERRY_ESNEXT
if ((status_flags & SCANNER_LITERAL_POOL_FUNCTION)
&& (type & SCANNER_LITERAL_IS_LOCAL_FUNC) == SCANNER_LITERAL_IS_FUNC)
{
@@ -878,7 +828,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
type &= (uint8_t) ~SCANNER_LITERAL_IS_FUNC;
literal_p->type = type;
}
#endif /* JERRY_ESNEXT */
if ((type & SCANNER_LITERAL_IS_LOCAL)
|| ((type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_ARG))
@@ -904,7 +853,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
no_declarations++;
#if JERRY_ESNEXT
if ((type & (SCANNER_LITERAL_IS_CONST | SCANNER_LITERAL_IS_ARG)) == SCANNER_LITERAL_IS_CONST)
{
JERRY_ASSERT (type & SCANNER_LITERAL_IS_LET);
@@ -913,14 +861,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
literal_p->type = (uint8_t) (type & ~SCANNER_LITERAL_IS_FUNC);
no_declarations--;
}
#else /* !JERRY_ESNEXT */
if (type & SCANNER_LITERAL_IS_LOCAL)
{
/* Catch parameters cannot be functions. */
literal_p->type = (uint8_t) (type & ~SCANNER_LITERAL_IS_FUNC);
no_declarations--;
}
#endif /* JERRY_ESNEXT */
}
intptr_t diff = (intptr_t) (literal_p->char_p - prev_source_p);
@@ -941,9 +881,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
prev_source_p = literal_p->char_p + literal_p->length;
if ((status_flags & SCANNER_LITERAL_POOL_FUNCTION)
#if JERRY_ESNEXT
|| ((type & SCANNER_LITERAL_IS_FUNC) && (status_flags & SCANNER_LITERAL_POOL_IS_STRICT))
#endif /* JERRY_ESNEXT */
|| !(type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_FUNC)))
{
continue;
@@ -956,18 +894,12 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
lexer_lit_location_t *literal_location_p = scanner_add_custom_literal (context_p, prev_literal_pool_p, literal_p);
uint8_t extended_type = literal_location_p->type;
#if JERRY_ESNEXT
const uint16_t no_reg_flags = (SCANNER_LITERAL_POOL_FUNCTION | SCANNER_LITERAL_POOL_CLASS_FIELD);
#else /* !JERRY_ESNEXT */
const uint16_t no_reg_flags = SCANNER_LITERAL_POOL_FUNCTION;
#endif /* JERRY_ESNEXT */
if ((status_flags & no_reg_flags) || (type & SCANNER_LITERAL_NO_REG))
if ((status_flags & (SCANNER_LITERAL_POOL_FUNCTION | SCANNER_LITERAL_POOL_CLASS_FIELD))
|| (type & SCANNER_LITERAL_NO_REG))
{
extended_type |= SCANNER_LITERAL_NO_REG;
}
#if JERRY_ESNEXT
extended_type |= SCANNER_LITERAL_IS_USED;
if (status_flags & SCANNER_LITERAL_POOL_FUNCTION_STATEMENT)
@@ -984,7 +916,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
* for speculative arrow parameters and local (non-var) functions. */
type = 0;
}
#endif /* JERRY_ESNEXT */
type = (uint8_t) (type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_FUNC));
JERRY_ASSERT (type == 0 || !(status_flags & SCANNER_LITERAL_POOL_FUNCTION));
@@ -1046,13 +977,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
no_declarations++;
}
#if JERRY_ESNEXT
const uint16_t is_unmapped = SCANNER_LITERAL_POOL_IS_STRICT | SCANNER_LITERAL_POOL_HAS_COMPLEX_ARGUMENT;
#else /* !JERRY_ESNEXT */
const uint16_t is_unmapped = SCANNER_LITERAL_POOL_IS_STRICT;
#endif /* JERRY_ESNEXT */
if (!(status_flags & is_unmapped))
if (!(status_flags & (SCANNER_LITERAL_POOL_IS_STRICT | SCANNER_LITERAL_POOL_HAS_COMPLEX_ARGUMENT)))
{
mapped_arguments = true;
}
@@ -1072,7 +997,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
last_argument_p = NULL;
}
#if JERRY_ESNEXT
if (status_flags & (SCANNER_LITERAL_POOL_HAS_COMPLEX_ARGUMENT | SCANNER_LITERAL_POOL_ARROW))
{
u8_arg |= SCANNER_FUNCTION_HAS_COMPLEX_ARGUMENT;
@@ -1097,7 +1021,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
u8_arg |= SCANNER_FUNCTION_IS_STRICT;
}
#endif /* JERRY_ESNEXT */
info_p->u8_arg = u8_arg;
info_p->u16_arg = (uint16_t) no_declarations;
@@ -1147,19 +1070,16 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
type = SCANNER_STREAM_TYPE_ARG_FUNC;
#if JERRY_ESNEXT
if (literal_p->type & SCANNER_LITERAL_IS_DESTRUCTURED_ARG)
{
type = SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC;
}
#endif /* JERRY_ESNEXT */
}
}
else if (literal_p->type & SCANNER_LITERAL_IS_ARG)
{
type = SCANNER_STREAM_TYPE_ARG;
#if JERRY_ESNEXT
if (literal_p->type & SCANNER_LITERAL_IS_DESTRUCTURED_ARG)
{
type = SCANNER_STREAM_TYPE_DESTRUCTURED_ARG;
@@ -1171,9 +1091,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_ARG_VAR || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR);
}
#endif /* JERRY_ESNEXT */
}
#if JERRY_ESNEXT
else if (literal_p->type & SCANNER_LITERAL_IS_LET)
{
if (!(literal_p->type & SCANNER_LITERAL_IS_CONST))
@@ -1210,7 +1128,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
type |= SCANNER_STREAM_NO_REG | SCANNER_STREAM_EARLY_CREATE;
}
#endif /* JERRY_ESNEXT */
if (literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)
{
@@ -1282,7 +1199,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
context_p->status_flags &= (uint32_t) ~PARSER_IS_STRICT;
}
#if JERRY_ESNEXT
if (prev_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_GENERATOR)
{
context_p->status_flags |= PARSER_IS_GENERATOR_FUNCTION;
@@ -1300,7 +1216,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
context_p->status_flags &= (uint32_t) ~PARSER_IS_ASYNC_FUNCTION;
}
#endif /* JERRY_ESNEXT */
}
scanner_context_p->active_literal_pool_p = literal_pool_p->prev_p;
@@ -1309,8 +1224,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
scanner_free (literal_pool_p, sizeof (scanner_literal_pool_t));
} /* scanner_pop_literal_pool */
#if JERRY_ESNEXT
/**
* Filter out the arguments from a literal pool.
*/
@@ -1467,8 +1380,6 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
scanner_free (literal_pool_p, sizeof (scanner_literal_pool_t));
} /* scanner_filter_arguments */
#endif /* JERRY_ESNEXT */
/**
* Add any literal to the specified literal pool.
*
@@ -1522,13 +1433,11 @@ scanner_add_custom_literal (parser_context_t *context_p, /**< context */
}
}
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (literal_pool_p->status_flags & SCANNER_LITERAL_POOL_CLASS_NAME))
{
literal_pool_p = literal_pool_p->prev_p;
continue;
}
#endif /* JERRY_ESNEXT */
literal_p = (lexer_lit_location_t *) parser_list_append (context_p, &literal_pool_p->literal_pool);
*literal_p = *literal_location_p;
@@ -1565,9 +1474,7 @@ scanner_add_reference (parser_context_t *context_p, /**< context */
{
lexer_lit_location_t *lit_location_p =
scanner_add_custom_literal (context_p, scanner_context_p->active_literal_pool_p, &context_p->token.lit_location);
#if JERRY_ESNEXT
lit_location_p->type |= SCANNER_LITERAL_IS_USED;
#endif /* JERRY_ESNEXT */
if (scanner_context_p->active_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_IN_WITH)
{
@@ -1634,12 +1541,10 @@ scanner_append_argument (parser_context_t *context_p, /**< context */
{
literal_p->length = 0;
#if JERRY_ESNEXT
if (literal_p->type & SCANNER_LITERAL_IS_USED)
{
literal_type = SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_EARLY_CREATE;
}
#endif /* JERRY_ESNEXT */
}
literal_p = (lexer_lit_location_t *) parser_list_append (context_p, &literal_pool_p->literal_pool);
@@ -1699,18 +1604,11 @@ scanner_detect_eval_call (parser_context_t *context_p, /**< context */
{
if (context_p->token.keyword_type == LEXER_KEYW_EVAL && lexer_check_next_character (context_p, LIT_CHAR_LEFT_PAREN))
{
#if JERRY_ESNEXT
const uint16_t flags = (uint16_t) (SCANNER_LITERAL_POOL_CAN_EVAL | SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE);
#else /* !JERRY_ESNEXT */
const uint16_t flags = SCANNER_LITERAL_POOL_CAN_EVAL;
#endif /* JERRY_ESNEXT */
scanner_context_p->active_literal_pool_p->status_flags |= flags;
scanner_context_p->active_literal_pool_p->status_flags |=
(SCANNER_LITERAL_POOL_CAN_EVAL | SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE);
}
} /* scanner_detect_eval_call */
#if JERRY_ESNEXT
/**
* Throws an error for invalid var statements.
*/
@@ -2005,8 +1903,6 @@ scanner_append_hole (parser_context_t *context_p, scanner_context_t *scanner_con
literal_p->status_flags = LEXER_LIT_LOCATION_NO_OPTS;
} /* scanner_append_hole */
#endif /* JERRY_ESNEXT */
/**
* Reverse the scanner info chain after the scanning is completed.
*/
@@ -2071,15 +1967,11 @@ scanner_cleanup (parser_context_t *context_p) /**< context */
}
case SCANNER_TYPE_WHILE:
case SCANNER_TYPE_FOR_IN:
#if JERRY_ESNEXT
case SCANNER_TYPE_FOR_OF:
#endif /* JERRY_ESNEXT */
case SCANNER_TYPE_CASE:
#if JERRY_ESNEXT
case SCANNER_TYPE_INITIALIZER:
case SCANNER_TYPE_CLASS_FIELD_INITIALIZER_END:
case SCANNER_TYPE_CLASS_STATIC_BLOCK_END:
#endif /* JERRY_ESNEXT */
{
size = sizeof (scanner_location_info_t);
break;
@@ -2095,25 +1987,19 @@ scanner_cleanup (parser_context_t *context_p) /**< context */
size = sizeof (scanner_switch_info_t);
break;
}
#if JERRY_ESNEXT
case SCANNER_TYPE_CLASS_CONSTRUCTOR:
{
scanner_release_private_fields (((scanner_class_info_t *) scanner_info_p)->members);
size = sizeof (scanner_class_info_t);
break;
}
#endif /* JERRY_ESNEXT */
default:
{
#if JERRY_ESNEXT
JERRY_ASSERT (
scanner_info_p->type == SCANNER_TYPE_END_ARGUMENTS || scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS
|| scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION || scanner_info_p->type == SCANNER_TYPE_ERR_REDECLARED
|| scanner_info_p->type == SCANNER_TYPE_ERR_ASYNC_FUNCTION
|| scanner_info_p->type == SCANNER_TYPE_EXPORT_MODULE_SPECIFIER);
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (scanner_info_p->type == SCANNER_TYPE_END_ARGUMENTS);
#endif /* JERRY_ESNEXT */
break;
}
}
@@ -2141,24 +2027,15 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
JERRY_UNUSED (check_type);
#if JERRY_ESNEXT
JERRY_ASSERT ((check_type == PARSER_CHECK_BLOCK_CONTEXT ? info_p->type == SCANNER_TYPE_BLOCK
: info_p->type == SCANNER_TYPE_FUNCTION));
uint32_t scope_stack_reg_top =
(check_type != PARSER_CHECK_GLOBAL_CONTEXT ? context_p->scope_stack_reg_top : 1); /* block result */
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (check_type == PARSER_CHECK_BLOCK_CONTEXT);
JERRY_ASSERT (info_p->type == SCANNER_TYPE_BLOCK);
uint32_t scope_stack_reg_top = context_p->scope_stack_reg_top;
#endif /* !JERRY_NDEBUG */
while (data_p[0] != SCANNER_STREAM_TYPE_END)
{
uint8_t data = data_p[0];
#if JERRY_ESNEXT
uint32_t type = data & SCANNER_STREAM_TYPE_MASK;
if (JERRY_UNLIKELY (check_type == PARSER_CHECK_FUNCTION_CONTEXT))
@@ -2219,11 +2096,6 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|| type == SCANNER_STREAM_TYPE_FUNC);
}
#endif /* !JERRY_NDEBUG */
#else /* !JERRY_ESNEXT */
JERRY_ASSERT ((data & SCANNER_STREAM_TYPE_MASK) == SCANNER_STREAM_TYPE_VAR);
#endif /* JERRY_ESNEXT */
if (!(data & SCANNER_STREAM_UINT16_DIFF))
{
if (data_p[2] != 0)
@@ -2240,7 +2112,6 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
data_p += 2 + 2;
}
#if JERRY_ESNEXT
#if JERRY_MODULE_SYSTEM
const bool is_import = (type == SCANNER_STREAM_TYPE_IMPORT);
#else /* !JERRY_MODULE_SYSTEM */
@@ -2275,7 +2146,6 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
continue;
}
}
#endif /* JERRY_ESNEXT */
if ((data & SCANNER_STREAM_NO_REG) || scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
{
@@ -2288,8 +2158,6 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
return false;
} /* scanner_is_context_needed */
#if JERRY_ESNEXT
/**
* Try to scan/parse the ".target" part in the "new.target" expression.
*
@@ -2326,8 +2194,6 @@ scanner_try_scan_new_target (parser_context_t *context_p) /**< parser/scanner co
return false;
} /* scanner_try_scan_new_target */
#endif /* JERRY_ESNEXT */
/**
* Description of "arguments" literal string.
*/
@@ -2356,7 +2222,6 @@ scanner_create_unused_literal (parser_context_t *context_p, /**< context */
context_p->literal_count++;
} /* scanner_create_unused_literal */
#if JERRY_ESNEXT
/**
* Emit checks for redeclared bindings in the global lexical scope.
*/
@@ -2438,7 +2303,6 @@ scanner_check_variables (parser_context_t *context_p) /**< context */
parser_flush_cbc (context_p);
} /* scanner_check_variables */
#endif /* JERRY_ESNEXT */
/**
* Create and/or initialize var/let/const/function/etc. variables.
@@ -2560,10 +2424,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
map_to = (uint16_t) (PARSER_REGISTER_START + scope_stack_reg_top);
#if JERRY_ESNEXT
scope_stack_p->map_to = (uint16_t) (scope_stack_reg_top + 1);
#endif /* JERRY_ESNEXT */
scope_stack_reg_top++;
}
else
@@ -2573,19 +2434,14 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
#if JERRY_ESNEXT
if (data_p[0] & SCANNER_STREAM_LOCAL_ARGUMENTS)
{
context_p->status_flags |= PARSER_LEXICAL_BLOCK_NEEDED;
}
scope_stack_p->map_to = 0;
#endif /* JERRY_ESNEXT */
}
#if !JERRY_ESNEXT
scope_stack_p->map_to = map_to;
#endif /* !JERRY_ESNEXT */
scope_stack_p++;
#if JERRY_PARSER_DUMP_BYTE_CODE
@@ -2594,7 +2450,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
parser_emit_cbc_ext_literal (context_p, CBC_EXT_CREATE_ARGUMENTS, map_to);
#if JERRY_ESNEXT
if (type == SCANNER_STREAM_TYPE_ARGUMENTS_FUNC)
{
if (JERRY_UNLIKELY (scope_stack_p >= scope_stack_end_p))
@@ -2609,7 +2464,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
scanner_create_unused_literal (context_p, 0);
}
#endif /* JERRY_ESNEXT */
if (option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_ARGS)
{
@@ -2650,7 +2504,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
if (option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_BODY)
{
#if JERRY_ESNEXT
if ((context_p->status_flags & PARSER_LEXICAL_BLOCK_NEEDED)
&& (type == SCANNER_STREAM_TYPE_ARG_VAR || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR))
{
@@ -2667,7 +2520,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
parser_emit_cbc_ext_literal_from_token (context_p, CBC_EXT_COPY_FROM_ARG);
}
}
#endif /* JERRY_ESNEXT */
literal.char_p += data_p[1];
continue;
@@ -2691,9 +2543,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
JERRY_ASSERT (scope_stack_p >= context_p->scope_stack_p + 2);
JERRY_ASSERT (context_p->status_flags & PARSER_IS_FUNCTION);
#if JERRY_ESNEXT
JERRY_ASSERT (!(context_p->status_flags & PARSER_FUNCTION_IS_PARSING_ARGS));
#endif /* JERRY_ESNEXT */
parser_scope_stack_t *function_map_p = scope_stack_p - 2;
uint16_t literal_index = context_p->lit_object.index;
@@ -2709,13 +2559,11 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
cbc_opcode_t opcode = CBC_SET_VAR_FUNC;
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (context_p->status_flags & PARSER_LEXICAL_BLOCK_NEEDED)
&& (function_map_p[0].map_to & PARSER_SCOPE_STACK_REGISTER_MASK) == 0)
{
opcode = CBC_INIT_ARG_OR_FUNC;
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc_literal_value (context_p,
(uint16_t) opcode,
@@ -2732,7 +2580,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
scope_stack_p->map_from = context_p->lit_object.index;
#if JERRY_ESNEXT
if (info_type == SCANNER_TYPE_FUNCTION)
{
if (type != SCANNER_STREAM_TYPE_LET
@@ -2744,7 +2591,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_GLOBAL;
}
}
#endif /* JERRY_ESNEXT */
uint16_t map_to;
uint16_t func_init_opcode = CBC_INIT_ARG_OR_FUNC;
@@ -2752,15 +2598,9 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
if (!(data_p[0] & SCANNER_STREAM_NO_REG) && scope_stack_reg_top < PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
{
map_to = (uint16_t) (PARSER_REGISTER_START + scope_stack_reg_top);
#if JERRY_ESNEXT
scope_stack_p->map_to = (uint16_t) (scope_stack_reg_top + 1);
#else /* !JERRY_ESNEXT */
scope_stack_p->map_to = map_to;
#endif /* JERRY_ESNEXT */
scope_stack_reg_top++;
#if JERRY_ESNEXT
switch (type)
{
case SCANNER_STREAM_TYPE_CONST:
@@ -2782,18 +2622,13 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
}
func_init_opcode = CBC_SET_VAR_FUNC;
#endif /* JERRY_ESNEXT */
}
else
{
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_USED;
map_to = context_p->lit_object.index;
#if JERRY_ESNEXT
uint16_t scope_stack_map_to = 0;
#else /* !JERRY_ESNEXT */
scope_stack_p->map_to = map_to;
#endif /* JERRY_ESNEXT */
if (info_type == SCANNER_TYPE_FUNCTION)
{
@@ -2802,7 +2637,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
switch (type)
{
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_LET:
case SCANNER_STREAM_TYPE_CONST:
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG:
@@ -2819,14 +2653,11 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
/* FALLTHRU */
}
case SCANNER_STREAM_TYPE_LOCAL:
#endif /* JERRY_ESNEXT */
case SCANNER_STREAM_TYPE_VAR:
{
#if JERRY_PARSER_DUMP_BYTE_CODE
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
#if JERRY_ESNEXT
uint16_t opcode;
switch (type)
@@ -2867,43 +2698,34 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
break;
}
}
#else /* !JERRY_ESNEXT */
uint16_t opcode = ((option_flags & SCANNER_CREATE_VARS_IS_SCRIPT) ? CBC_CREATE_VAR_EVAL : CBC_CREATE_VAR);
#endif /* JERRY_ESNEXT */
parser_emit_cbc_literal (context_p, opcode, map_to);
break;
}
case SCANNER_STREAM_TYPE_ARG:
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_ARG_VAR:
#endif /* JERRY_ESNEXT */
case SCANNER_STREAM_TYPE_ARG_FUNC:
{
#if JERRY_PARSER_DUMP_BYTE_CODE
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
#if JERRY_ESNEXT
scope_stack_map_to |= PARSER_SCOPE_STACK_NO_FUNCTION_COPY;
/* Argument initializers of functions with simple arguments (e.g. function f(a,b,a) {}) are
* generated here. The other initializers are handled by parser_parse_function_arguments(). */
if (!(info_u8_arg & SCANNER_FUNCTION_HAS_COMPLEX_ARGUMENT))
{
#endif /* JERRY_ESNEXT */
parser_emit_cbc_literal_value (context_p,
CBC_INIT_ARG_OR_FUNC,
(uint16_t) (PARSER_REGISTER_START + scope_stack_reg_top),
map_to);
#if JERRY_ESNEXT
}
else if (data_p[0] & SCANNER_STREAM_EARLY_CREATE)
{
parser_emit_cbc_literal (context_p, CBC_CREATE_LOCAL, map_to);
scope_stack_map_to |= PARSER_SCOPE_STACK_IS_LOCAL_CREATED;
}
#endif /* JERRY_ESNEXT */
if (scope_stack_reg_top < PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
{
@@ -2913,9 +2735,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
}
}
#if JERRY_ESNEXT
scope_stack_p->map_to = scope_stack_map_to;
#endif /* JERRY_ESNEXT */
}
scope_stack_p++;
@@ -2939,7 +2759,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
if (func_init_opcode == CBC_INIT_ARG_OR_FUNC && (option_flags & SCANNER_CREATE_VARS_IS_SCRIPT))
{
#if JERRY_ESNEXT
literal.char_p -= data_p[1];
if (!scanner_scope_find_lexical_declaration (context_p, &literal))
@@ -2952,9 +2771,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
}
}
literal.char_p += data_p[1];
#else /* !JERRY_ESNEXT */
func_init_opcode = CBC_CREATE_VAR_FUNC_EVAL;
#endif /* JERRY_ESNEXT */
}
parser_emit_cbc_literal_value (context_p, func_init_opcode, context_p->literal_count, map_to);
@@ -2970,12 +2786,10 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
context_p->scope_stack_reg_top = (uint16_t) scope_stack_reg_top;
#if JERRY_ESNEXT
if (info_type == SCANNER_TYPE_FUNCTION)
{
context_p->scope_stack_global_end = context_p->scope_stack_top;
}
#endif /* JERRY_ESNEXT */
if (context_p->register_count < scope_stack_reg_top)
{
@@ -3021,16 +2835,10 @@ scanner_decode_map_to (parser_scope_stack_t *stack_item_p) /**< scope stack item
{
JERRY_ASSERT (stack_item_p->map_from != PARSER_SCOPE_STACK_FUNC);
#if JERRY_ESNEXT
uint16_t value = (stack_item_p->map_to & PARSER_SCOPE_STACK_REGISTER_MASK);
return (value == 0) ? stack_item_p->map_from : (uint16_t) (value + (PARSER_REGISTER_START - 1));
#else /* !JERRY_ESNEXT */
return stack_item_p->map_to;
#endif /* JERRY_ESNEXT */
} /* scanner_decode_map_to */
#if JERRY_ESNEXT
/**
* Find the given literal index in the scope stack
* and save it the constant literal pool if the literal is register stored
@@ -3142,8 +2950,6 @@ scanner_literal_exists (parser_context_t *context_p, /**< context */
return false;
} /* scanner_literal_exists */
#endif /* JERRY_ESNEXT */
/**
* @}
* @}
File diff suppressed because it is too large Load Diff
-41
View File
@@ -39,12 +39,9 @@ typedef enum
SCANNER_TYPE_WHILE, /**< while statement */
SCANNER_TYPE_FOR, /**< for statement */
SCANNER_TYPE_FOR_IN, /**< for-in statement */
#if JERRY_ESNEXT
SCANNER_TYPE_FOR_OF, /**< for-of statement */
#endif /* JERRY_ESNEXT */
SCANNER_TYPE_SWITCH, /**< switch statement */
SCANNER_TYPE_CASE, /**< case statement */
#if JERRY_ESNEXT
SCANNER_TYPE_INITIALIZER, /**< destructuring binding or assignment pattern with initializer */
SCANNER_TYPE_LITERAL_FLAGS, /**< object or array literal with non-zero flags (stored in u8_arg) */
SCANNER_TYPE_CLASS_CONSTRUCTOR, /**< class constructor */
@@ -54,7 +51,6 @@ typedef enum
SCANNER_TYPE_ERR_REDECLARED, /**< syntax error: a variable is redeclared */
SCANNER_TYPE_ERR_ASYNC_FUNCTION, /**< an invalid async function follows */
SCANNER_TYPE_EXPORT_MODULE_SPECIFIER, /**< export with module specifier */
#endif /* JERRY_ESNEXT */
} scanner_info_type_t;
/**
@@ -167,10 +163,8 @@ typedef enum
SCANNER_STREAM_HAS_ESCAPE = (1 << 6), /**< binding has escape */
SCANNER_STREAM_NO_REG = (1 << 5), /**< binding cannot be stored in register */
SCANNER_STREAM_EARLY_CREATE = (1 << 4), /**< binding must be created with ECMA_VALUE_UNINITIALIZED */
#if JERRY_ESNEXT
SCANNER_STREAM_LOCAL_ARGUMENTS = SCANNER_STREAM_EARLY_CREATE, /**< arguments is redeclared
* as let/const binding later */
#endif /* JERRY_ESNEXT */
/* Update SCANNER_STREAM_TYPE_MASK macro if more bits are added. */
} scanner_compressed_stream_flags_t;
@@ -182,35 +176,27 @@ typedef enum
SCANNER_STREAM_TYPE_END, /**< end of scanner data */
SCANNER_STREAM_TYPE_HOLE, /**< no name is assigned to this argument */
SCANNER_STREAM_TYPE_ARGUMENTS, /**< arguments object should be created */
#if JERRY_ESNEXT
SCANNER_STREAM_TYPE_ARGUMENTS_FUNC, /**< arguments object should be created which
* is later initialized with a function */
#endif /* JERRY_ESNEXT */
SCANNER_STREAM_TYPE_VAR, /**< var declaration */
#if JERRY_ESNEXT
SCANNER_STREAM_TYPE_LET, /**< let declaration */
SCANNER_STREAM_TYPE_CONST, /**< const declaration */
SCANNER_STREAM_TYPE_LOCAL, /**< local declaration (e.g. catch block) */
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
SCANNER_STREAM_TYPE_IMPORT, /**< module import */
#endif /* JERRY_MODULE_SYSTEM */
/* The next four types must be in this order (see SCANNER_STREAM_TYPE_IS_ARG). */
SCANNER_STREAM_TYPE_ARG, /**< argument declaration */
#if JERRY_ESNEXT
SCANNER_STREAM_TYPE_ARG_VAR, /**< argument declaration which is later copied
* into a variable declared by var statement */
SCANNER_STREAM_TYPE_DESTRUCTURED_ARG, /**< destructuring argument declaration */
SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR, /**< destructuring argument declaration which is later
* copied into a variable declared by var statement */
#endif /* JERRY_ESNEXT */
/* Function types should be at the end. See the SCANNER_STREAM_TYPE_IS_FUNCTION macro. */
SCANNER_STREAM_TYPE_ARG_FUNC, /**< argument declaration which
* is later initialized with a function */
#if JERRY_ESNEXT
SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC, /**< destructuring argument declaration which
* is later initialized with a function */
#endif /* JERRY_ESNEXT */
SCANNER_STREAM_TYPE_FUNC, /**< function declaration */
} scanner_compressed_stream_types_t;
@@ -224,8 +210,6 @@ typedef enum
*/
#define SCANNER_STREAM_TYPE_IS_FUNCTION(type) ((type) >= SCANNER_STREAM_TYPE_ARG_FUNC)
#if JERRY_ESNEXT
/**
* Checks whether the decoded type represents a function argument.
*/
@@ -244,25 +228,6 @@ typedef enum
#define SCANNER_STREAM_TYPE_IS_ARGUMENTS(type) \
((type) == SCANNER_STREAM_TYPE_ARGUMENTS || (type) == SCANNER_STREAM_TYPE_ARGUMENTS_FUNC)
#else /* !JERRY_ESNEXT */
/**
* Checks whether the decoded type represents a function argument.
*/
#define SCANNER_STREAM_TYPE_IS_ARG(type) ((type) == SCANNER_STREAM_TYPE_ARG)
/**
* Checks whether the decoded type represents both a function argument and a function declaration.
*/
#define SCANNER_STREAM_TYPE_IS_ARG_FUNC(type) ((type) == SCANNER_STREAM_TYPE_ARG_FUNC)
/**
* Checks whether the decoded type represents an arguments declaration
*/
#define SCANNER_STREAM_TYPE_IS_ARGUMENTS(type) ((type) == SCANNER_STREAM_TYPE_ARGUMENTS)
#endif /* JERRY_ESNEXT */
/**
* Constants for u8_arg flags in scanner_function_info_t.
*/
@@ -270,12 +235,10 @@ typedef enum
{
SCANNER_FUNCTION_ARGUMENTS_NEEDED = (1 << 0), /**< arguments object needs to be created */
SCANNER_FUNCTION_HAS_COMPLEX_ARGUMENT = (1 << 1), /**< function has complex (ES2015+) argument definition */
#if JERRY_ESNEXT
SCANNER_FUNCTION_LEXICAL_ENV_NEEDED = (1 << 2), /**< lexical environment is needed for the function body */
SCANNER_FUNCTION_STATEMENT = (1 << 3), /**< function is function statement (not arrow expression)
* this flag must be combined with the type of function (e.g. async) */
SCANNER_FUNCTION_ASYNC = (1 << 4), /**< function is async function */
#endif /* JERRY_ESNEXT */
SCANNER_FUNCTION_IS_STRICT = (1 << 5), /**< function is strict */
} scanner_function_flags_t;
@@ -306,8 +269,6 @@ typedef enum
SCANNER_PRIVATE_FIELD_PROPERTY_GETTER_SETTER = (SCANNER_PRIVATE_FIELD_PROPERTY | SCANNER_PRIVATE_FIELD_GETTER_SETTER),
} scanner_private_field_flags_t;
#if JERRY_ESNEXT
/**
* Object or array literal constants for u8_arg flags in scanner_info_t.
*/
@@ -321,8 +282,6 @@ typedef enum
SCANNER_LITERAL_OBJECT_HAS_REST = (1 << 3), /**< the object literal has a member prefixed with three dots */
} scanner_literal_flags_t;
#endif /* JERRY_ESNEXT */
/**
* Option bits for scanner_create_variables function.
*/
@@ -16,9 +16,6 @@
/* This file is automatically generated by the gen-strings.py script
* from parser-error-messages.ini. Do not edit! */
#if JERRY_PARSER && !(JERRY_ESNEXT)
PARSER_ERROR_DEF (PARSER_ERR_INVALID_NUMBER, "Invalid number")
#endif /* JERRY_PARSER && !(JERRY_ESNEXT) */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_DUPLICATED_LABEL, "Duplicated label")
PARSER_ERROR_DEF (PARSER_ERR_LEFT_PAREN_EXPECTED, "Expected '(' token")
@@ -28,10 +25,10 @@ PARSER_ERROR_DEF (PARSER_ERR_SEMICOLON_EXPECTED, "Expected ';' token")
PARSER_ERROR_DEF (PARSER_ERR_RIGHT_SQUARE_EXPECTED, "Expected ']' token")
PARSER_ERROR_DEF (PARSER_ERR_LEFT_BRACE_EXPECTED, "Expected '{' token")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER || JERRY_MODULE_SYSTEM
#if JERRY_MODULE_SYSTEM || JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_RIGHT_BRACE_EXPECTED, "Expected '}' token")
#endif /* JERRY_ESNEXT && JERRY_PARSER \
|| JERRY_MODULE_SYSTEM */
#endif /* JERRY_MODULE_SYSTEM \
|| JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_NUMBER_TOO_LONG, "Number is too long")
#endif /* JERRY_PARSER */
@@ -47,30 +44,22 @@ PARSER_ERROR_DEF (PARSER_ERR_AS_EXPECTED, "Expected 'as' token")
#endif /* JERRY_MODULE_SYSTEM && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_IN_EXPECTED, "Expected 'in' token")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_OF_EXPECTED, "Expected 'of' token")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_EXPRESSION_EXPECTED, "Expression expected")
#endif /* JERRY_PARSER */
#if JERRY_MODULE_SYSTEM || JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_IDENTIFIER_EXPECTED, "Identifier expected")
#endif /* JERRY_MODULE_SYSTEM \
|| JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_OCTAL_DIGIT, "Invalid octal digit")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_OCTAL_DIGIT, "Invalid octal digit")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_SWITCH, "Invalid switch body")
#endif /* JERRY_PARSER */
#if JERRY_BUILTIN_REGEXP && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_UNKNOWN_REGEXP_FLAG, "Unknown regexp flag")
#endif /* JERRY_BUILTIN_REGEXP && JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_BIN_DIGIT, "Invalid binary digit")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_BIN_DIGIT, "Invalid binary digit")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_RIGHT_SQUARE, "Unexpected '}' token")
#endif /* JERRY_PARSER */
#if JERRY_MODULE_SYSTEM && JERRY_PARSER
@@ -91,10 +80,8 @@ PARSER_ERROR_DEF (PARSER_ERR_META_EXPECTED, "Expected 'meta' keyword")
#endif /* JERRY_MODULE_SYSTEM && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_UNEXPECTED_END, "Unexpected end of input")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_UNEXPECTED_PRIVATE_FIELD, "Unexpected private field")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#endif /* JERRY_PARSER */
#if JERRY_MODULE_SYSTEM && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_LEFT_BRACE_MULTIPLY_EXPECTED, "Expected '{' or '*' token")
#endif /* JERRY_MODULE_SYSTEM && JERRY_PARSER */
@@ -117,10 +104,10 @@ PARSER_ERROR_DEF (PARSER_ERR_FROM_COMMA_EXPECTED, "Expected 'from' or ',' token"
#if JERRY_MODULE_SYSTEM
PARSER_ERROR_DEF (PARSER_ERR_EXPORT_NOT_DEFINED, "Export not defined in module")
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_ESNEXT && JERRY_PARSER || JERRY_MODULE_SYSTEM
#if JERRY_MODULE_SYSTEM || JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_VARIABLE_REDECLARED, "Local variable is redeclared")
#endif /* JERRY_ESNEXT && JERRY_PARSER \
|| JERRY_MODULE_SYSTEM */
#endif /* JERRY_MODULE_SYSTEM \
|| JERRY_PARSER */
#if JERRY_BUILTIN_BIGINT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_BIGINT, "Number is not a valid BigInt")
#endif /* JERRY_BUILTIN_BIGINT && JERRY_PARSER */
@@ -130,10 +117,8 @@ PARSER_ERROR_DEF (PARSER_ERR_PROPERTY_IDENTIFIER_EXPECTED, "Property identifier
#if JERRY_MODULE_SYSTEM
PARSER_ERROR_DEF (PARSER_ERR_DUPLICATED_EXPORT_IDENTIFIER, "Duplicate exported identifier")
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_NEW_TARGET_EXPECTED, "Expected new.target expression")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_NEW_TARGET_EXPECTED, "Expected new.target expression")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_CHARACTER, "Invalid (unexpected) character")
PARSER_ERROR_DEF (PARSER_ERR_NON_STRICT_ARG_DEFINITION, "Non-strict argument definition")
PARSER_ERROR_DEF (PARSER_ERR_UNTERMINATED_MULTILINE_COMMENT, "Unterminated multiline comment")
@@ -145,36 +130,23 @@ PARSER_ERROR_DEF (PARSER_ERR_DUPLICATED_IMPORT_BINDING, "Duplicated imported bin
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_WHILE_EXPECTED, "While expected for do-while loop")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_DELETE_PRIVATE_FIELD, "Private fields can not be deleted")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_LHS_FOR_LOOP, "Invalid left-hand-side in for-loop")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_LEFT_HAND_SIDE_EXP_EXPECTED, "Left-hand-side expression expected")
PARSER_ERROR_DEF (PARSER_ERR_LITERAL_LIMIT_REACHED, "Maximum number of literals reached")
PARSER_ERROR_DEF (PARSER_ERR_STACK_LIMIT_REACHED, "Maximum function stack size reached")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_AWAIT_NOT_ALLOWED, "Await expression is not allowed here")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#endif /* JERRY_PARSER */
#if JERRY_MODULE_SYSTEM && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_LEFT_BRACE_MULTIPLY_LITERAL_EXPECTED, "Expected '{' or '*' or literal token")
#endif /* JERRY_MODULE_SYSTEM && JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_LHS_ASSIGNMENT, "Invalid left-hand side in assignment")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_LHS_ASSIGNMENT, "Invalid left-hand side in assignment")
PARSER_ERROR_DEF (PARSER_ERR_SCOPE_STACK_LIMIT_REACHED, "Maximum depth of scope stack reached")
#endif /* JERRY_PARSER */
#if !JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_OBJECT_PROPERTY_REDEFINED, "Property of object literal redefined")
#endif /* !JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_UNEXPECTED_SUPER_KEYWORD, "Super is not allowed to be used here")
PARSER_ERROR_DEF (PARSER_ERR_YIELD_NOT_ALLOWED, "Yield expression is not allowed here")
PARSER_ERROR_DEF (PARSER_ERR_MULTIPLE_CLASS_CONSTRUCTORS, "Multiple constructors are not allowed")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#endif /* JERRY_PARSER */
#if JERRY_MODULE_SYSTEM
PARSER_ERROR_DEF (PARSER_ERR_MODULE_UNEXPECTED, "Unexpected import or export statement")
#endif /* JERRY_MODULE_SYSTEM */
@@ -182,21 +154,13 @@ PARSER_ERROR_DEF (PARSER_ERR_MODULE_UNEXPECTED, "Unexpected import or export sta
PARSER_ERROR_DEF (PARSER_ERR_IDENTIFIER_AFTER_NUMBER, "Identifier cannot start after a number")
PARSER_ERROR_DEF (PARSER_ERR_MULTIPLE_DEFAULTS_NOT_ALLOWED, "Multiple default cases are not allowed")
PARSER_ERROR_DEF (PARSER_ERR_ARRAY_ITEM_SEPARATOR_EXPECTED, "Expected ',' or ']' after an array item")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_ILLEGAL_PROPERTY_IN_DECLARATION, "Illegal property in declaration context")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_DESTRUCTURING_PATTERN, "Invalid destructuring assignment target")
PARSER_ERROR_DEF (PARSER_ERR_DUPLICATED_PRIVATE_FIELD, "Private field has already been declared")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_NO_ARGUMENTS_EXPECTED, "Property getters must have no arguments")
PARSER_ERROR_DEF (PARSER_ERR_ONE_ARGUMENT_EXPECTED, "Property setters must have one argument")
PARSER_ERROR_DEF (PARSER_ERR_CASE_NOT_IN_SWITCH, "Case statement must be in a switch block")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_CLASS_CONSTRUCTOR_AS_ACCESSOR, "Class constructor may not be an accessor")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_CONTINUE, "Continue statement must be inside a loop")
#endif /* JERRY_PARSER */
#if JERRY_MODULE_SYSTEM && JERRY_PARSER
@@ -206,37 +170,23 @@ PARSER_ERROR_DEF (PARSER_ERR_IMPORT_META_REQUIRE_MODULE, "Cannot use 'import.met
PARSER_ERROR_DEF (PARSER_ERR_INVALID_IDENTIFIER_PART, "Character cannot be part of an identifier")
PARSER_ERROR_DEF (PARSER_ERR_EVAL_CANNOT_ASSIGNED, "Eval cannot be assigned to in strict mode")
PARSER_ERROR_DEF (PARSER_ERR_WITH_NOT_ALLOWED, "With statement not allowed in strict mode")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_NEW_TARGET_NOT_ALLOWED, "new.target expression is not allowed here")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_IDENTIFIER_START, "Character cannot be start of an identifier")
PARSER_ERROR_DEF (PARSER_ERR_STRICT_IDENT_NOT_ALLOWED, "Identifier name is reserved in strict mode")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_NULLISH_COALESCING, "Cannot chain nullish with logical AND or OR")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_DEFAULT_NOT_IN_SWITCH, "Default statement must be in a switch block")
#endif /* JERRY_PARSER */
#if JERRY_MODULE_SYSTEM && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_IMPORT_AFTER_NEW, "Module import call is not allowed after new")
#endif /* JERRY_MODULE_SYSTEM && JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_TOO_MANY_CLASS_FIELDS, "Too many computed class fields are declared")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_TOO_MANY_CLASS_FIELDS, "Too many computed class fields are declared")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_KEYWORD, "Escape sequences are not allowed in keywords")
PARSER_ERROR_DEF (PARSER_ERR_ARGUMENT_LIMIT_REACHED, "Maximum number of function arguments reached")
PARSER_ERROR_DEF (PARSER_ERR_NEWLINE_NOT_ALLOWED, "Newline is not allowed in strings or regexps")
PARSER_ERROR_DEF (PARSER_ERR_OCTAL_NUMBER_NOT_ALLOWED, "Octal numbers are not allowed in strict mode")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_CLASS_PRIVATE_CONSTRUCTOR, "Class constructor may not be a private method")
PARSER_ERROR_DEF (PARSER_ERR_FOR_AWAIT_NO_OF, "only 'of' form is allowed for for-await loops")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_ARGUMENTS_CANNOT_ASSIGNED, "Arguments cannot be assigned to in strict mode")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_BREAK, "Break statement must be inside a loop or switch")
PARSER_ERROR_DEF (PARSER_ERR_OBJECT_ITEM_SEPARATOR_EXPECTED, "Expected ',' or '}' after a property definition")
@@ -248,41 +198,23 @@ PARSER_ERROR_DEF (PARSER_ERR_UNSUPPORTED_REGEXP, "Regexp is not supported in the
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_INVALID_RETURN, "Return statement must be inside a function body")
PARSER_ERROR_DEF (PARSER_ERR_COLON_FOR_CONDITIONAL_EXPECTED, "Expected ':' token for ?: conditional expression")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER, "Rest parameter must be the last formal parameter")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_DELETE_IDENT_NOT_ALLOWED, "Deleting identifier is not allowed in strict mode")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_LABELLED_FUNC_NOT_IN_BLOCK, "Labelled functions are only allowed inside blocks")
PARSER_ERROR_DEF (PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER, "Rest parameter may not have a default initializer")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_EVAL_NOT_ALLOWED, "Eval is not allowed to be used here in strict mode")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_CONTINUE_LABEL, "Labeled statement targeted by a continue not found")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_LEXICAL_LET_BINDING, "Let binding cannot appear in let/const declarations")
PARSER_ERROR_DEF (PARSER_ERR_UNDECLARED_PRIVATE_FIELD, "Private field must be declared in an enclosing class")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_LHS_PREFIX_OP, "Invalid left-hand side expression in prefix operation")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_OCTAL_ESCAPE_NOT_ALLOWED, "Octal escape sequences are not allowed in strict mode")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_SETTER_REST_PARAMETER, "Setter function argument must not be a rest parameter")
PARSER_ERROR_DEF (PARSER_ERR_ARGUMENTS_IN_CLASS_FIELD, "In class field declarations 'arguments' is not allowed")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_LHS_POSTFIX_OP, "Invalid left-hand side expression in postfix operation")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER, "Invalid use of underscore character in number literals")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_EXPONENTIATION, "Left operand of ** operator cannot be unary expression")
PARSER_ERROR_DEF (PARSER_ERR_MISSING_ASSIGN_AFTER_CONST, "Value assignment is expected after a const declaration")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#if JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_ARGUMENTS_NOT_ALLOWED, "Arguments is not allowed to be used here in strict mode")
#endif /* JERRY_PARSER */
#if JERRY_ESNEXT && JERRY_PARSER
PARSER_ERROR_DEF (PARSER_ERR_DUPLICATED_ARGUMENT_NAMES, "Duplicated function argument names are not allowed here")
PARSER_ERROR_DEF (PARSER_ERR_CLASS_STATIC_PROTOTYPE, "Classes may not have a static property called 'prototype'")
PARSER_ERROR_DEF (PARSER_ERR_INVALID_CLASS_CONSTRUCTOR, "Class constructor may not be a generator or async function")
@@ -298,4 +230,4 @@ PARSER_ERROR_DEF (PARSER_ERR_USE_STRICT_NOT_ALLOWED,
"The 'use strict' directive is not allowed for functions with non-simple arguments")
PARSER_ERROR_DEF (PARSER_ERR_ASSIGNMENT_EXPECTED,
"Unexpected arrow function or yield expression (parentheses around the expression may help)")
#endif /* JERRY_ESNEXT && JERRY_PARSER */
#endif /* JERRY_PARSER */
@@ -73,7 +73,6 @@ PARSER_ERR_INVALID_LHS_FOR_LOOP = "Invalid left-hand-side in for-loop"
PARSER_ERR_INVALID_LHS_POSTFIX_OP = "Invalid left-hand side expression in postfix operation"
PARSER_ERR_INVALID_LHS_PREFIX_OP = "Invalid left-hand side expression in prefix operation"
PARSER_ERR_INVALID_NULLISH_COALESCING = "Cannot chain nullish with logical AND or OR"
PARSER_ERR_INVALID_NUMBER = "Invalid number"
PARSER_ERR_INVALID_OCTAL_DIGIT = "Invalid octal digit"
PARSER_ERR_INVALID_RETURN = "Return statement must be inside a function body"
PARSER_ERR_INVALID_RIGHT_SQUARE = "Unexpected '}' token"
@@ -103,7 +102,6 @@ PARSER_ERR_NON_STRICT_ARG_DEFINITION = "Non-strict argument definition"
PARSER_ERR_NO_ARGUMENTS_EXPECTED = "Property getters must have no arguments"
PARSER_ERR_NUMBER_TOO_LONG = "Number is too long"
PARSER_ERR_OBJECT_ITEM_SEPARATOR_EXPECTED = "Expected ',' or '}' after a property definition"
PARSER_ERR_OBJECT_PROPERTY_REDEFINED = "Property of object literal redefined"
PARSER_ERR_OCTAL_ESCAPE_NOT_ALLOWED = "Octal escape sequences are not allowed in strict mode"
PARSER_ERR_OCTAL_NUMBER_NOT_ALLOWED = "Octal numbers are not allowed in strict mode"
PARSER_ERR_OF_EXPECTED = "Expected 'of' token"
-21
View File
@@ -277,22 +277,14 @@ void
re_append_char (re_compiler_ctx_t *re_ctx_p, /**< RegExp bytecode context */
const lit_code_point_t cp) /**< code point */
{
#if JERRY_ESNEXT
const size_t size = (re_ctx_p->flags & RE_FLAG_UNICODE) ? sizeof (lit_code_point_t) : sizeof (ecma_char_t);
#else /* !JERRY_ESNEXT */
JERRY_UNUSED (re_ctx_p);
const size_t size = sizeof (ecma_char_t);
#endif /* !JERRY_ESNEXT */
uint8_t *dest_p = re_bytecode_reserve (re_ctx_p, size);
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
re_encode_u32 (dest_p, cp);
return;
}
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (cp <= LIT_UTF16_CODE_UNIT_MAX);
re_encode_u16 (dest_p, (ecma_char_t) cp);
@@ -306,22 +298,15 @@ re_insert_char (re_compiler_ctx_t *re_ctx_p, /**< RegExp bytecode context */
const uint32_t offset, /**< bytecode offset */
const lit_code_point_t cp) /**< code point*/
{
#if JERRY_ESNEXT
const size_t size = (re_ctx_p->flags & RE_FLAG_UNICODE) ? sizeof (lit_code_point_t) : sizeof (ecma_char_t);
#else /* !JERRY_ESNEXT */
JERRY_UNUSED (re_ctx_p);
const size_t size = sizeof (ecma_char_t);
#endif /* !JERRY_ESNEXT */
uint8_t *dest_p = re_bytecode_insert (re_ctx_p, offset, size);
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
re_encode_u32 (dest_p, cp);
return;
}
#endif /* JERRY_ESNEXT */
JERRY_ASSERT (cp <= LIT_UTF16_CODE_UNIT_MAX);
re_encode_u16 (dest_p, (ecma_char_t) cp);
@@ -338,16 +323,12 @@ re_get_char (const uint8_t **bc_p, /**< reference to bytecode pointer */
{
lit_code_point_t cp;
#if !JERRY_ESNEXT
JERRY_UNUSED (unicode);
#else /* JERRY_ESNEXT */
if (unicode)
{
cp = re_decode_u32 (*bc_p);
*bc_p += sizeof (lit_code_point_t);
}
else
#endif /* JERRY_ESNEXT */
{
cp = re_decode_u16 (*bc_p);
*bc_p += sizeof (ecma_char_t);
@@ -594,13 +575,11 @@ re_dump_bytecode (re_compiler_ctx_t *re_ctx_p) /**< RegExp bytecode context */
JERRY_DEBUG_MSG ("\n");
break;
}
#if JERRY_ESNEXT
case RE_OP_UNICODE_PERIOD:
{
JERRY_DEBUG_MSG ("UNICODE_PERIOD\n");
break;
}
#endif /* JERRY_ESNEXT */
case RE_OP_PERIOD:
{
JERRY_DEBUG_MSG ("PERIOD\n");
-2
View File
@@ -82,9 +82,7 @@ typedef enum
RE_OP_CLASS_ESCAPE, /**< class escape */
RE_OP_CHAR_CLASS, /**< character class */
#if JERRY_ESNEXT
RE_OP_UNICODE_PERIOD, /**< period in full unicode mode */
#endif /* JERRY_ESNEXT */
RE_OP_PERIOD, /**< period in non-unicode mode */
RE_OP_CHAR, /**< any code point */
RE_OP_BYTE, /**< 1-byte utf8 character */
-33
View File
@@ -388,7 +388,6 @@ re_count_groups (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context */
}
} /* re_count_groups */
#if JERRY_ESNEXT
/**
* Check if a code point is a Syntax character
*
@@ -403,7 +402,6 @@ re_is_syntax_char (lit_code_point_t cp) /**< code point */
|| cp == LIT_CHAR_RIGHT_PAREN || cp == LIT_CHAR_LEFT_SQUARE || cp == LIT_CHAR_RIGHT_SQUARE
|| cp == LIT_CHAR_LEFT_BRACE || cp == LIT_CHAR_RIGHT_BRACE || cp == LIT_CHAR_VLINE);
} /* re_is_syntax_char */
#endif /* JERRY_ESNEXT */
/**
* Parse a Character Escape or a Character Class Escape.
@@ -429,12 +427,10 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
return ECMA_VALUE_EMPTY;
}
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
return ecma_raise_syntax_error (ECMA_ERR_INVALID_ESCAPE_SEQUENCE);
}
#endif /* JERRY_ESNEXT */
/* Legacy octal escape sequence */
if (lit_char_is_octal_digit (*re_ctx_p->input_curr_p))
@@ -531,12 +527,10 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
}
}
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
return ecma_raise_syntax_error (ECMA_ERR_INVALID_CONTROL_ESCAPE_SEQUENCE);
}
#endif /* JERRY_ESNEXT */
re_ctx_p->token.value = LIT_CHAR_BACKSLASH;
re_ctx_p->input_curr_p--;
@@ -554,12 +548,10 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
break;
}
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
return ecma_raise_syntax_error (ECMA_ERR_INVALID_HEX_ESCAPE_SEQUENCE);
}
#endif /* JERRY_ESNEXT */
re_ctx_p->token.value = LIT_CHAR_LOWERCASE_X;
break;
@@ -573,7 +565,6 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
re_ctx_p->token.value = hex_value;
re_ctx_p->input_curr_p += 4;
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE && lit_is_code_point_utf16_high_surrogate (re_ctx_p->token.value)
&& re_ctx_p->input_curr_p + 6 <= re_ctx_p->input_end_p && re_ctx_p->input_curr_p[0] == '\\'
&& re_ctx_p->input_curr_p[1] == 'u')
@@ -586,12 +577,10 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
re_ctx_p->input_curr_p += 6;
}
}
#endif /* JERRY_ESNEXT */
break;
}
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
if (re_ctx_p->input_curr_p + 1 < re_ctx_p->input_end_p && re_ctx_p->input_curr_p[0] == LIT_CHAR_LEFT_BRACE
@@ -620,7 +609,6 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
return ecma_raise_syntax_error (ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE);
}
#endif /* JERRY_ESNEXT */
re_ctx_p->token.value = LIT_CHAR_LOWERCASE_U;
break;
@@ -628,13 +616,11 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
/* Identity escape */
default:
{
#if JERRY_ESNEXT
/* Must be '/', or one of SyntaxCharacter */
if (re_ctx_p->flags & RE_FLAG_UNICODE && ch != LIT_CHAR_SLASH && !re_is_syntax_char (ch))
{
return ecma_raise_syntax_error (ECMA_ERR_INVALID_ESCAPE);
}
#endif /* JERRY_ESNEXT */
re_ctx_p->token.value = ch;
}
}
@@ -811,12 +797,10 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
return ecma_raise_syntax_error (ECMA_ERR_NOTHING_TO_REPEAT);
}
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
return ecma_raise_syntax_error (ECMA_ERR_LONE_QUANTIFIER_BRACKET);
}
#endif /* JERRY_ESNEXT */
re_ctx_p->input_curr_p++;
re_ctx_p->token.type = RE_TOK_CHAR;
@@ -825,7 +809,6 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
/* Check quantifier */
break;
}
#if JERRY_ESNEXT
case LIT_CHAR_RIGHT_SQUARE:
case LIT_CHAR_RIGHT_BRACE:
{
@@ -836,13 +819,11 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
default:
{
re_ctx_p->token.type = RE_TOK_CHAR;
re_ctx_p->token.value = ch;
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE && lit_is_code_point_utf16_high_surrogate (ch)
&& re_ctx_p->input_curr_p < re_ctx_p->input_end_p)
{
@@ -853,7 +834,6 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
re_ctx_p->input_curr_p += LIT_UTF8_MAX_BYTES_IN_CODE_UNIT;
}
}
#endif /* JERRY_ESNEXT */
/* Check quantifier */
break;
@@ -974,13 +954,11 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
re_ctx_p->input_curr_p++;
current = LIT_CHAR_BS;
}
#if JERRY_ESNEXT
else if (*re_ctx_p->input_curr_p == LIT_CHAR_MINUS)
{
re_ctx_p->input_curr_p++;
current = LIT_CHAR_MINUS;
}
#endif /* JERRY_ESNEXT */
else if ((re_ctx_p->flags & RE_FLAG_UNICODE) == 0 && *re_ctx_p->input_curr_p == LIT_CHAR_LOWERCASE_C
&& re_ctx_p->input_curr_p + 1 < re_ctx_p->input_end_p
&& (lit_char_is_decimal_digit (*(re_ctx_p->input_curr_p + 1))
@@ -1009,12 +987,10 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
}
}
}
#if JERRY_ESNEXT
else if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
current = ecma_regexp_unicode_advance (&re_ctx_p->input_curr_p, re_ctx_p->input_end_p);
}
#endif /* JERRY_ESNEXT */
else
{
current = lit_cesu8_read_next (&re_ctx_p->input_curr_p);
@@ -1036,12 +1012,10 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
continue;
}
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
return ecma_raise_syntax_error (ECMA_ERR_INVALID_CHARACTER_CLASS);
}
#endif /* JERRY_ESNEXT */
if (start != RE_INVALID_CP)
{
@@ -1180,12 +1154,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
}
case RE_TOK_PERIOD:
{
#if JERRY_ESNEXT
re_append_opcode (re_ctx_p, (re_ctx_p->flags & RE_FLAG_UNICODE) ? RE_OP_UNICODE_PERIOD : RE_OP_PERIOD);
#else /* !JERRY_ESNEXT */
re_append_opcode (re_ctx_p, RE_OP_PERIOD);
#endif /* !JERRY_ESNEXT */
re_insert_atom_iterator (re_ctx_p, atom_offset);
break;
}
@@ -1232,7 +1201,6 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
return result;
}
#if JERRY_ESNEXT
if (re_ctx_p->flags & RE_FLAG_UNICODE)
{
re_ctx_p->token.qmin = 1;
@@ -1240,7 +1208,6 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
re_ctx_p->token.greedy = true;
}
else
#endif /* JERRY_ESNEXT */
{
re_parse_quantifier (re_ctx_p);