Re-target for ES.Next (#3901)
A list of changes: - 'es2015-subset' profile is deprecated, and an 'es.next' profile is added. - The default profile is changed to 'es.next' - Renamed the JERRY_ES2015 guard to JERRY_ESNEXT - Renamed JERRY_ES2015_BUILTIN_* guards to JERRY_BUILTIN_* - Moved es2015 specific tests to a new 'es.next' subdirectory - Updated docs, targets, and test runners to reflect these changes Resolves #3737. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
@@ -64,19 +64,19 @@
|
||||
|
||||
#define CBC_HAS_POP_STACK_BYTE_ARG (CBC_HAS_BYTE_ARG | CBC_POP_STACK_BYTE_ARG)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* CBC_NO_RESULT_OPERATION for ext opcodes
|
||||
*/
|
||||
#define CBC_EXT_NO_RESULT_OPERATION(opcode) \
|
||||
((opcode) >= PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_CALL) \
|
||||
&& (opcode) <= PARSER_TO_EXT_OPCODE (CBC_EXT_SPREAD_CALL_PROP_BLOCK))
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
/**
|
||||
* CBC_NO_RESULT_OPERATION for ext opcodes
|
||||
*/
|
||||
#define CBC_EXT_NO_RESULT_OPERATION(opcode) false
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Debug macro. */
|
||||
#define CBC_ARGS_EQ(op, types) \
|
||||
|
||||
@@ -74,9 +74,9 @@ typedef enum
|
||||
LEXER_FLAG_SOURCE_PTR = (1 << 2), /**< the literal is directly referenced in the source code
|
||||
* (no need to allocate memory) */
|
||||
LEXER_FLAG_LATE_INIT = (1 << 3), /**< initialize this variable after the byte code is freed */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
LEXER_FLAG_GLOBAL = (1 << 4), /**< this local identifier is not a let or const declaration */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} lexer_literal_status_flags_t;
|
||||
|
||||
/**
|
||||
|
||||
+100
-100
@@ -92,7 +92,7 @@ lexer_hex_to_code_point (const uint8_t *source_p, /**< current source position *
|
||||
return result;
|
||||
} /* lexer_hex_to_code_point */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Parse hexadecimal character sequence enclosed in braces
|
||||
@@ -146,7 +146,7 @@ lexer_hex_in_braces_to_code_point (const uint8_t *source_p, /**< current source
|
||||
return result;
|
||||
} /* lexer_hex_in_braces_to_code_point */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Parse hexadecimal character sequence
|
||||
@@ -160,13 +160,13 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (char_p[0] == LIT_CHAR_LEFT_BRACE)
|
||||
{
|
||||
length = 0;
|
||||
char_p++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ lexer_unchecked_hex_to_character (const uint8_t **source_p) /**< [in, out] curre
|
||||
|
||||
JERRY_ASSERT (result <= LIT_UNICODE_CODE_POINT_MAX);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (length == 0)
|
||||
{
|
||||
if (*char_p != LIT_CHAR_RIGHT_BRACE)
|
||||
@@ -198,7 +198,7 @@ lexer_unchecked_hex_to_character (const uint8_t **source_p) /**< [in, out] curre
|
||||
*source_p = char_p + 1;
|
||||
return result;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (--length == 0)
|
||||
{
|
||||
@@ -395,7 +395,7 @@ lexer_skip_spaces (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* lexer_skip_spaces */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Skip all the continuous empty statements.
|
||||
*/
|
||||
@@ -413,7 +413,7 @@ lexer_skip_empty_statements (parser_context_t *context_p) /**< context */
|
||||
|
||||
context_p->token.flags = (uint8_t) (context_p->token.flags | LEXER_NO_SKIP_SPACES);
|
||||
} /* lexer_skip_empty_statements */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Keyword data.
|
||||
@@ -485,10 +485,10 @@ static const keyword_string_t keywords_with_length_4[] =
|
||||
*/
|
||||
static const keyword_string_t keywords_with_length_5[] =
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
LEXER_KEYWORD ("async", LEXER_KEYW_ASYNC),
|
||||
LEXER_KEYWORD ("await", LEXER_KEYW_AWAIT),
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
LEXER_KEYWORD ("break", LEXER_KEYW_BREAK),
|
||||
LEXER_KEYWORD ("catch", LEXER_KEYW_CATCH),
|
||||
LEXER_KEYWORD ("class", LEXER_KEYW_CLASS),
|
||||
@@ -641,7 +641,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
|
||||
has_escape = true;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (source_p + 5 <= source_end_p && source_p[1] == LIT_CHAR_LOWERCASE_U)
|
||||
{
|
||||
if (source_p[2] == LIT_CHAR_LEFT_BRACE)
|
||||
@@ -653,12 +653,12 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
code_point = lexer_hex_to_code_point (source_p + 2, 4);
|
||||
}
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (code_point == UINT32_MAX)
|
||||
{
|
||||
@@ -693,13 +693,13 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (JERRY_UNLIKELY (code_point >= LIT_UTF8_2_BYTE_MARKER))
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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;
|
||||
|
||||
/* Only ES2015 supports code points outside of the basic plane which can be part of an identifier. */
|
||||
/* Only ES2015+ supports code points outside of the basic plane which can be part of an identifier. */
|
||||
if ((code_point >= LIT_UTF16_HIGH_SURROGATE_MIN && code_point <= LIT_UTF16_HIGH_SURROGATE_MAX)
|
||||
&& source_p + 3 < source_end_p)
|
||||
{
|
||||
@@ -722,7 +722,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
decoded_length = 2 * 3;
|
||||
has_escape = true;
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
if (code_point < LIT_UTF8_4_BYTE_MARKER)
|
||||
{
|
||||
utf8_length = lit_read_code_point_from_utf8 (source_p,
|
||||
@@ -734,7 +734,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
code_point = 0;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
if (length == 0)
|
||||
@@ -817,7 +817,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (JERRY_LIKELY (keyword_p->type < LEXER_FIRST_NON_RESERVED_KEYWORD))
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (keyword_p->type == LEXER_KEYW_AWAIT))
|
||||
{
|
||||
if (!(context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
|
||||
@@ -838,7 +838,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
context_p->token.type = (uint8_t) LEXER_KEYW_AWAIT;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (ident_start_p == buffer_p)
|
||||
{
|
||||
@@ -850,7 +850,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (keyword_p->type == LEXER_KEYW_LET && (context_p->status_flags & PARSER_IS_STRICT))
|
||||
{
|
||||
if (ident_start_p == buffer_p)
|
||||
@@ -876,7 +876,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
context_p->token.type = (uint8_t) LEXER_KEYW_YIELD;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (keyword_p->type >= LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD
|
||||
&& (context_p->status_flags & PARSER_IS_STRICT))
|
||||
@@ -914,11 +914,11 @@ void
|
||||
lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
lexer_string_options_t opts) /**< options */
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
int32_t raw_length_adjust = 0;
|
||||
#else /* ENABLED (JERRY_ES2015) */
|
||||
#else /* ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_UNUSED (opts);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint8_t str_end_character = context_p->source_p[0];
|
||||
const uint8_t *source_p = context_p->source_p + 1;
|
||||
@@ -931,12 +931,12 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
size_t length = 0;
|
||||
uint8_t has_escape = false;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (str_end_character == LIT_CHAR_RIGHT_BRACE)
|
||||
{
|
||||
str_end_character = LIT_CHAR_GRAVE_ACCENT;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -971,9 +971,9 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
if (source_p < source_end_p
|
||||
&& *source_p == LIT_CHAR_LF)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
raw_length_adjust--;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
source_p++;
|
||||
}
|
||||
|
||||
@@ -996,7 +996,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (opts & LEXER_STRING_RAW)
|
||||
{
|
||||
if ((*source_p == LIT_CHAR_GRAVE_ACCENT) || (*source_p == LIT_CHAR_BACKSLASH))
|
||||
@@ -1007,7 +1007,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (*source_p == LIT_CHAR_0
|
||||
&& source_p + 1 < source_end_p
|
||||
@@ -1084,7 +1084,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
context_p->token.line = line;
|
||||
context_p->token.column = (parser_line_counter_t) (column - 1);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (source_p + 4 <= source_end_p
|
||||
&& source_p[0] == LIT_CHAR_LOWERCASE_U
|
||||
&& source_p[1] == LIT_CHAR_LEFT_BRACE)
|
||||
@@ -1094,14 +1094,14 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
if (source_p + escape_length <= source_end_p)
|
||||
{
|
||||
code_point = lexer_hex_to_code_point (source_p + 1, escape_length - 1);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (code_point == UINT32_MAX)
|
||||
{
|
||||
@@ -1115,7 +1115,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT &&
|
||||
source_p[0] == LIT_CHAR_DOLLAR_SIGN &&
|
||||
source_p + 1 < source_end_p &&
|
||||
@@ -1125,7 +1125,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
source_p++;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (*source_p >= LIT_UTF8_4_BYTE_MARKER)
|
||||
{
|
||||
@@ -1135,9 +1135,9 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
length += 2 * 3;
|
||||
has_escape = true;
|
||||
source_p += 4;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
raw_length_adjust += 2;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
column++;
|
||||
continue;
|
||||
}
|
||||
@@ -1147,7 +1147,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
/* Subtract -1 because column is increased below. */
|
||||
column--;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT)
|
||||
{
|
||||
/* Newline (without backslash) is part of the string.
|
||||
@@ -1184,7 +1184,7 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else if (*source_p == LIT_CHAR_CR
|
||||
|| *source_p == LIT_CHAR_LF
|
||||
|| (*source_p == LEXER_NEWLINE_LS_PS_BYTE_1 && LEXER_NEWLINE_LS_PS_BYTE_23 (source_p)))
|
||||
@@ -1206,24 +1206,24 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (opts & LEXER_STRING_RAW)
|
||||
{
|
||||
length = (size_t) ((source_p - string_start_p) + raw_length_adjust);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (length > PARSER_MAXIMUM_STRING_LENGTH)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_STRING_TOO_LONG);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
context_p->token.type = ((str_end_character != LIT_CHAR_GRAVE_ACCENT) ? LEXER_LITERAL
|
||||
: LEXER_TEMPLATE_LITERAL);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
context_p->token.type = LEXER_LITERAL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Fill literal data. */
|
||||
context_p->token.lit_location.char_p = string_start_p;
|
||||
@@ -1297,7 +1297,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
while (source_p < source_end_p
|
||||
&& lit_char_is_hex_digit (source_p[0]));
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (LEXER_TO_ASCII_LOWERCASE (source_p[1]) == LIT_CHAR_LOWERCASE_O)
|
||||
{
|
||||
context_p->token.extra_value = LEXER_NUMBER_OCTAL;
|
||||
@@ -1313,7 +1313,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
|
||||
lexer_parse_octal_number (context_p, &source_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else if (source_p[1] >= LIT_CHAR_0
|
||||
&& source_p[1] <= LIT_CHAR_7)
|
||||
{
|
||||
@@ -1331,7 +1331,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_NUMBER);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (LEXER_TO_ASCII_LOWERCASE (source_p[1]) == LIT_CHAR_LOWERCASE_B)
|
||||
{
|
||||
context_p->token.extra_value = LEXER_NUMBER_BINARY;
|
||||
@@ -1352,7 +1352,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
while (source_p < source_end_p
|
||||
&& lit_char_is_binary_digit (source_p[0]));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
can_be_float = true;
|
||||
@@ -1552,7 +1552,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (length >= 3
|
||||
&& context_p->source_p[1] == LIT_CHAR_DOT
|
||||
&& context_p->source_p[2] == LIT_CHAR_DOT)
|
||||
@@ -1561,7 +1561,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
length = 3;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
context_p->token.type = LEXER_DOT;
|
||||
length = 1;
|
||||
@@ -1665,14 +1665,14 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->source_p[1] == (uint8_t) LIT_CHAR_GREATER_THAN)
|
||||
{
|
||||
context_p->token.type = LEXER_ARROW;
|
||||
length = 2;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
context_p->token.type = LEXER_ASSIGN;
|
||||
@@ -1717,7 +1717,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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)
|
||||
@@ -1731,7 +1731,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
length = 2;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
context_p->token.type = LEXER_MULTIPLY;
|
||||
@@ -1758,9 +1758,9 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
|
||||
case LIT_CHAR_SINGLE_QUOTE:
|
||||
case LIT_CHAR_DOUBLE_QUOTE:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LIT_CHAR_GRAVE_ACCENT:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
{
|
||||
lexer_parse_string (context_p, LEXER_STRING_NO_OPTS);
|
||||
return;
|
||||
@@ -1867,9 +1867,9 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LIT_CHAR_GRAVE_ACCENT:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1880,19 +1880,19 @@ lexer_check_post_primary_exp (parser_context_t *context_p) /**< context */
|
||||
&& context_p->source_p + 1 < context_p->source_end_p
|
||||
&& context_p->source_p[1] == context_p->source_p[0]);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* lexer_check_post_primary_exp */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Checks whether the next token is a type used for detecting arrow functions.
|
||||
@@ -2050,7 +2050,7 @@ lexer_update_await_yield (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
} /* lexer_update_await_yield */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Convert an ident with escapes to a utf8 string.
|
||||
@@ -2074,7 +2074,7 @@ lexer_convert_ident_to_cesu8 (uint8_t *destination_p, /**< destination string */
|
||||
continue;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (*source_p >= LIT_UTF8_4_BYTE_MARKER)
|
||||
{
|
||||
lit_four_byte_utf8_char_to_cesu8 (destination_p, source_p);
|
||||
@@ -2083,7 +2083,7 @@ lexer_convert_ident_to_cesu8 (uint8_t *destination_p, /**< destination string */
|
||||
source_p += 4;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
*destination_p++ = *source_p++;
|
||||
}
|
||||
@@ -2129,17 +2129,17 @@ lexer_convert_literal_to_chars (parser_context_t *context_p, /**< context */
|
||||
|
||||
uint8_t str_end_character = source_p[-1];
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_UNUSED (opts);
|
||||
bool is_raw = false;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -2271,7 +2271,7 @@ lexer_convert_literal_to_chars (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT)
|
||||
{
|
||||
if (source_p[0] == LIT_CHAR_DOLLAR_SIGN
|
||||
@@ -2303,7 +2303,7 @@ lexer_convert_literal_to_chars (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (*source_p >= LIT_UTF8_4_BYTE_MARKER)
|
||||
{
|
||||
@@ -2477,12 +2477,12 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
|
||||
const uint8_t *src_end_p = src_p + length - 1;
|
||||
ecma_number_t multiplier = 8.0;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->token.extra_value == LEXER_NUMBER_BINARY)
|
||||
{
|
||||
multiplier = 2.0;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
num = 0;
|
||||
do
|
||||
@@ -2659,7 +2659,7 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
|
||||
result_index = context_p->literal_count;
|
||||
context_p->literal_count++;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (!(extra_status_flags & PARSER_IS_ARROW_FUNCTION))
|
||||
{
|
||||
compiled_code_p = parser_parse_function (context_p, extra_status_flags);
|
||||
@@ -2668,9 +2668,9 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
compiled_code_p = parser_parse_arrow_function (context_p, extra_status_flags);
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
compiled_code_p = parser_parse_function (context_p, extra_status_flags);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
literal_p->u.bytecode_p = compiled_code_p;
|
||||
literal_p->type = LEXER_FUNCTION_LITERAL;
|
||||
@@ -2927,7 +2927,7 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
|
||||
return;
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
else if (context_p->status_flags & PARSER_MODULE_DEFAULT_CLASS_OR_FUNC)
|
||||
{
|
||||
/* When parsing default exports for modules, it is not required by functions or classes to have identifiers.
|
||||
@@ -2939,9 +2939,9 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
|
||||
context_p->status_flags &= (uint32_t) ~(PARSER_MODULE_DEFAULT_CLASS_OR_FUNC);
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->token.type == LEXER_KEYW_YIELD)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_YIELD_NOT_ALLOWED);
|
||||
@@ -2950,7 +2950,7 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_AWAIT_NOT_ALLOWED);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_EXPECTED);
|
||||
} /* lexer_expect_identifier */
|
||||
|
||||
@@ -2968,11 +2968,11 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_PROPERTY_IDENTIFIER_EXPECTED);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
int is_class_method = ((ident_opts & LEXER_OBJ_IDENT_CLASS_METHOD)
|
||||
&& !(ident_opts & LEXER_OBJ_IDENT_ONLY_IDENTIFIERS)
|
||||
&& (context_p->token.type != LEXER_KEYW_STATIC));
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
context_p->token.line = context_p->line;
|
||||
context_p->token.column = context_p->column;
|
||||
@@ -2986,11 +2986,11 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
context_p->token.flags = (uint8_t) (context_p->token.flags | LEXER_NO_SKIP_SPACES);
|
||||
|
||||
if (context_p->source_p < context_p->source_end_p
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
&& context_p->source_p[0] != LIT_CHAR_COLON)
|
||||
{
|
||||
if (lexer_compare_literal_to_string (context_p, "get", 3))
|
||||
@@ -3005,23 +3005,23 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (lexer_compare_literal_to_string (context_p, "async", 5))
|
||||
{
|
||||
context_p->token.type = LEXER_KEYW_ASYNC;
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (is_class_method && lexer_compare_literal_to_string (context_p, "static", 6))
|
||||
{
|
||||
context_p->token.type = LEXER_KEYW_STATIC;
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
create_literal_object = true;
|
||||
}
|
||||
@@ -3036,7 +3036,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
create_literal_object = true;
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LIT_CHAR_LEFT_SQUARE:
|
||||
{
|
||||
lexer_consume_next_character (context_p);
|
||||
@@ -3061,7 +3061,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
lexer_consume_next_character (context_p);
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case LIT_CHAR_RIGHT_BRACE:
|
||||
{
|
||||
if (ident_opts & LEXER_OBJ_IDENT_ONLY_IDENTIFIERS)
|
||||
@@ -3097,14 +3097,14 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (create_literal_object)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (is_class_method && lexer_compare_literal_to_string (context_p, "constructor", 11))
|
||||
{
|
||||
context_p->token.type = LEXER_CLASS_CONSTRUCTOR;
|
||||
context_p->token.flags &= (uint8_t) ~LEXER_NO_SKIP_SPACES;
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_construct_literal_object (context_p,
|
||||
&context_p->token.lit_location,
|
||||
@@ -3151,12 +3151,12 @@ lexer_check_property_modifier (parser_context_t *context_p) /**< context */
|
||||
context_p->token.flags = (uint8_t) (context_p->token.flags | LEXER_NO_SKIP_SPACES);
|
||||
|
||||
if (context_p->source_p >= context_p->source_end_p
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|| context_p->source_p[0] == LIT_CHAR_COLON)
|
||||
{
|
||||
return;
|
||||
@@ -3174,13 +3174,13 @@ lexer_check_property_modifier (parser_context_t *context_p) /**< context */
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (lexer_compare_literal_to_string (context_p, "async", 5))
|
||||
{
|
||||
context_p->token.type = LEXER_KEYW_ASYNC;
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* lexer_check_property_modifier */
|
||||
|
||||
/**
|
||||
@@ -3386,7 +3386,7 @@ lexer_string_is_directive (parser_context_t *context_p) /**< context */
|
||||
&& context_p->token.type != LEXER_DOT));
|
||||
} /* lexer_string_is_directive */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Compares the current token to an expected identifier.
|
||||
@@ -3443,7 +3443,7 @@ lexer_token_is_async (parser_context_t *context_p) /**< context */
|
||||
&& !context_p->token.lit_location.has_escape);
|
||||
} /* lexer_token_is_async */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Compares the current identifier or string to an expected string.
|
||||
@@ -3480,17 +3480,17 @@ lexer_convert_binary_lvalue_token_to_binary (uint8_t token) /**< binary lvalue t
|
||||
JERRY_ASSERT (LEXER_IS_BINARY_LVALUE_TOKEN (token));
|
||||
JERRY_ASSERT (token != LEXER_ASSIGN);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (token <= LEXER_ASSIGN_EXPONENTIATION)
|
||||
{
|
||||
return (uint8_t) (LEXER_ADD + (token - LEXER_ASSIGN_ADD));
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
if (token <= LEXER_ASSIGN_MODULO)
|
||||
{
|
||||
return (uint8_t) (LEXER_ADD + (token - LEXER_ASSIGN_ADD));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (token <= LEXER_ASSIGN_UNS_RIGHT_SHIFT)
|
||||
{
|
||||
|
||||
@@ -39,10 +39,10 @@ typedef enum
|
||||
LEXER_LIT_TRUE, /**< true (not a keyword!) */
|
||||
LEXER_LIT_FALSE, /**< false (not a keyword!) */
|
||||
LEXER_LIT_NULL, /**< null (not a keyword!) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
LEXER_TEMPLATE_LITERAL, /**< multi segment template literal */
|
||||
LEXER_THREE_DOTS, /**< ... (rest or spread operator) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Unary operators
|
||||
* IMPORTANT: update CBC_UNARY_OP_TOKEN_TO_OPCODE and
|
||||
@@ -58,9 +58,9 @@ typedef enum
|
||||
LEXER_BIT_NOT, /**< "~" */
|
||||
LEXER_KEYW_VOID, /**< void */
|
||||
LEXER_KEYW_TYPEOF, /**< typeof */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
LEXER_KEYW_AWAIT, /**< await */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
LEXER_KEYW_DELETE, /**< delete */
|
||||
LEXER_INCREASE, /**< "++" */
|
||||
LEXER_DECREASE, /**< "--" */
|
||||
@@ -69,13 +69,13 @@ typedef enum
|
||||
* IMPORTANT: update CBC_BINARY_OP_TOKEN_TO_OPCODE,
|
||||
* CBC_BINARY_LVALUE_OP_TOKEN_TO_OPCODE and
|
||||
* parser_binary_precedence_table after changes. */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
#define LEXER_IS_BINARY_OP_TOKEN(token_type) \
|
||||
((token_type) >= LEXER_ASSIGN && (token_type) <= LEXER_EXPONENTIATION)
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
#define LEXER_IS_BINARY_OP_TOKEN(token_type) \
|
||||
((token_type) >= LEXER_ASSIGN && (token_type) <= LEXER_MODULO)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#define LEXER_IS_BINARY_LVALUE_TOKEN(token_type) \
|
||||
((token_type) >= LEXER_ASSIGN && (token_type) <= LEXER_ASSIGN_BIT_XOR)
|
||||
@@ -88,9 +88,9 @@ typedef enum
|
||||
LEXER_ASSIGN_MULTIPLY, /**< "*=" (prec: 3) */
|
||||
LEXER_ASSIGN_DIVIDE, /**< "/=" (prec: 3) */
|
||||
LEXER_ASSIGN_MODULO, /**< "%=" (prec: 3) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
LEXER_ASSIGN_EXPONENTIATION, /**< "**=" (prec: 3) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
LEXER_ASSIGN_LEFT_SHIFT, /**< "<<=" (prec: 3) */
|
||||
LEXER_ASSIGN_RIGHT_SHIFT, /**< ">>=" (prec: 3) */
|
||||
LEXER_ASSIGN_UNS_RIGHT_SHIFT, /**< ">>>=" (prec: 3) */
|
||||
@@ -121,9 +121,9 @@ typedef enum
|
||||
LEXER_MULTIPLY, /**< "*" (prec: 14) */
|
||||
LEXER_DIVIDE, /**< "/" (prec: 14) */
|
||||
LEXER_MODULO, /**< "%" (prec: 14) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
LEXER_EXPONENTIATION, /**< "**" (prec: 15) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
LEXER_LEFT_BRACE, /**< "{" */
|
||||
LEXER_LEFT_PAREN, /**< "(" */
|
||||
@@ -135,9 +135,9 @@ typedef enum
|
||||
LEXER_SEMICOLON, /**< ";" */
|
||||
LEXER_COLON, /**< ":" */
|
||||
LEXER_COMMA, /**< "," */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
LEXER_ARROW, /**< "=>" */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
LEXER_KEYW_BREAK, /**< break */
|
||||
LEXER_KEYW_DO, /**< do */
|
||||
@@ -173,21 +173,21 @@ typedef enum
|
||||
LEXER_PROPERTY_GETTER, /**< property getter function */
|
||||
LEXER_PROPERTY_SETTER, /**< property setter function */
|
||||
LEXER_COMMA_SEP_LIST, /**< comma separated bracketed expression list */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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_CLASS_CONSTRUCTOR, /**< special value for class constructor method */
|
||||
LEXER_INVALID_PATTERN, /**< special value for invalid destructuring pattern */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* Keywords which are not keyword tokens. */
|
||||
#define LEXER_FIRST_NON_RESERVED_KEYWORD LEXER_KEYW_ASYNC
|
||||
LEXER_KEYW_ASYNC, /**< async */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
/* Keywords which are not keyword tokens. */
|
||||
#define LEXER_FIRST_NON_RESERVED_KEYWORD LEXER_KEYW_EVAL
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Keywords which cannot be assigned in strict mode. */
|
||||
#define LEXER_FIRST_NON_STRICT_ARGUMENTS LEXER_KEYW_EVAL
|
||||
|
||||
@@ -61,24 +61,24 @@
|
||||
static const uint8_t parser_binary_precedence_table[] =
|
||||
{
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
3,
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
|
||||
11, 11, 11, 11, 11, 11, 12, 12, 12,
|
||||
13, 13, 14, 14, 14,
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
15,
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
};
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_STATIC_ASSERT (sizeof (parser_binary_precedence_table) == 38,
|
||||
parser_binary_precedence_table_should_have_38_values_in_es2015);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_STATIC_ASSERT (sizeof (parser_binary_precedence_table) == 36,
|
||||
parser_binary_precedence_table_should_have_36_values_in_es51);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Generate byte code for operators with lvalue.
|
||||
@@ -132,7 +132,7 @@ parser_check_invalid_assign (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* parser_check_invalid_assign */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Check and throw an error if the "new.target" is invalid as a left-hand side expression.
|
||||
@@ -155,7 +155,7 @@ parser_check_invalid_new_target (parser_context_t *context_p, /**< parser contex
|
||||
}
|
||||
} /* parser_check_invalid_new_target */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Emit identifier reference
|
||||
@@ -223,7 +223,7 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_emit_ident_reference (context_p, unary_opcode);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (unary_opcode != CBC_DELETE_IDENT_PUSH_RESULT
|
||||
&& scanner_literal_is_const_reg (context_p, context_p->last_cbc.literal_index))
|
||||
{
|
||||
@@ -231,7 +231,7 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
|
||||
context_p->last_cbc_opcode = CBC_PUSH_LITERAL;
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_ASSIGN_CONST_ERROR);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
|
||||
/* Invalid LeftHandSide expression. */
|
||||
if (opcode == CBC_DELETE_PUSH_RESULT)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER_PROP_LITERAL)
|
||||
|| context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER_PROP))
|
||||
{
|
||||
@@ -259,15 +259,15 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
|
||||
parser_emit_cbc (context_p, CBC_POP);
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
parser_emit_cbc (context_p, CBC_POP);
|
||||
parser_emit_cbc (context_p, CBC_PUSH_TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
parser_check_invalid_new_target (context_p, opcode);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ parser_parse_array_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->token.type == LEXER_THREE_DOTS)
|
||||
{
|
||||
opcode = (uint16_t) (PARSER_TO_EXT_OPCODE (CBC_EXT_SPREAD_ARRAY_APPEND));
|
||||
@@ -317,7 +317,7 @@ parser_parse_array_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_SPREAD_ELEMENT);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_parse_expression (context_p, PARSE_EXPR_NO_COMMA);
|
||||
|
||||
@@ -339,15 +339,15 @@ parser_parse_array_literal (parser_context_t *context_p) /**< context */
|
||||
if (pushed_items >= 64)
|
||||
{
|
||||
parser_emit_cbc_call (context_p, opcode, pushed_items);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
opcode = (uint16_t) CBC_ARRAY_APPEND;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
pushed_items = 0;
|
||||
}
|
||||
}
|
||||
} /* parser_parse_array_literal */
|
||||
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Object literal item types.
|
||||
*/
|
||||
@@ -444,9 +444,9 @@ parser_append_object_literal_item (parser_context_t *context_p, /**< context */
|
||||
context_p->stack_top_uint8 = PARSER_OBJECT_PROPERTY_BOTH_ACCESSORS;
|
||||
}
|
||||
} /* parser_append_object_literal_item */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/** Forward definition of parse array initializer. */
|
||||
static void
|
||||
parser_parse_array_initializer (parser_context_t *context_p, parser_pattern_flags_t flags);
|
||||
@@ -769,10 +769,10 @@ parser_parse_class (parser_context_t *context_p, /**< context */
|
||||
lexer_construct_literal_object (context_p, &context_p->token.lit_location, LEXER_STRING_LITERAL);
|
||||
class_name_index = context_p->lit_object.index;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
parser_module_append_export_name (context_p);
|
||||
context_p->status_flags &= (uint32_t) ~(PARSER_MODULE_STORE_IDENT);
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
}
|
||||
@@ -856,9 +856,9 @@ parser_parse_class (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_parse_class */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Parse object initializer method definition.
|
||||
*
|
||||
@@ -914,7 +914,7 @@ parser_reparse_as_common_identifier (parser_context_t *context_p, /**< context *
|
||||
LEXER_IDENT_LITERAL);
|
||||
|
||||
} /* parser_reparse_as_common_identifier */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Parse object literal.
|
||||
@@ -926,13 +926,13 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_emit_cbc (context_p, CBC_CREATE_OBJECT);
|
||||
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
parser_stack_push_uint8 (context_p, PARSER_OBJECT_PROPERTY_START);
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool proto_seen = false;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -949,26 +949,26 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
uint32_t status_flags;
|
||||
cbc_ext_opcode_t opcode;
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
parser_object_literal_item_types_t item_type;
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
bool is_getter = context_p->token.type == LEXER_PROPERTY_GETTER;
|
||||
|
||||
if (is_getter)
|
||||
{
|
||||
status_flags = PARSER_FUNCTION_CLOSURE | PARSER_IS_PROPERTY_GETTER;
|
||||
opcode = CBC_EXT_SET_GETTER;
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
item_type = PARSER_OBJECT_PROPERTY_GETTER;
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
else
|
||||
{
|
||||
status_flags = PARSER_FUNCTION_CLOSURE | PARSER_IS_PROPERTY_SETTER;
|
||||
opcode = CBC_EXT_SET_SETTER;
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
item_type = PARSER_OBJECT_PROPERTY_SETTER;
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
lexer_expect_object_literal_id (context_p, LEXER_OBJ_IDENT_ONLY_IDENTIFIERS);
|
||||
@@ -976,7 +976,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
/* This assignment is a nop for computed getters/setters. */
|
||||
uint16_t literal_index = context_p->lit_object.index;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool is_computed = context_p->token.type == LEXER_RIGHT_SQUARE;
|
||||
|
||||
if (is_computed)
|
||||
@@ -984,18 +984,18 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
opcode = ((opcode == CBC_EXT_SET_GETTER) ? CBC_EXT_SET_COMPUTED_GETTER
|
||||
: CBC_EXT_SET_COMPUTED_SETTER);
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
parser_append_object_literal_item (context_p, literal_index, item_type);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint16_t function_literal_index = lexer_construct_function_object (context_p, status_flags);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (opcode >= CBC_EXT_SET_COMPUTED_GETTER)
|
||||
{
|
||||
literal_index = function_literal_index;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_emit_cbc_literal (context_p,
|
||||
CBC_PUSH_LITERAL,
|
||||
@@ -1003,7 +1003,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
|
||||
JERRY_ASSERT (context_p->last_cbc_opcode == CBC_PUSH_LITERAL);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (is_computed)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, is_getter ? CBC_EXT_SET_COMPUTED_GETTER_NAME
|
||||
@@ -1014,7 +1014,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
|
||||
parser_set_function_name (context_p, function_literal_index, literal_index, status_flags);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
context_p->last_cbc_opcode = PARSER_TO_EXT_OPCODE (opcode);
|
||||
context_p->last_cbc.value = function_literal_index;
|
||||
@@ -1022,7 +1022,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_RIGHT_SQUARE:
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
@@ -1120,10 +1120,10 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
default:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const lexer_lit_location_t *literal_p = (const lexer_lit_location_t *) context_p->lit_object.literal_p;
|
||||
bool is_proto = ((context_p->token.lit_location.type == LEXER_IDENT_LITERAL
|
||||
|| context_p->token.lit_location.type == LEXER_STRING_LITERAL)
|
||||
@@ -1138,22 +1138,22 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
|
||||
proto_seen = true;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint16_t literal_index = context_p->lit_object.index;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
parser_line_counter_t start_line = context_p->token.line;
|
||||
parser_line_counter_t start_column = context_p->token.column;
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
parser_append_object_literal_item (context_p,
|
||||
literal_index,
|
||||
PARSER_OBJECT_PROPERTY_VALUE);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->token.type == LEXER_LEFT_PAREN && !is_proto)
|
||||
{
|
||||
parser_parse_object_method (context_p);
|
||||
@@ -1177,7 +1177,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->token.type != LEXER_COLON)
|
||||
{
|
||||
@@ -1187,34 +1187,34 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
parser_parse_expression (context_p, PARSE_EXPR_NO_COMMA);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (is_proto)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_SET__PROTO__);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->last_cbc.literal_type == LEXER_FUNCTION_LITERAL)
|
||||
{
|
||||
parser_set_function_name (context_p, context_p->last_cbc.literal_index, literal_index, 0);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
context_p->last_cbc_opcode = CBC_SET_LITERAL_PROPERTY;
|
||||
context_p->last_cbc.value = literal_index;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_FINALIZE_ANONYMOUS_CLASS))
|
||||
{
|
||||
uint16_t name_index = scanner_save_literal (context_p, literal_index);
|
||||
parser_emit_cbc_ext_literal (context_p, CBC_EXT_SET_CLASS_NAME, name_index);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
parser_emit_cbc_literal (context_p, CBC_SET_PROPERTY, literal_index);
|
||||
}
|
||||
|
||||
@@ -1232,14 +1232,14 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
while (context_p->stack_top_uint8 != PARSER_OBJECT_PROPERTY_START)
|
||||
{
|
||||
parser_stack_pop (context_p, NULL, 3);
|
||||
}
|
||||
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
} /* parser_parse_object_literal */
|
||||
|
||||
/**
|
||||
@@ -1255,21 +1255,21 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
|
||||
uint16_t function_literal_index;
|
||||
int32_t function_name_index = -1;
|
||||
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (status_flags & PARSER_IS_FUNC_EXPRESSION);
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (status_flags & PARSER_IS_FUNC_EXPRESSION)
|
||||
{
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
parser_line_counter_t debugger_line = context_p->token.line;
|
||||
parser_line_counter_t debugger_column = context_p->token.column;
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint32_t parent_status_flags = context_p->status_flags;
|
||||
|
||||
context_p->status_flags &= (uint32_t) ~(PARSER_IS_ASYNC_FUNCTION
|
||||
@@ -1288,7 +1288,7 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
|
||||
context_p->status_flags |= PARSER_IS_GENERATOR_FUNCTION | PARSER_DISALLOW_AWAIT_YIELD;
|
||||
status_flags |= PARSER_IS_GENERATOR_FUNCTION | PARSER_DISALLOW_AWAIT_YIELD;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (!lexer_check_next_character (context_p, LIT_CHAR_LEFT_PAREN))
|
||||
{
|
||||
@@ -1326,10 +1326,10 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
|
||||
function_name_index = context_p->lit_object.index;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
context_p->status_flags = parent_status_flags;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
|
||||
{
|
||||
@@ -1349,12 +1349,12 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
|
||||
|
||||
JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (function_name_index != -1)
|
||||
{
|
||||
parser_set_function_name (context_p, function_literal_index, (uint16_t) function_name_index, 0);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (literals == 1)
|
||||
{
|
||||
@@ -1386,7 +1386,7 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
|
||||
context_p->last_cbc.literal_keyword_type = LEXER_EOS;
|
||||
} /* parser_parse_function_expression */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Parse template literal.
|
||||
@@ -1590,7 +1590,7 @@ parser_abort_parsing_after_assignment_expression (parser_context_t *context_p)
|
||||
&& context_p->token.type != LEXER_COMMA);
|
||||
} /* parser_abort_parsing_after_assignment_expression */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Parse and record unary operators, and parse the primary literal.
|
||||
@@ -1619,7 +1619,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
context_p->token.type = LEXER_NEGATE;
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_KEYW_AWAIT:
|
||||
{
|
||||
if (JERRY_UNLIKELY (context_p->token.lit_location.has_escape))
|
||||
@@ -1628,7 +1628,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
/* Bracketed expressions are primary expressions. At this
|
||||
@@ -1636,13 +1636,13 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
* they are processed when their closing paren is reached. */
|
||||
if (context_p->token.type == LEXER_LEFT_PAREN)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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_FUNCTION);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
(*grouping_level_p) += PARSER_GROUPING_LEVEL_INCREASE;
|
||||
new_was_seen = false;
|
||||
}
|
||||
@@ -1651,7 +1651,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
/* After 'new' unary operators are not allowed. */
|
||||
new_was_seen = true;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* Check if "new.target" is written here. */
|
||||
if (scanner_try_scan_new_target (context_p))
|
||||
{
|
||||
@@ -1665,7 +1665,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
/* Found "new.target" return here */
|
||||
return false;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
else if (new_was_seen
|
||||
|| (*grouping_level_p == PARSE_EXPR_LEFT_HAND_SIDE)
|
||||
@@ -1681,7 +1681,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
/* Parse primary expression. */
|
||||
switch (context_p->token.type)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_TEMPLATE_LITERAL:
|
||||
{
|
||||
if (context_p->source_p[-1] != LIT_CHAR_GRAVE_ACCENT)
|
||||
@@ -1693,10 +1693,10 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
/* The string is a normal string literal. */
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case LEXER_LITERAL:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (context_p->next_scanner_info_p->source_p == context_p->source_p))
|
||||
{
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
|
||||
@@ -1734,7 +1734,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
parser_parse_function_expression (context_p, arrow_status_flags);
|
||||
return parser_abort_parsing_after_assignment_expression (context_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint8_t type = context_p->token.lit_location.type;
|
||||
|
||||
@@ -1744,14 +1744,14 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
&context_p->token.lit_location,
|
||||
context_p->token.lit_location.type);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
if ((context_p->status_flags & PARSER_MODULE_STORE_IDENT)
|
||||
&& type == LEXER_IDENT_LITERAL)
|
||||
{
|
||||
context_p->module_identifier_lit_p = context_p->lit_object.literal_p;
|
||||
context_p->status_flags &= (uint32_t) ~(PARSER_MODULE_STORE_IDENT);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
}
|
||||
else if (type == LEXER_NUMBER_LITERAL)
|
||||
{
|
||||
@@ -1820,7 +1820,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
case LEXER_LEFT_BRACE:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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_INITIALIZER);
|
||||
@@ -1833,14 +1833,14 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
|
||||
scanner_release_next (context_p, sizeof (scanner_location_info_t));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_parse_object_literal (context_p);
|
||||
break;
|
||||
}
|
||||
case LEXER_LEFT_SQUARE:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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_INITIALIZER);
|
||||
@@ -1853,7 +1853,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
|
||||
scanner_release_next (context_p, sizeof (scanner_location_info_t));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_parse_array_literal (context_p);
|
||||
break;
|
||||
@@ -1886,18 +1886,18 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
case LEXER_KEYW_THIS:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_ALLOW_SUPER_CALL)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_RESOLVE_LEXICAL_THIS);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
parser_emit_cbc (context_p, CBC_PUSH_THIS);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
break;
|
||||
}
|
||||
case LEXER_LIT_TRUE:
|
||||
@@ -1915,7 +1915,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
parser_emit_cbc (context_p, CBC_PUSH_NULL);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_parse_class (context_p, false);
|
||||
@@ -1986,7 +1986,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
return (context_p->token.type != LEXER_RIGHT_PAREN
|
||||
&& context_p->token.type != LEXER_COMMA);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
default:
|
||||
{
|
||||
bool is_left_hand_side = (*grouping_level_p == PARSE_EXPR_LEFT_HAND_SIDE);
|
||||
@@ -2036,13 +2036,13 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
context_p->last_cbc_opcode = PARSER_CBC_UNAVAILABLE;
|
||||
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_PROP_THIS_LITERAL);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER))
|
||||
{
|
||||
context_p->last_cbc_opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER_PROP_LITERAL);
|
||||
context_p->last_cbc.literal_index = context_p->lit_object.index;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_PROP_LITERAL);
|
||||
@@ -2055,14 +2055,14 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
parser_push_result (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint16_t last_cbc_opcode = context_p->last_cbc_opcode;
|
||||
|
||||
if (last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER))
|
||||
{
|
||||
context_p->last_cbc_opcode = PARSER_CBC_UNAVAILABLE;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
parser_parse_expression (context_p, PARSE_EXPR);
|
||||
@@ -2072,13 +2072,13 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER))
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_SUPER_PROP);
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (PARSER_IS_MUTABLE_PUSH_LITERAL (context_p->last_cbc_opcode))
|
||||
{
|
||||
@@ -2091,9 +2091,9 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_TEMPLATE_LITERAL:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case LEXER_LEFT_PAREN:
|
||||
{
|
||||
size_t call_arguments = 0;
|
||||
@@ -2121,7 +2121,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
opcode = CBC_CALL_PROP;
|
||||
context_p->last_cbc_opcode = PARSER_PUSH_PROP_TO_PUSH_PROP_REFERENCE (context_p->last_cbc_opcode);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER_CONSTRUCTOR))
|
||||
{
|
||||
opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_CALL);
|
||||
@@ -2136,7 +2136,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
context_p->last_cbc_opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_PROP_REFERENCE);
|
||||
opcode = CBC_CALL_PROP;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else if (JERRY_UNLIKELY (context_p->status_flags & PARSER_INSIDE_WITH)
|
||||
&& PARSER_IS_PUSH_LITERALS_WITH_THIS (context_p->last_cbc_opcode)
|
||||
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL)
|
||||
@@ -2147,7 +2147,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool has_spread_element = false;
|
||||
|
||||
if (context_p->token.type == LEXER_TEMPLATE_LITERAL)
|
||||
@@ -2189,7 +2189,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
lexer_next_token (context_p);
|
||||
|
||||
if (context_p->token.type != LEXER_RIGHT_PAREN)
|
||||
@@ -2215,7 +2215,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_RIGHT_PAREN_EXPECTED);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
@@ -2223,7 +2223,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint16_t eval_flags = PARSER_SAVE_STATUS_FLAGS (context_p->status_flags);
|
||||
const uint32_t required_flags = PARSER_IS_FUNCTION | PARSER_LEXICAL_BLOCK_NEEDED;
|
||||
|
||||
@@ -2244,14 +2244,14 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
parser_emit_cbc (context_p, CBC_EVAL);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (has_spread_element)
|
||||
{
|
||||
uint16_t spread_opcode;
|
||||
@@ -2278,7 +2278,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
parser_emit_cbc_ext_call (context_p, spread_opcode, call_arguments);
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (call_arguments <= 1)
|
||||
{
|
||||
@@ -2346,9 +2346,9 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint8_t last_unary_token = LEXER_INCREASE;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Generate byte code for the unary operators. */
|
||||
while (true)
|
||||
@@ -2356,20 +2356,20 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
uint8_t token = context_p->stack_top_uint8;
|
||||
if (!LEXER_IS_UNARY_OP_TOKEN (token))
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->token.type == LEXER_EXPONENTIATION
|
||||
&& last_unary_token != LEXER_INCREASE
|
||||
&& last_unary_token != LEXER_DECREASE)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_EXPONENTIATION);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
last_unary_token = token;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_push_result (context_p);
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
@@ -2386,12 +2386,12 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
parser_emit_unary_lvalue_opcode (context_p, (cbc_opcode_t) token);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (JERRY_UNLIKELY (token == LEXER_KEYW_AWAIT))
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_AWAIT);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
token = (uint8_t) (LEXER_UNARY_OP_TOKEN_TO_OPCODE (token));
|
||||
@@ -2482,7 +2482,7 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**<
|
||||
|
||||
assign_opcode = CBC_ASSIGN_SET_IDENT;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (!(pattern_flags & (PARSER_PATTERN_LET | PARSER_PATTERN_CONST | PARSER_PATTERN_LOCAL)))
|
||||
{
|
||||
if (scanner_literal_is_const_reg (context_p, literal_index))
|
||||
@@ -2507,7 +2507,7 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**<
|
||||
assign_opcode = CBC_INIT_ARG_OR_CATCH;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_stack_push_uint16 (context_p, literal_index);
|
||||
JERRY_ASSERT (CBC_SAME_ARGS (CBC_PUSH_LITERAL, assign_opcode));
|
||||
@@ -2550,7 +2550,7 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**<
|
||||
context_p->last_cbc_opcode = CBC_PUSH_THIS_LITERAL;
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER_PROP_LITERAL))
|
||||
{
|
||||
context_p->last_cbc_opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_PROP_LITERAL_ASSIGNMENT_REFERENCE);
|
||||
@@ -2561,13 +2561,13 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**<
|
||||
context_p->last_cbc_opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_PROP_ASSIGNMENT_REFERENCE);
|
||||
assign_opcode = CBC_ASSIGN_SUPER;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
/* Invalid LeftHandSide expression. */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
parser_check_invalid_new_target (context_p, CBC_ASSIGN);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR);
|
||||
}
|
||||
@@ -2603,12 +2603,12 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_emit_ident_reference (context_p, CBC_PUSH_IDENT_REFERENCE);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (scanner_literal_is_const_reg (context_p, context_p->last_cbc.literal_index))
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, LEXER_ASSIGN_CONST);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
else if (PARSER_IS_PUSH_PROP (context_p->last_cbc_opcode))
|
||||
{
|
||||
@@ -2617,9 +2617,9 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */
|
||||
else
|
||||
{
|
||||
/* Invalid LeftHandSide expression. */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
parser_check_invalid_new_target (context_p, CBC_ASSIGN);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR);
|
||||
parser_emit_cbc (context_p, CBC_PUSH_PROP_REFERENCE);
|
||||
@@ -2690,7 +2690,7 @@ parser_process_binary_opcodes (parser_context_t *context_p, /**< context */
|
||||
index = parser_stack_pop_uint16 (context_p);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool group_expr_assingment = false;
|
||||
|
||||
if (JERRY_UNLIKELY (context_p->stack_top_uint8 == LEXER_ASSIGN_GROUP_EXPR))
|
||||
@@ -2704,11 +2704,11 @@ parser_process_binary_opcodes (parser_context_t *context_p, /**< context */
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_ASSIGN_CONST_ERROR);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (index != UINT16_MAX)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (!group_expr_assingment)
|
||||
{
|
||||
uint16_t function_literal_index = parser_check_anonymous_function_declaration (context_p);
|
||||
@@ -2723,7 +2723,7 @@ parser_process_binary_opcodes (parser_context_t *context_p, /**< context */
|
||||
parser_set_function_name (context_p, function_literal_index, (uint16_t) index, 0);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL
|
||||
&& opcode == CBC_ASSIGN_SET_IDENT)
|
||||
@@ -2795,7 +2795,7 @@ parser_process_binary_opcodes (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
} /* parser_process_binary_opcodes */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* End position marker of a pattern.
|
||||
*/
|
||||
@@ -3089,9 +3089,9 @@ parser_pattern_process_assignment (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_FUNCTION_ARGUMENT;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
parser_module_append_export_name (context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_LITERAL);
|
||||
lexer_next_token (context_p);
|
||||
@@ -3249,9 +3249,9 @@ parser_parse_object_initializer (parser_context_t *context_p, /**< context */
|
||||
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_FUNCTION_ARGUMENT;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
parser_module_append_export_name (context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_LITERAL);
|
||||
parser_pattern_form_assignment (context_p, flags, push_prop_opcode, prop_index, start_line);
|
||||
@@ -3307,7 +3307,7 @@ parser_parse_initializer_by_next_char (parser_context_t *context_p, /**< context
|
||||
}
|
||||
} /* parser_parse_initializer_by_next_char */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Process ternary expression.
|
||||
@@ -3404,7 +3404,7 @@ parser_process_group_expression (parser_context_t *context_p, /**< context */
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* Lookahead for anonymous function declaration after '=' token when the assignment base is LHS expression
|
||||
with a single indentifier in it. e.g.: (a) = function () {} */
|
||||
if (JERRY_UNLIKELY (context_p->token.type == LEXER_ASSIGN
|
||||
@@ -3414,7 +3414,7 @@ parser_process_group_expression (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, LEXER_ASSIGN_GROUP_EXPR);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
} /* parser_process_group_expression */
|
||||
|
||||
@@ -3495,7 +3495,7 @@ process_unary_expression:
|
||||
{
|
||||
min_prec_treshold = parser_binary_precedence_table[context_p->token.type - LEXER_FIRST_BINARY_OP];
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* Check for BINARY_LVALUE tokens + LEXER_LOGICAL_OR + LEXER_LOGICAL_AND + LEXER_EXPONENTIATION */
|
||||
if ((min_prec_treshold == PARSER_RIGHT_TO_LEFT_ORDER_EXPONENTIATION)
|
||||
|| (min_prec_treshold <= PARSER_RIGHT_TO_LEFT_ORDER_MAX_PRECEDENCE
|
||||
@@ -3504,7 +3504,7 @@ process_unary_expression:
|
||||
/* Right-to-left evaluation order. */
|
||||
min_prec_treshold++;
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
/* Check for BINARY_LVALUE tokens + LEXER_LOGICAL_OR + LEXER_LOGICAL_AND */
|
||||
if (min_prec_treshold <= PARSER_RIGHT_TO_LEFT_ORDER_MAX_PRECEDENCE
|
||||
&& min_prec_treshold != PARSER_RIGHT_TO_LEFT_ORDER_TERNARY_PRECEDENCE)
|
||||
@@ -3512,7 +3512,7 @@ process_unary_expression:
|
||||
/* Right-to-left evaluation order. */
|
||||
min_prec_treshold++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
parser_process_binary_opcodes (context_p, min_prec_treshold);
|
||||
|
||||
@@ -57,7 +57,7 @@ typedef enum
|
||||
* after the last byte code */
|
||||
PARSER_DEBUGGER_BREAKPOINT_APPENDED = (1u << 11), /**< pending (unsent) breakpoint
|
||||
* info is available */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 */
|
||||
@@ -75,11 +75,11 @@ typedef enum
|
||||
* Note: PARSER_CLASS_CONSTRUCTOR must be present */
|
||||
PARSER_ALLOW_NEW_TARGET = (1u << 23), /**< allow new.target parsing in the current context */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
PARSER_MODULE_DEFAULT_CLASS_OR_FUNC = (1u << 24), /**< parsing a function or class default export */
|
||||
PARSER_MODULE_STORE_IDENT = (1u << 25), /**< store identifier of the current export statement */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
PARSER_HAS_LATE_LIT_INIT = (1u << 30), /**< there are identifier or string literals which construction
|
||||
* is postponed after the local parser data is freed */
|
||||
#ifndef JERRY_NDEBUG
|
||||
@@ -124,10 +124,10 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
PARSER_CHECK_BLOCK_CONTEXT, /**< check block context */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
PARSER_CHECK_GLOBAL_CONTEXT, /**< check global context */
|
||||
PARSER_CHECK_FUNCTION_CONTEXT, /**< check function context */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} parser_check_context_type_t;
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ typedef enum
|
||||
#define PARSER_MAX_BRANCH_LENGTH 3
|
||||
#endif /* PARSER_MAXIMUM_CODE_SIZE <= UINT16_MAX */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Offset of PARSER_ALLOW_SUPER
|
||||
*/
|
||||
@@ -201,7 +201,7 @@ typedef enum
|
||||
#define PARSER_GET_EVAL_FLAG(type) \
|
||||
((type) >> JERRY_LOG2 (ECMA_PARSE_ALLOW_SUPER))
|
||||
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* All flags that affect exotic arguments object creation.
|
||||
@@ -209,7 +209,7 @@ typedef enum
|
||||
#define PARSER_ARGUMENTS_RELATED_FLAGS \
|
||||
(PARSER_ARGUMENTS_NEEDED | PARSER_IS_STRICT)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Checks whether unmapped arguments are needed. */
|
||||
#define PARSER_NEEDS_MAPPED_ARGUMENTS(status_flags) \
|
||||
@@ -397,7 +397,7 @@ typedef struct
|
||||
*/
|
||||
#define PARSER_SCOPE_STACK_FUNC 0xffff
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Mask for decoding the register index of map_to
|
||||
@@ -420,7 +420,7 @@ typedef struct
|
||||
*/
|
||||
#define PARSER_SCOPE_STACK_IS_LOCAL_CREATED (PARSER_SCOPE_STACK_IS_CONST_REG)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Starting literal index for registers.
|
||||
@@ -489,10 +489,10 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
uint16_t context_stack_depth; /**< current context stack depth */
|
||||
@@ -523,10 +523,10 @@ typedef struct
|
||||
parser_saved_context_t *last_context_p; /**< last saved context */
|
||||
parser_stack_iterator_t last_statement; /**< last statement position */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
ecma_module_node_t *module_current_node_p; /**< import / export node that is being processed */
|
||||
lexer_literal_t *module_identifier_lit_p; /**< the literal for the identifier of the current element */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
/* Lexer members. */
|
||||
lexer_token_t token; /**< current token */
|
||||
@@ -561,10 +561,10 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
uint8_t stack_top_uint8; /**< top byte stored on the stack */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
@@ -702,14 +702,14 @@ bool lexer_check_next_characters (parser_context_t *context_p, lit_utf8_byte_t c
|
||||
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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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);
|
||||
bool lexer_check_yield_no_arg (parser_context_t *context_p);
|
||||
bool lexer_consume_generator (parser_context_t *context_p);
|
||||
void lexer_update_await_yield (parser_context_t *context_p, uint32_t status_flags);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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);
|
||||
@@ -732,12 +732,12 @@ bool lexer_compare_identifiers (parser_context_t *context_p, const lexer_lit_loc
|
||||
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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
bool lexer_compare_literal_to_string (parser_context_t *context_p, const char *string_p, size_t string_length);
|
||||
uint8_t lexer_convert_binary_lvalue_token_to_binary (uint8_t token);
|
||||
|
||||
@@ -753,11 +753,11 @@ uint8_t lexer_convert_binary_lvalue_token_to_binary (uint8_t token);
|
||||
void parser_parse_block_expression (parser_context_t *context_p, int options);
|
||||
void parser_parse_expression_statement (parser_context_t *context_p, int options);
|
||||
void parser_parse_expression (parser_context_t *context_p, int options);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -776,20 +776,20 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool scanner_scope_find_let_declaration (parser_context_t *context_p, lexer_lit_location_t *literal_p);
|
||||
bool scanner_try_scan_new_target (parser_context_t *context_p);
|
||||
void scanner_check_variables (parser_context_t *context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
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);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
void scanner_scan_all (parser_context_t *context_p, const uint8_t *arg_list_p, const uint8_t *arg_list_end_p,
|
||||
const uint8_t *source_p, const uint8_t *source_end_p);
|
||||
@@ -804,7 +804,7 @@ void scanner_scan_all (parser_context_t *context_p, const uint8_t *arg_list_p, c
|
||||
void parser_parse_statements (parser_context_t *context_p);
|
||||
void parser_free_jumps (parser_stack_iterator_t iterator);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
@@ -830,7 +830,7 @@ void parser_module_add_names_to_node (parser_context_t *context_p,
|
||||
ecma_string_t *imex_name_p,
|
||||
ecma_string_t *local_name_p);
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -840,14 +840,14 @@ void parser_module_add_names_to_node (parser_context_t *context_p,
|
||||
*/
|
||||
|
||||
ecma_compiled_code_t *parser_parse_function (parser_context_t *context_p, uint32_t status_flags);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_compiled_code_t *parser_parse_arrow_function (parser_context_t *context_p, uint32_t status_flags);
|
||||
void parser_set_function_name (parser_context_t *context_p, uint16_t function_literal_index, uint16_t name_index,
|
||||
uint32_t status_flags);
|
||||
void parser_compiled_code_set_function_name (parser_context_t *context_p, ecma_compiled_code_t *bytecode_p,
|
||||
uint16_t name_index, uint32_t status_flags);
|
||||
uint16_t parser_check_anonymous_function_declaration (parser_context_t *context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Error management. */
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "js-parser-internal.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
@@ -463,13 +463,13 @@ parser_module_parse_import_clause (parser_context_t *context_p) /**< parser cont
|
||||
parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_EXPECTED);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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_ERR_REDECLARED);
|
||||
parser_raise_error (context_p, PARSER_ERR_VARIABLE_REDECLARED);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_string_t *import_name_p = NULL;
|
||||
ecma_string_t *local_name_p = NULL;
|
||||
@@ -490,13 +490,13 @@ parser_module_parse_import_clause (parser_context_t *context_p) /**< parser cont
|
||||
parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_EXPECTED);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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_ERR_REDECLARED);
|
||||
parser_raise_error (context_p, PARSER_ERR_VARIABLE_REDECLARED);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_construct_literal_object (context_p, &context_p->token.lit_location, LEXER_NEW_IDENT_LITERAL);
|
||||
|
||||
@@ -615,4 +615,4 @@ module_found:
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_module_handle_module_specifier */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
@@ -43,12 +43,12 @@ typedef enum
|
||||
{
|
||||
PARSER_STATEMENT_START,
|
||||
PARSER_STATEMENT_BLOCK,
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
PARSER_STATEMENT_BLOCK_SCOPE,
|
||||
PARSER_STATEMENT_PRIVATE_SCOPE,
|
||||
PARSER_STATEMENT_BLOCK_CONTEXT,
|
||||
PARSER_STATEMENT_PRIVATE_CONTEXT,
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
PARSER_STATEMENT_LABEL,
|
||||
PARSER_STATEMENT_IF,
|
||||
PARSER_STATEMENT_ELSE,
|
||||
@@ -58,9 +58,9 @@ typedef enum
|
||||
PARSER_STATEMENT_WHILE,
|
||||
PARSER_STATEMENT_FOR,
|
||||
PARSER_STATEMENT_FOR_IN,
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
PARSER_STATEMENT_FOR_OF,
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
PARSER_STATEMENT_WITH,
|
||||
PARSER_STATEMENT_TRY,
|
||||
} parser_statement_type_t;
|
||||
@@ -88,7 +88,7 @@ static const uint8_t parser_statement_flags[] =
|
||||
PARSER_STATM_HAS_BLOCK,
|
||||
/* PARSER_STATEMENT_BLOCK, */
|
||||
PARSER_STATM_HAS_BLOCK,
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* PARSER_STATEMENT_BLOCK_SCOPE, */
|
||||
PARSER_STATM_HAS_BLOCK,
|
||||
/* PARSER_STATEMENT_PRIVATE_SCOPE, */
|
||||
@@ -97,7 +97,7 @@ static const uint8_t parser_statement_flags[] =
|
||||
PARSER_STATM_HAS_BLOCK | PARSER_STATM_CONTEXT_BREAK,
|
||||
/* PARSER_STATEMENT_PRIVATE_CONTEXT, */
|
||||
PARSER_STATM_CONTEXT_BREAK,
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
/* PARSER_STATEMENT_LABEL */
|
||||
PARSER_STATM_SINGLE_STATM,
|
||||
/* PARSER_STATEMENT_IF */
|
||||
@@ -116,17 +116,17 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* PARSER_STATEMENT_FOR_OF */
|
||||
PARSER_STATM_BREAK_TARGET | PARSER_STATM_CONTINUE_TARGET | PARSER_STATM_SINGLE_STATM | PARSER_STATM_CONTEXT_BREAK,
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Block statement.
|
||||
*/
|
||||
@@ -144,7 +144,7 @@ typedef struct
|
||||
parser_branch_t branch; /**< branch to the end */
|
||||
} parser_block_context_t;
|
||||
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Loop statement.
|
||||
@@ -260,7 +260,7 @@ parser_statement_length (uint8_t type) /**< type of statement */
|
||||
{
|
||||
/* PARSER_STATEMENT_BLOCK */
|
||||
1,
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* PARSER_STATEMENT_BLOCK_SCOPE */
|
||||
(uint8_t) (sizeof (parser_block_statement_t) + 1),
|
||||
/* PARSER_STATEMENT_PRIVATE_SCOPE */
|
||||
@@ -269,7 +269,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
/* PARSER_STATEMENT_LABEL */
|
||||
(uint8_t) (sizeof (parser_label_statement_t) + 1),
|
||||
/* PARSER_STATEMENT_IF */
|
||||
@@ -288,10 +288,10 @@ parser_statement_length (uint8_t type) /**< type of statement */
|
||||
(uint8_t) (sizeof (parser_for_statement_t) + sizeof (parser_loop_statement_t) + 1),
|
||||
/* PARSER_STATEMENT_FOR_IN */
|
||||
(uint8_t) (sizeof (parser_for_in_of_statement_t) + sizeof (parser_loop_statement_t) + 1),
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* PARSER_STATEMENT_FOR_OF */
|
||||
(uint8_t) (sizeof (parser_for_in_of_statement_t) + sizeof (parser_loop_statement_t) + 1),
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
/* PARSER_STATEMENT_WITH */
|
||||
(uint8_t) (sizeof (parser_with_statement_t) + 1 + 1),
|
||||
/* PARSER_STATEMENT_TRY */
|
||||
@@ -365,7 +365,7 @@ parser_parse_enclosed_expr (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_parse_enclosed_expr */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Create a block context.
|
||||
@@ -471,7 +471,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Parse var statement.
|
||||
@@ -483,18 +483,18 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
|| context_p->token.type == LEXER_KEYW_LET
|
||||
|| context_p->token.type == LEXER_KEYW_CONST);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint8_t declaration_type = context_p->token.type;
|
||||
|
||||
if (declaration_type != LEXER_KEYW_VAR)
|
||||
{
|
||||
parser_validate_lexical_context (context_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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;
|
||||
@@ -512,7 +512,7 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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);
|
||||
@@ -521,11 +521,11 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
parser_line_counter_t ident_line_counter = context_p->token.line;
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) || ENABLED (JERRY_LINE_INFO) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
parser_module_append_export_name (context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (declaration_type != LEXER_KEYW_VAR
|
||||
&& context_p->token.keyword_type == LEXER_KEYW_LET)
|
||||
{
|
||||
@@ -537,7 +537,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
@@ -570,7 +570,7 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
|
||||
cbc_opcode_t opcode = CBC_ASSIGN_SET_IDENT;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint16_t function_literal_index = parser_check_anonymous_function_declaration (context_p);
|
||||
|
||||
if (function_literal_index == PARSER_ANONYMOUS_CLASS)
|
||||
@@ -597,11 +597,11 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
opcode = CBC_INIT_CONST;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_emit_cbc_literal (context_p, (uint16_t) opcode, index);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (declaration_type == LEXER_KEYW_LET)
|
||||
{
|
||||
parser_emit_cbc (context_p, CBC_PUSH_UNDEFINED);
|
||||
@@ -622,7 +622,7 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_MISSING_ASSIGN_AFTER_CONST);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->token.type != LEXER_COMMA)
|
||||
{
|
||||
@@ -630,9 +630,9 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
context_p->status_flags &= (uint32_t) ~(PARSER_MODULE_STORE_IDENT);
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
} /* parser_parse_var_statement */
|
||||
|
||||
/**
|
||||
@@ -643,7 +643,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
JERRY_ASSERT (context_p->token.type == LEXER_KEYW_FUNCTION);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (parser_statement_flags[context_p->stack_top_uint8] & PARSER_STATM_SINGLE_STATM))
|
||||
{
|
||||
if (context_p->status_flags & PARSER_IS_STRICT)
|
||||
@@ -689,39 +689,39 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_LEXICAL_SINGLE_STATEMENT);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
parser_line_counter_t debugger_line = context_p->token.line;
|
||||
parser_line_counter_t debugger_column = context_p->token.column;
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool is_generator_function = false;
|
||||
|
||||
if (lexer_consume_generator (context_p))
|
||||
{
|
||||
is_generator_function = true;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_VARIABLE_REDECLARED);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
uint16_t function_name_index = context_p->lit_object.index;
|
||||
parser_module_append_export_name (context_p);
|
||||
context_p->status_flags &= (uint32_t) ~(PARSER_MODULE_STORE_IDENT);
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
uint32_t status_flags = PARSER_FUNCTION_CLOSURE;
|
||||
|
||||
@@ -730,7 +730,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
|
||||
status_flags |= PARSER_HAS_NON_STRICT_ARG;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (is_generator_function)
|
||||
{
|
||||
status_flags |= PARSER_IS_GENERATOR_FUNCTION | PARSER_DISALLOW_AWAIT_YIELD;
|
||||
@@ -740,7 +740,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
status_flags |= PARSER_IS_ASYNC_FUNCTION | PARSER_DISALLOW_AWAIT_YIELD;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
@@ -771,7 +771,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
|
||||
|
||||
JERRY_ASSERT (scope_stack_p[1].map_from == PARSER_SCOPE_STACK_FUNC);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (!(context_p->status_flags & PARSER_IS_STRICT)
|
||||
&& (scope_stack_p >= context_p->scope_stack_p + context_p->scope_stack_global_end))
|
||||
{
|
||||
@@ -822,7 +822,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
|
||||
parser_pop_block_context (context_p);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_literal_t *literal_p = PARSER_GET_LITERAL ((size_t) scope_stack_p[1].map_to);
|
||||
|
||||
@@ -839,9 +839,9 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
parser_compiled_code_set_function_name (context_p, compiled_code_p, function_name_index, 0);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_parse_function_statement */
|
||||
@@ -1208,7 +1208,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
parser_for_in_of_statement_t for_in_of_statement;
|
||||
scanner_location_t start_location, end_location;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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);
|
||||
|
||||
@@ -1260,7 +1260,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
|
||||
scanner_set_location (context_p, &end_location);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN);
|
||||
|
||||
bool is_for_in = true;
|
||||
@@ -1268,7 +1268,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
|
||||
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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* The length of both 'in' and 'of' is two. */
|
||||
const uint8_t *source_end_p = context_p->source_p - 2;
|
||||
@@ -1296,12 +1296,12 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
|
||||
for_in_of_statement.start_offset = context_p->byte_code_size;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (has_context)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_CLONE_CONTEXT);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* The expression parser must not read the 'in' or 'of' tokens. */
|
||||
scanner_get_location (&end_location, context_p);
|
||||
@@ -1311,26 +1311,26 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
context_p->source_end_p = source_end_p;
|
||||
scanner_seek (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (token_type == LEXER_EOS)
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
lexer_next_token (context_p);
|
||||
|
||||
uint8_t token_type = context_p->token.type;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
switch (token_type)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_KEYW_LET:
|
||||
case LEXER_KEYW_CONST:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case LEXER_KEYW_VAR:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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
|
||||
@@ -1357,7 +1357,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
parser_parse_initializer_by_next_char (context_p, flags);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_expect_identifier (context_p, LEXER_IDENT_LITERAL);
|
||||
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
|
||||
@@ -1368,12 +1368,12 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
|
||||
if (context_p->token.type == LEXER_ASSIGN)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_IS_STRICT)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_FOR_IN_OF_DECLARATION);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
parser_branch_t branch;
|
||||
|
||||
/* Initialiser is never executed. */
|
||||
@@ -1385,7 +1385,7 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
#ifndef JERRY_NDEBUG
|
||||
if (literal_index < PARSER_REGISTER_START
|
||||
&& has_context
|
||||
@@ -1397,9 +1397,9 @@ 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 /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
parser_emit_cbc_literal (context_p, CBC_ASSIGN_SET_IDENT, literal_index);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -1427,11 +1427,11 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
|
||||
if (context_p->token.type != LEXER_EOS)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
parser_raise_error (context_p, is_for_in ? PARSER_ERR_IN_EXPECTED : PARSER_ERR_OF_EXPECTED);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
parser_raise_error (context_p, PARSER_ERR_IN_EXPECTED);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
parser_flush_cbc (context_p);
|
||||
@@ -1443,12 +1443,12 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_stack_push (context_p, &for_in_of_statement, sizeof (parser_for_in_of_statement_t));
|
||||
parser_stack_push (context_p, &loop, sizeof (parser_loop_statement_t));
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
parser_stack_push_uint8 (context_p, is_for_in ? PARSER_STATEMENT_FOR_IN
|
||||
: PARSER_STATEMENT_FOR_OF);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_FOR_IN);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
parser_stack_iterator_init (context_p, &context_p->last_statement);
|
||||
return;
|
||||
}
|
||||
@@ -1457,13 +1457,13 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
|
||||
if (context_p->token.type != LEXER_SEMICOLON)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const uint8_t *source_p = context_p->source_p;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
switch (context_p->token.type)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_LITERAL:
|
||||
{
|
||||
if (!lexer_token_is_let (context_p))
|
||||
@@ -1496,7 +1496,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case LEXER_KEYW_VAR:
|
||||
{
|
||||
parser_parse_var_statement (context_p);
|
||||
@@ -1590,7 +1590,7 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool has_block_context = false;
|
||||
uint8_t next_statement_type;
|
||||
|
||||
@@ -1612,7 +1612,7 @@ parser_parse_for_statement_end (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_set_continues_to_current_position (context_p, loop.branch_list_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (has_block_context)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_CLONE_FULL_CONTEXT);
|
||||
@@ -1667,7 +1667,7 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->stack_top_uint8 == PARSER_STATEMENT_PRIVATE_SCOPE
|
||||
|| context_p->stack_top_uint8 == PARSER_STATEMENT_PRIVATE_CONTEXT)
|
||||
{
|
||||
@@ -1704,12 +1704,12 @@ parser_parse_switch_statement_start (parser_context_t *context_p) /**< context *
|
||||
parser_raise_error (context_p, PARSER_ERR_LEFT_BRACE_EXPECTED);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->next_scanner_info_p->source_p == context_p->source_p - 1)
|
||||
{
|
||||
parser_push_block_context (context_p, true);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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);
|
||||
@@ -1876,10 +1876,10 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
@@ -1900,10 +1900,10 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
|
||||
|
||||
if (try_statement.type == parser_catch_block)
|
||||
{
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (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 /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->token.type != LEXER_KEYW_FINALLY)
|
||||
{
|
||||
@@ -1970,7 +1970,7 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
|
||||
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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
|
||||
@@ -1981,28 +1981,28 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
parser_emit_cbc_literal (context_p, CBC_ASSIGN_SET_IDENT, context_p->lit_object.index);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_ASSERT (block_found);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->token.type != LEXER_RIGHT_PAREN)
|
||||
{
|
||||
@@ -2034,7 +2034,7 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
|
||||
CBC_EXT_FINALLY,
|
||||
&try_statement.branch);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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);
|
||||
@@ -2046,7 +2046,7 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
|
||||
|
||||
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
lexer_next_token (context_p);
|
||||
@@ -2320,7 +2320,7 @@ parser_parse_continue_statement (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* parser_parse_continue_statement */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
/**
|
||||
* Parse import statement.
|
||||
* Note: See 15.2.2
|
||||
@@ -2563,7 +2563,7 @@ parser_parse_export_statement (parser_context_t *context_p) /**< context */
|
||||
parser_module_add_export_node_to_context (context_p);
|
||||
context_p->module_current_node_p = NULL;
|
||||
} /* parser_parse_export_statement */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
/**
|
||||
* Parse label statement.
|
||||
@@ -2715,13 +2715,13 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (strict_mode != PARSER_USE_STRICT_NOT_FOUND
|
||||
&& (context_p->status_flags & PARSER_FUNCTION_HAS_NON_SIMPLE_PARAM))
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_USE_STRICT_NOT_ALLOWED);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->token.type == LEXER_SEMICOLON)
|
||||
{
|
||||
@@ -2754,10 +2754,10 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
JERRY_ASSERT (context_p->stack_depth == context_p->context_stack_depth);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (context_p->stack_top_uint8 != PARSER_STATEMENT_PRIVATE_SCOPE
|
||||
&& context_p->stack_top_uint8 != PARSER_STATEMENT_PRIVATE_CONTEXT);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
|
||||
@@ -2815,7 +2815,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
|
||||
case LEXER_LEFT_BRACE:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
|
||||
{
|
||||
parser_push_block_context (context_p, false);
|
||||
@@ -2824,9 +2824,9 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_BLOCK);
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_BLOCK);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_stack_iterator_init (context_p, &context_p->last_statement);
|
||||
lexer_next_token (context_p);
|
||||
@@ -2834,25 +2834,25 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
|
||||
case LEXER_KEYW_VAR:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_KEYW_LET:
|
||||
case LEXER_KEYW_CONST:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
{
|
||||
parser_parse_var_statement (context_p);
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_validate_lexical_context (context_p);
|
||||
parser_parse_class (context_p, true);
|
||||
goto consume_last_statement;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
case LEXER_KEYW_IMPORT:
|
||||
{
|
||||
parser_parse_import_statement (context_p);
|
||||
@@ -2864,7 +2864,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
parser_parse_export_statement (context_p);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
case LEXER_KEYW_FUNCTION:
|
||||
{
|
||||
@@ -2940,7 +2940,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
CBC_EXT_TRY_CREATE_CONTEXT,
|
||||
&try_statement.branch);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
try_statement.scope_stack_top = context_p->scope_stack_top;
|
||||
try_statement.scope_stack_reg_top = context_p->scope_stack_reg_top;
|
||||
|
||||
@@ -2955,7 +2955,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
|
||||
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_stack_push (context_p, &try_statement, sizeof (parser_try_statement_t));
|
||||
parser_stack_push_uint8 (context_p, PARSER_STATEMENT_TRY);
|
||||
@@ -3014,13 +3014,13 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
|| context_p->token.type == LEXER_EOS
|
||||
|| context_p->token.type == LEXER_RIGHT_BRACE)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_RETURN_PROMISE_UNDEFINED);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_emit_cbc (context_p, CBC_RETURN_WITH_BLOCK);
|
||||
break;
|
||||
@@ -3028,13 +3028,13 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_parse_expression (context_p, PARSE_EXPR);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_RETURN_PROMISE);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
|
||||
{
|
||||
@@ -3071,7 +3071,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
continue;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (lexer_token_is_let (context_p)))
|
||||
{
|
||||
if (context_p->next_scanner_info_p->source_p == context_p->source_p)
|
||||
@@ -3126,7 +3126,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
/* FALLTHRU */
|
||||
}
|
||||
@@ -3165,14 +3165,14 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else if (context_p->stack_top_uint8 == PARSER_STATEMENT_SWITCH
|
||||
|| context_p->stack_top_uint8 == PARSER_STATEMENT_SWITCH_NO_DEFAULT)
|
||||
{
|
||||
@@ -3195,13 +3195,13 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
else if (context_p->stack_top_uint8 == PARSER_STATEMENT_TRY)
|
||||
{
|
||||
@@ -3291,18 +3291,18 @@ consume_last_statement:
|
||||
}
|
||||
|
||||
case PARSER_STATEMENT_FOR_IN:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case PARSER_STATEMENT_FOR_OF:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
{
|
||||
parser_for_in_of_statement_t for_in_of_statement;
|
||||
parser_loop_statement_t loop;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool is_for_in = (context_p->stack_top_uint8 == PARSER_STATEMENT_FOR_IN);
|
||||
#else
|
||||
bool is_for_in = true;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
parser_stack_pop (context_p, &loop, sizeof (parser_loop_statement_t));
|
||||
@@ -3328,13 +3328,13 @@ consume_last_statement:
|
||||
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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3418,9 +3418,9 @@ parser_free_jumps (parser_stack_iterator_t iterator) /**< iterator position */
|
||||
case PARSER_STATEMENT_WHILE:
|
||||
case PARSER_STATEMENT_FOR:
|
||||
case PARSER_STATEMENT_FOR_IN:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case PARSER_STATEMENT_FOR_OF:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
{
|
||||
parser_loop_statement_t loop;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Append the cooked and raw string to the corresponding array
|
||||
*/
|
||||
@@ -143,7 +143,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "js-parser-internal.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_object_t *
|
||||
parser_new_tagged_template_literal (ecma_object_t **raw_strings_p);
|
||||
|
||||
@@ -40,7 +40,7 @@ parser_tagged_template_literal_append_strings (parser_context_t *context_p, ecma
|
||||
|
||||
void
|
||||
parser_tagged_template_literal_finalize (ecma_object_t *template_obj_p, ecma_object_t *raw_strings_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#endif /* ECMA_TAGGED_TEMPLATE_LITERAL_H */
|
||||
|
||||
|
||||
@@ -838,12 +838,12 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Invalid hexadecimal digit.";
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case PARSER_ERR_INVALID_BIN_DIGIT:
|
||||
{
|
||||
return "Invalid binary digit.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case PARSER_ERR_INVALID_ESCAPE_SEQUENCE:
|
||||
{
|
||||
return "Invalid escape sequence.";
|
||||
@@ -944,7 +944,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Arguments is not allowed to be used here in strict mode.";
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case PARSER_ERR_USE_STRICT_NOT_ALLOWED:
|
||||
{
|
||||
return "The 'use strict' directive is not allowed for functions with non-simple arguments.";
|
||||
@@ -965,7 +965,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Duplicate __proto__ fields are not allowed in object literals.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case PARSER_ERR_DELETE_IDENT_NOT_ALLOWED:
|
||||
{
|
||||
return "Deleting identifier is not allowed in strict mode.";
|
||||
@@ -1122,7 +1122,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Non-strict argument definition.";
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case PARSER_ERR_VARIABLE_REDECLARED:
|
||||
{
|
||||
return "Local variable is redeclared.";
|
||||
@@ -1211,8 +1211,8 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "new.target expression is not allowed here.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
case PARSER_ERR_FILE_NOT_FOUND:
|
||||
{
|
||||
return "Requested module not found.";
|
||||
@@ -1257,7 +1257,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Duplicated imported binding name.";
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_PARSE_STRICT_MODE == (int) PARSER_IS_STRICT,
|
||||
ecma_parse_strict_mode_must_be_equal_to_parser_is_strict);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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,
|
||||
@@ -34,7 +34,7 @@ JERRY_STATIC_ASSERT (PARSER_RESTORE_STATUS_FLAGS (ECMA_PARSE_ALLOW_SUPER) == PAR
|
||||
|
||||
JERRY_STATIC_ASSERT (PARSER_RESTORE_STATUS_FLAGS (ECMA_PARSE_FUNCTION_CONTEXT) == 0,
|
||||
ecma_parse_function_context_must_not_be_transformed);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@@ -539,12 +539,12 @@ parse_print_literal (ecma_compiled_code_t *compiled_code_p, /**< compiled code *
|
||||
ident_end = args_p->ident_end;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_REST_PARAMETER)
|
||||
{
|
||||
argument_end++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (literal_index < argument_end)
|
||||
{
|
||||
@@ -674,7 +674,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
JERRY_DEBUG_MSG (",no_lexical_env");
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION)
|
||||
{
|
||||
JERRY_DEBUG_MSG (",arrow");
|
||||
@@ -689,7 +689,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
{
|
||||
JERRY_DEBUG_MSG (",generator");
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
JERRY_DEBUG_MSG ("]\n");
|
||||
|
||||
@@ -923,7 +923,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
ecma_value_t *literal_pool_p;
|
||||
uint8_t *dst_p;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if ((context_p->status_flags & (PARSER_IS_FUNCTION | PARSER_LEXICAL_BLOCK_NEEDED))
|
||||
== (PARSER_IS_FUNCTION | PARSER_LEXICAL_BLOCK_NEEDED))
|
||||
{
|
||||
@@ -940,7 +940,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
parser_stack_pop (context_p, &branch, sizeof (parser_branch_t));
|
||||
parser_set_branch_to_current_position (context_p, &branch);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
JERRY_ASSERT (context_p->stack_depth == 0);
|
||||
#ifndef JERRY_NDEBUG
|
||||
@@ -1022,13 +1022,13 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
PARSER_NEXT_BYTE (page_p, offset);
|
||||
length++;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (ext_opcode == CBC_EXT_RETURN_PROMISE
|
||||
|| ext_opcode == CBC_EXT_RETURN_PROMISE_UNDEFINED)
|
||||
{
|
||||
last_opcode = CBC_RETURN;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
if (ext_opcode == CBC_EXT_LINE)
|
||||
@@ -1166,12 +1166,12 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_NO_END_LABEL;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
|
||||
{
|
||||
length++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
length++;
|
||||
}
|
||||
@@ -1196,7 +1196,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
total_size += context_p->argument_count * sizeof (ecma_value_t);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* function.name */
|
||||
if (!(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR))
|
||||
{
|
||||
@@ -1207,7 +1207,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
total_size += sizeof (ecma_value_t);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
if (JERRY_CONTEXT (resource_name) != ECMA_VALUE_UNDEFINED)
|
||||
@@ -1240,13 +1240,13 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
compiled_code_p->refs = 1;
|
||||
compiled_code_p->status_flags = CBC_CODE_FLAGS_FUNCTION;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
JERRY_ASSERT (context_p->argument_count > 0);
|
||||
context_p->argument_count--;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (needs_uint16_arguments)
|
||||
{
|
||||
@@ -1316,7 +1316,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & (PARSER_IS_PROPERTY_GETTER | PARSER_IS_PROPERTY_SETTER))
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_ACCESSOR;
|
||||
@@ -1352,7 +1352,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
literal_pool_p = ((ecma_value_t *) byte_code_p) - context_p->register_count;
|
||||
byte_code_p += literal_length;
|
||||
@@ -1543,14 +1543,14 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
*dst_p++ = CBC_RETURN_WITH_BLOCK;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
|
||||
{
|
||||
dst_p[-1] = CBC_EXT_OPCODE;
|
||||
dst_p[0] = CBC_EXT_RETURN_PROMISE_UNDEFINED;
|
||||
dst_p++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
JERRY_ASSERT (dst_p == byte_code_p + length);
|
||||
|
||||
@@ -1640,12 +1640,12 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (!(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR))
|
||||
{
|
||||
*(--base_p) = ECMA_VALUE_EMPTY;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
if (JERRY_CONTEXT (resource_name) != ECMA_VALUE_UNDEFINED)
|
||||
@@ -1654,12 +1654,12 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->tagged_template_literal_cp != JMEM_CP_NULL)
|
||||
{
|
||||
base_p[-1] = (ecma_value_t) context_p->tagged_template_literal_cp;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
@@ -1701,7 +1701,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (context_p->status_flags & PARSER_IS_FUNCTION);
|
||||
JERRY_ASSERT (!(context_p->status_flags & PARSER_LEXICAL_BLOCK_NEEDED));
|
||||
|
||||
@@ -1713,11 +1713,11 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_IS_ASYNC_FUNCTION;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->token.type == end_type)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_CREATE_GENERATOR);
|
||||
@@ -1725,25 +1725,25 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_DISALLOW_AWAIT_YIELD;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool has_mapped_arguments = (context_p->next_scanner_info_p->u8_arg & SCANNER_FUNCTION_MAPPED_ARGUMENTS) != 0;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_ARGS);
|
||||
scanner_set_active (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
context_p->status_flags |= PARSER_FUNCTION_IS_PARSING_ARGS;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER);
|
||||
@@ -1810,7 +1810,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
lexer_next_token (context_p);
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->token.type != LEXER_LITERAL
|
||||
|| context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
|
||||
@@ -1829,14 +1829,14 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (JERRY_UNLIKELY (context_p->lit_object.literal_p->status_flags & LEXER_FLAG_FUNCTION_ARGUMENT))
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if ((context_p->status_flags & PARSER_FUNCTION_HAS_NON_SIMPLE_PARAM)
|
||||
|| (context_p->status_flags & PARSER_IS_ARROW_FUNCTION))
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_DUPLICATED_ARGUMENT_NAMES);
|
||||
}
|
||||
has_duplicated_arg_names = true;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
context_p->status_flags |= PARSER_HAS_NON_STRICT_ARG;
|
||||
}
|
||||
@@ -1847,7 +1847,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint16_t literal_index = context_p->lit_object.index;
|
||||
|
||||
if (context_p->token.type == LEXER_ASSIGN)
|
||||
@@ -1906,7 +1906,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
(uint16_t) (PARSER_REGISTER_START + context_p->argument_count),
|
||||
literal_index);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
context_p->argument_count++;
|
||||
if (context_p->argument_count >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
@@ -1932,7 +1932,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
scanner_revert_active (context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (!has_mapped_arguments || !(context_p->status_flags & PARSER_FUNCTION_HAS_NON_SIMPLE_PARAM));
|
||||
|
||||
if (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION)
|
||||
@@ -1963,7 +1963,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_BODY);
|
||||
} /* parser_parse_function_arguments */
|
||||
@@ -2004,18 +2004,18 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
if (arg_list_p != NULL)
|
||||
{
|
||||
context.status_flags |= PARSER_IS_FUNCTION;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (parse_opts & ECMA_PARSE_GENERATOR_FUNCTION)
|
||||
{
|
||||
context.status_flags |= PARSER_IS_GENERATOR_FUNCTION;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
context.status_flags |= PARSER_RESTORE_STATUS_FLAGS (parse_opts);
|
||||
context.tagged_template_literal_cp = JMEM_CP_NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
context.stack_depth = 0;
|
||||
context.stack_limit = 0;
|
||||
@@ -2050,10 +2050,10 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
context.scope_stack_size = 0;
|
||||
context.scope_stack_top = 0;
|
||||
context.scope_stack_reg_top = 0;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
context.scope_stack_global_end = 0;
|
||||
context.tagged_template_literal_cp = JMEM_CP_NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
context.context_stack_depth = 0;
|
||||
@@ -2112,14 +2112,14 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
context.breakpoint_info_count = 0;
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
if (context.global_status_flags & ECMA_PARSE_MODULE)
|
||||
{
|
||||
context.status_flags |= PARSER_IS_STRICT;
|
||||
}
|
||||
|
||||
context.module_current_node_p = NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
PARSER_TRY (context.try_buffer)
|
||||
{
|
||||
@@ -2145,18 +2145,18 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
|
||||
lexer_next_token (&context);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
else if (parse_opts & ECMA_PARSE_MODULE)
|
||||
{
|
||||
scanner_create_variables (&context, SCANNER_CREATE_VARS_NO_OPTS);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (context.next_scanner_info_p->source_p == source_p
|
||||
&& context.next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (scanner_is_context_needed (&context, PARSER_CHECK_GLOBAL_CONTEXT))
|
||||
{
|
||||
context.status_flags |= PARSER_LEXICAL_BLOCK_NEEDED;
|
||||
@@ -2166,7 +2166,7 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
{
|
||||
scanner_check_variables (&context);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
scanner_create_variables (&context, SCANNER_CREATE_VARS_IS_SCRIPT);
|
||||
}
|
||||
@@ -2219,7 +2219,7 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
|
||||
scanner_cleanup (&context);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
if (context.module_current_node_p != NULL)
|
||||
{
|
||||
ecma_module_release_module_nodes (context.module_current_node_p);
|
||||
@@ -2276,12 +2276,12 @@ parser_save_context (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_IS_PARSING_ARGS)
|
||||
{
|
||||
context_p->status_flags |= PARSER_LEXICAL_BLOCK_NEEDED;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Save private part of the context. */
|
||||
|
||||
@@ -2302,10 +2302,10 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
saved_context_p->context_stack_depth = context_p->context_stack_depth;
|
||||
@@ -2330,10 +2330,10 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
context_p->scope_stack_global_end = 0;
|
||||
context_p->tagged_template_literal_cp = JMEM_CP_NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
context_p->context_stack_depth = 0;
|
||||
@@ -2375,10 +2375,10 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
context_p->context_stack_depth = saved_context_p->context_stack_depth;
|
||||
@@ -2400,20 +2400,20 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
context_p->status_flags |= PARSER_ALLOW_NEW_TARGET;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_DEBUG_MSG ("\n--- %s parsing start ---\n\n",
|
||||
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor"
|
||||
: "Function");
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_DEBUG_MSG ("\n--- Function parsing start ---\n\n");
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
@@ -2468,13 +2468,13 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_DEBUG_MSG ("\n--- %s parsing end ---\n\n",
|
||||
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor"
|
||||
: "Function");
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_DEBUG_MSG ("\n--- Function parsing end ---\n\n");
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
@@ -2483,7 +2483,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
return compiled_code_p;
|
||||
} /* parser_parse_function */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Parse arrow function code
|
||||
@@ -2712,7 +2712,7 @@ parser_compiled_code_set_function_name (parser_context_t *context_p, /**< contex
|
||||
}
|
||||
} /* parser_compiled_code_set_function_name */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Raise a parse error.
|
||||
@@ -2749,24 +2749,24 @@ parser_raise_error (parser_context_t *context_p, /**< context */
|
||||
parser_free_jumps (saved_context_p->last_statement);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (saved_context_p->tagged_template_literal_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_collection_free (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
saved_context_p->tagged_template_literal_cp));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
saved_context_p = saved_context_p->prev_context_p;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (context_p->tagged_template_literal_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_collection_free (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
context_p->tagged_template_literal_cp));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
context_p->error = error;
|
||||
PARSER_THROW (context_p->try_buffer);
|
||||
@@ -2816,7 +2816,7 @@ parser_parse_script (const uint8_t *arg_list_p, /**< function argument list */
|
||||
|
||||
if (!*bytecode_data_p)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
if (JERRY_CONTEXT (module_top_context_p) != NULL)
|
||||
{
|
||||
ecma_module_cleanup ();
|
||||
@@ -2870,7 +2870,7 @@ parser_parse_script (const uint8_t *arg_list_p, /**< function argument list */
|
||||
#endif /* ENABLED (JERRY_ERROR_MESSAGES) */
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
if (JERRY_CONTEXT (module_top_context_p) != NULL)
|
||||
{
|
||||
ecma_value_t ret_value = ecma_module_parse_modules ();
|
||||
@@ -2884,7 +2884,7 @@ parser_parse_script (const uint8_t *arg_list_p, /**< function argument list */
|
||||
return ret_value;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
if ((JERRY_CONTEXT (debugger_flags) & (JERRY_DEBUGGER_CONNECTED | JERRY_DEBUGGER_PARSER_WAIT))
|
||||
|
||||
@@ -44,9 +44,9 @@ typedef enum
|
||||
PARSER_ERR_INVALID_CHARACTER, /**< unexpected character */
|
||||
PARSER_ERR_INVALID_OCTAL_DIGIT, /**< invalid octal digit */
|
||||
PARSER_ERR_INVALID_HEX_DIGIT, /**< invalid hexadecimal digit */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
PARSER_ERR_INVALID_BIN_DIGIT, /**< invalid binary digit */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
PARSER_ERR_INVALID_ESCAPE_SEQUENCE, /**< invalid escape sequence */
|
||||
PARSER_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE, /**< invalid unicode escape sequence */
|
||||
PARSER_ERR_INVALID_IDENTIFIER_START, /**< character cannot be start of an identifier */
|
||||
@@ -77,13 +77,13 @@ typedef enum
|
||||
PARSER_ERR_STRICT_IDENT_NOT_ALLOWED, /**< identifier name is reserved in strict mode */
|
||||
PARSER_ERR_EVAL_NOT_ALLOWED, /**< eval is not allowed here in strict mode */
|
||||
PARSER_ERR_ARGUMENTS_NOT_ALLOWED, /**< arguments is not allowed here in strict mode */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
PARSER_ERR_USE_STRICT_NOT_ALLOWED, /**< use strict directive is not allowed */
|
||||
PARSER_ERR_YIELD_NOT_ALLOWED, /**< yield expression is not allowed */
|
||||
PARSER_ERR_AWAIT_NOT_ALLOWED, /**< await expression is not allowed */
|
||||
PARSER_ERR_FOR_IN_OF_DECLARATION, /**< variable declaration in for-in or for-of loop */
|
||||
PARSER_ERR_DUPLICATED_PROTO, /**< duplicated __proto__ fields are not allowed */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
PARSER_ERR_DELETE_IDENT_NOT_ALLOWED, /**< identifier delete is not allowed in strict mode */
|
||||
PARSER_ERR_EVAL_CANNOT_ASSIGNED, /**< eval cannot be assigned in strict mode */
|
||||
PARSER_ERR_ARGUMENTS_CANNOT_ASSIGNED, /**< arguments cannot be assigned in strict mode */
|
||||
@@ -125,7 +125,7 @@ typedef enum
|
||||
PARSER_ERR_INVALID_RIGHT_SQUARE, /**< right square must terminate a block */
|
||||
PARSER_ERR_DUPLICATED_LABEL, /**< duplicated label */
|
||||
PARSER_ERR_OBJECT_PROPERTY_REDEFINED, /**< property of object literal redefined */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
PARSER_ERR_VARIABLE_REDECLARED, /**< a variable redeclared */
|
||||
PARSER_ERR_LEXICAL_SINGLE_STATEMENT, /**< lexical declaration in single statement context */
|
||||
PARSER_ERR_LABELLED_FUNC_NOT_IN_BLOCK, /**< labelled functions are only allowed inside blocks */
|
||||
@@ -151,8 +151,8 @@ typedef enum
|
||||
PARSER_ERR_INVALID_EXPONENTIATION, /**< left operand of ** operator cannot be unary expression */
|
||||
PARSER_ERR_NEW_TARGET_EXPECTED, /**< expected new.target expression */
|
||||
PARSER_ERR_NEW_TARGET_NOT_ALLOWED, /**< new.target is not allowed in the given context */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
PARSER_ERR_FILE_NOT_FOUND, /**< file not found*/
|
||||
PARSER_ERR_FROM_EXPECTED, /**< from expected */
|
||||
PARSER_ERR_FROM_COMMA_EXPECTED, /**< from or comma expected */
|
||||
@@ -164,7 +164,7 @@ typedef enum
|
||||
PARSER_ERR_RIGHT_BRACE_COMMA_EXPECTED, /**< right brace or comma expected */
|
||||
PARSER_ERR_DUPLICATED_EXPORT_IDENTIFIER, /**< duplicated export identifier name */
|
||||
PARSER_ERR_DUPLICATED_IMPORT_BINDING, /**< duplicated import binding name */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
PARSER_ERR_NON_STRICT_ARG_DEFINITION /**< non-strict argument definition */
|
||||
} parser_error_t;
|
||||
|
||||
@@ -41,12 +41,12 @@ typedef enum
|
||||
SCAN_MODE_VAR_STATEMENT, /**< scanning var statement */
|
||||
SCAN_MODE_PROPERTY_NAME, /**< scanning property name */
|
||||
SCAN_MODE_FUNCTION_ARGUMENTS, /**< scanning function arguments */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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_METHOD, /**< scanning class method */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} scan_modes_t;
|
||||
|
||||
/**
|
||||
@@ -60,9 +60,9 @@ typedef enum
|
||||
SCAN_STACK_FUNCTION_STATEMENT, /**< function statement */
|
||||
SCAN_STACK_FUNCTION_EXPRESSION, /**< function expression */
|
||||
SCAN_STACK_FUNCTION_PROPERTY, /**< function expression in an object literal or class */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
SCAN_STACK_FUNCTION_ARROW, /**< arrow function expression */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 */
|
||||
@@ -72,19 +72,19 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 */
|
||||
@@ -96,7 +96,7 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* These four must be in this order. */
|
||||
SCAN_STACK_COMPUTED_PROPERTY, /**< computed property name */
|
||||
SCAN_STACK_COMPUTED_GENERATOR, /**< computed generator function */
|
||||
@@ -115,7 +115,7 @@ typedef enum
|
||||
SCAN_STACK_CLASS_EXTENDS, /**< class extends expression */
|
||||
SCAN_STACK_FUNCTION_PARAMETERS, /**< function parameter initializer */
|
||||
SCAN_STACK_USE_ASYNC, /**< an "async" identifier is used */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} scan_stack_modes_t;
|
||||
|
||||
/**
|
||||
@@ -124,9 +124,9 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
SCANNER_CONTEXT_NO_FLAGS = 0, /**< no flags are set */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
SCANNER_CONTEXT_THROW_ERR_ASYNC_FUNCTION = (1 << 0), /**< throw async function error */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
SCANNER_CONTEXT_DEBUGGER_ENABLED = (1 << 1), /**< debugger is enabled */
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
@@ -161,24 +161,24 @@ typedef enum
|
||||
{
|
||||
SCANNER_LITERAL_IS_ARG = (1 << 0), /**< literal is argument */
|
||||
SCANNER_LITERAL_IS_VAR = (1 << 1), /**< literal is var */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/** literal is a destructured argument binding of a possible arrow function */
|
||||
SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG = SCANNER_LITERAL_IS_VAR,
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
SCANNER_LITERAL_IS_CONST = (1 << 5), /**< literal is const */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} scanner_literal_type_flags_t;
|
||||
|
||||
/*
|
||||
@@ -222,7 +222,7 @@ typedef struct
|
||||
scanner_case_info_t **last_case_p; /**< last case info */
|
||||
} scanner_switch_statement_t;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Types of scanner destructuring bindings.
|
||||
@@ -263,7 +263,7 @@ typedef struct scanner_binding_list_t
|
||||
bool is_nested; /**< is nested binding declaration */
|
||||
} scanner_binding_list_t;
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Flags for scanner_literal_pool_t structure.
|
||||
@@ -275,19 +275,19 @@ typedef enum
|
||||
SCANNER_LITERAL_POOL_IS_STRICT = (1 << 2), /**< literal pool represents a strict mode code block */
|
||||
SCANNER_LITERAL_POOL_CAN_EVAL = (1 << 3), /**< prepare for executing eval in this block */
|
||||
SCANNER_LITERAL_POOL_NO_ARGUMENTS = (1 << 4), /**< arguments object must not be constructed */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
SCANNER_LITERAL_POOL_ARGUMENTS_UNMAPPED = (1 << 5), /**< arguments object should be unmapped */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
SCANNER_LITERAL_POOL_IN_WITH = (1 << 6), /**< literal pool is in a with statement */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
SCANNER_LITERAL_POOL_IN_EXPORT = (1 << 7), /**< the declared variables are exported by the module system */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
SCANNER_LITERAL_POOL_FUNCTION_STATEMENT = (1 << 8), /**< function statement */
|
||||
SCANNER_LITERAL_POOL_GENERATOR = (1 << 9), /**< generator function */
|
||||
SCANNER_LITERAL_POOL_ASYNC = (1 << 10), /**< async function */
|
||||
SCANNER_LITERAL_POOL_ASYNC_ARROW = (1 << 11), /**< can be an async arrow function */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} scanner_literal_pool_flags_t;
|
||||
|
||||
/**
|
||||
@@ -327,27 +327,27 @@ struct scanner_context_t
|
||||
{
|
||||
uint32_t context_status_flags; /**< original status flags of the context */
|
||||
uint8_t mode; /**< scanner mode */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint8_t binding_type; /**< current destructuring binding type */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
uint16_t status_flags; /**< scanner status flags */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
scanner_binding_list_t *active_binding_list_p; /**< currently active binding list */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const uint8_t *async_source_p; /**< source position for async functions */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
};
|
||||
|
||||
/* Scanner utils. */
|
||||
|
||||
void scanner_raise_error (parser_context_t *context_p);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
void scanner_raise_redeclaration_error (parser_context_t *context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
void *scanner_malloc (parser_context_t *context_p, size_t size);
|
||||
void scanner_free (void *ptr, size_t size);
|
||||
@@ -359,34 +359,34 @@ scanner_info_t *scanner_insert_info_before (parser_context_t *context_p, const u
|
||||
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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
void scanner_construct_global_block (parser_context_t *context_p, scanner_context_t *scanner_context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
void scanner_filter_arguments (parser_context_t *context_p, scanner_context_t *scanner_context_p);
|
||||
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);
|
||||
lexer_lit_location_t *scanner_add_literal (parser_context_t *context_p, scanner_context_t *scanner_context_p);
|
||||
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);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
void scanner_detect_eval_call (parser_context_t *context_p, scanner_context_t *scanner_context_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
void scanner_push_class_declaration (parser_context_t *context_p, scanner_context_t *scanner_context_p,
|
||||
uint8_t stack_mode);
|
||||
void scanner_push_destructuring_pattern (parser_context_t *context_p, scanner_context_t *scanner_context_p,
|
||||
uint8_t binding_type, 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Scanner operations. */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 scanner_scan_simple_arrow (parser_context_t *context_p, scanner_context_t *scanner_context_p,
|
||||
@@ -394,7 +394,7 @@ void scanner_scan_simple_arrow (parser_context_t *context_p, scanner_context_t *
|
||||
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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
void scanner_scan_bracket (parser_context_t *context_p, scanner_context_t *scanner_context_p);
|
||||
void scanner_check_directives (parser_context_t *context_p, scanner_context_t *scanner_context_p);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Add the "async" literal to the literal pool.
|
||||
@@ -343,7 +343,7 @@ typedef enum
|
||||
SCANNER_SCAN_BRACKET_ARROW_WITH_ONE_ARG, /**< arrow function with one argument */
|
||||
} scanner_scan_bracket_arrow_type_t;
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Scan bracketed expressions.
|
||||
@@ -353,19 +353,19 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
|
||||
scanner_context_t *scanner_context_p) /**< scanner context */
|
||||
{
|
||||
size_t depth = 0;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
JERRY_ASSERT (context_p->token.type == LEXER_LEFT_PAREN);
|
||||
|
||||
do
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
arrow_source_p = context_p->source_p;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
depth++;
|
||||
lexer_next_token (context_p);
|
||||
}
|
||||
@@ -379,13 +379,13 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
if (context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
arrow_source_p = NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const uint8_t *source_p = context_p->source_p;
|
||||
|
||||
if (lexer_check_arrow (context_p))
|
||||
@@ -396,7 +396,7 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
|
||||
size_t total_depth = depth;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while (depth > 0 && lexer_check_next_character (context_p, LIT_CHAR_RIGHT_PAREN))
|
||||
{
|
||||
@@ -407,16 +407,16 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* A function call cannot be an eval function. */
|
||||
arrow_source_p = NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
scanner_context_p->active_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_CAN_EVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (total_depth == depth)
|
||||
{
|
||||
if (lexer_check_arrow_param (context_p))
|
||||
@@ -446,10 +446,10 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
|
||||
arrow_source_p = NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LEXER_THREE_DOTS:
|
||||
case LEXER_LEFT_SQUARE:
|
||||
case LEXER_LEFT_BRACE:
|
||||
@@ -459,23 +459,23 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
|
||||
depth--;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
default:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
arrow_source_p = NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while (depth > 0)
|
||||
{
|
||||
@@ -483,7 +483,7 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
|
||||
depth--;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (arrow_source_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (async_source_p == NULL);
|
||||
@@ -531,7 +531,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* scanner_scan_bracket */
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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,7 +57,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Raise a scanner error.
|
||||
@@ -70,7 +70,7 @@ scanner_raise_error (parser_context_t *context_p) /**< context */
|
||||
JERRY_ASSERT (0);
|
||||
} /* scanner_raise_error */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Raise a variable redeclaration error.
|
||||
@@ -84,7 +84,7 @@ scanner_raise_redeclaration_error (parser_context_t *context_p) /**< context */
|
||||
scanner_raise_error (context_p);
|
||||
} /* scanner_raise_redeclaration_error */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Allocate memory for scanner.
|
||||
@@ -138,24 +138,24 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case SCANNER_STREAM_TYPE_LET:
|
||||
case SCANNER_STREAM_TYPE_CONST:
|
||||
case SCANNER_STREAM_TYPE_LOCAL:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
case SCANNER_STREAM_TYPE_IMPORT:
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
case SCANNER_STREAM_TYPE_ARG:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case SCANNER_STREAM_TYPE_ARG_VAR:
|
||||
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG:
|
||||
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR:
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
case SCANNER_STREAM_TYPE_ARG_FUNC:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case SCANNER_STREAM_TYPE_FUNC:
|
||||
{
|
||||
break;
|
||||
@@ -404,17 +404,17 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const uint16_t copied_flags = (SCANNER_LITERAL_POOL_IN_WITH
|
||||
| SCANNER_LITERAL_POOL_GENERATOR
|
||||
| SCANNER_LITERAL_POOL_ASYNC);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
const uint16_t copied_flags = SCANNER_LITERAL_POOL_IN_WITH;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
status_flags |= (uint16_t) (prev_literal_pool_p->status_flags & copied_flags);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else
|
||||
{
|
||||
context_p->status_flags &= (uint32_t) ~(PARSER_IS_GENERATOR_FUNCTION | PARSER_IS_ASYNC_FUNCTION);
|
||||
@@ -429,7 +429,7 @@ scanner_push_literal_pool (parser_context_t *context_p, /**< context */
|
||||
context_p->status_flags |= PARSER_IS_ASYNC_FUNCTION;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (prev_literal_pool_p != NULL)
|
||||
{
|
||||
@@ -493,12 +493,12 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
== SCANNER_LITERAL_POOL_CAN_EVAL);
|
||||
|
||||
uint8_t can_eval_types = 0;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if ((status_flags & SCANNER_LITERAL_POOL_CAN_EVAL) && prev_literal_pool_p != NULL)
|
||||
{
|
||||
@@ -545,7 +545,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if ((status_flags & SCANNER_LITERAL_POOL_FUNCTION)
|
||||
&& (type & (SCANNER_LITERAL_IS_FUNC | SCANNER_LITERAL_IS_FUNC_DECLARATION)) == SCANNER_LITERAL_IS_FUNC)
|
||||
{
|
||||
@@ -565,7 +565,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
type &= (uint8_t) ~SCANNER_LITERAL_IS_FUNC;
|
||||
literal_p->type = type;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if ((type & SCANNER_LITERAL_IS_LOCAL)
|
||||
|| ((type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_ARG))
|
||||
@@ -592,7 +592,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
no_declarations++;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if ((type & (SCANNER_LITERAL_IS_CONST | SCANNER_LITERAL_IS_ARG)) == SCANNER_LITERAL_IS_CONST)
|
||||
{
|
||||
JERRY_ASSERT (type & SCANNER_LITERAL_IS_LET);
|
||||
@@ -601,14 +601,14 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
literal_p->type = (uint8_t) (type & ~SCANNER_LITERAL_IS_FUNC);
|
||||
no_declarations--;
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
intptr_t diff = (intptr_t) (literal_p->char_p - prev_source_p);
|
||||
@@ -629,9 +629,9 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|| ((type & SCANNER_LITERAL_IS_FUNC) && (status_flags & SCANNER_LITERAL_POOL_IS_STRICT))
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|| !(type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_FUNC)))
|
||||
{
|
||||
continue;
|
||||
@@ -651,7 +651,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
extended_type |= SCANNER_LITERAL_NO_REG;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
extended_type |= SCANNER_LITERAL_IS_USED;
|
||||
|
||||
if (status_flags & SCANNER_LITERAL_POOL_FUNCTION_STATEMENT)
|
||||
@@ -669,7 +669,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
* for speculative arrow parameters and local (non-var) functions. */
|
||||
type = 0;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
type = (uint8_t) (type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_FUNC));
|
||||
JERRY_ASSERT (type == 0 || !(status_flags & SCANNER_LITERAL_POOL_FUNCTION));
|
||||
@@ -716,11 +716,11 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
no_declarations++;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const uint16_t is_unmapped = SCANNER_LITERAL_POOL_IS_STRICT | SCANNER_LITERAL_POOL_ARGUMENTS_UNMAPPED;
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
const uint16_t is_unmapped = SCANNER_LITERAL_POOL_IS_STRICT;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (status_flags & is_unmapped)
|
||||
{
|
||||
@@ -732,7 +732,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (status_flags & SCANNER_LITERAL_POOL_ASYNC)
|
||||
{
|
||||
u8_arg |= SCANNER_FUNCTION_ASYNC;
|
||||
@@ -747,7 +747,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
u8_arg |= SCANNER_FUNCTION_LEXICAL_ENV_NEEDED;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
info_p->u8_arg = u8_arg;
|
||||
info_p->u16_arg = (uint16_t) no_declarations;
|
||||
@@ -792,19 +792,19 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
type = SCANNER_STREAM_TYPE_ARG_FUNC;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (literal_p->type & SCANNER_LITERAL_IS_DESTRUCTURED_ARG)
|
||||
{
|
||||
type = SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
}
|
||||
else if (literal_p->type & SCANNER_LITERAL_IS_ARG)
|
||||
{
|
||||
type = SCANNER_STREAM_TYPE_ARG;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (literal_p->type & SCANNER_LITERAL_IS_DESTRUCTURED_ARG)
|
||||
{
|
||||
type = SCANNER_STREAM_TYPE_DESTRUCTURED_ARG;
|
||||
@@ -817,9 +817,9 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (literal_p->type & SCANNER_LITERAL_IS_LET)
|
||||
{
|
||||
if (!(literal_p->type & SCANNER_LITERAL_IS_CONST))
|
||||
@@ -831,12 +831,12 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
literal_p->type |= SCANNER_LITERAL_EARLY_CREATE;
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
else if (prev_literal_pool_p == NULL)
|
||||
{
|
||||
type = SCANNER_STREAM_TYPE_IMPORT;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
else
|
||||
{
|
||||
type = SCANNER_STREAM_TYPE_LOCAL;
|
||||
@@ -856,7 +856,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
type |= SCANNER_STREAM_NO_REG | SCANNER_STREAM_EARLY_CREATE;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (literal_p->has_escape)
|
||||
{
|
||||
@@ -923,7 +923,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_IS_STRICT;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (prev_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_GENERATOR)
|
||||
{
|
||||
context_p->status_flags |= PARSER_IS_GENERATOR_FUNCTION;
|
||||
@@ -941,7 +941,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_IS_ASYNC_FUNCTION;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
scanner_context_p->active_literal_pool_p = literal_pool_p->prev_p;
|
||||
@@ -976,17 +976,17 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (can_eval || (literal_p->type & SCANNER_LITERAL_EARLY_CREATE))
|
||||
{
|
||||
literal_p->type |= SCANNER_LITERAL_NO_REG | SCANNER_LITERAL_EARLY_CREATE;
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
if (can_eval)
|
||||
{
|
||||
literal_p->type |= SCANNER_LITERAL_NO_REG;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint8_t type = literal_p->type;
|
||||
|
||||
@@ -995,12 +995,12 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (type & (SCANNER_LITERAL_IS_DESTRUCTURED_ARG | SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG))
|
||||
{
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
if (literal_p == NULL)
|
||||
@@ -1022,10 +1022,10 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_list_iterator_init (&literal_pool_p->literal_pool, &literal_iterator);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* Destructured args are placed after the other arguments because of register assignments. */
|
||||
bool has_destructured_arg = false;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
|
||||
{
|
||||
@@ -1033,7 +1033,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
if ((type & SCANNER_LITERAL_IS_ARG) || (has_arguments && scanner_literal_is_arguments (literal_p)))
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (can_eval || (literal_p->type & SCANNER_LITERAL_EARLY_CREATE))
|
||||
{
|
||||
type |= SCANNER_LITERAL_NO_REG | SCANNER_LITERAL_EARLY_CREATE;
|
||||
@@ -1055,12 +1055,12 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
literal_p->type = type;
|
||||
continue;
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
if (can_eval)
|
||||
{
|
||||
literal_p->type |= SCANNER_LITERAL_NO_REG;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
lexer_lit_location_t *new_literal_p;
|
||||
new_literal_p = (lexer_lit_location_t *) parser_list_append (context_p, &new_literal_pool_p->literal_pool);
|
||||
@@ -1074,15 +1074,15 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
literal_p);
|
||||
type |= SCANNER_LITERAL_NO_REG;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
type |= SCANNER_LITERAL_IS_USED;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
literal_location_p->type |= type;
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (has_destructured_arg)
|
||||
{
|
||||
parser_list_iterator_init (&literal_pool_p->literal_pool, &literal_iterator);
|
||||
@@ -1099,7 +1099,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
new_literal_pool_p->prev_p = prev_literal_pool_p;
|
||||
|
||||
@@ -1193,9 +1193,9 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
lit_location_p->type |= SCANNER_LITERAL_IS_USED;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (scanner_context_p->active_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_IN_WITH)
|
||||
{
|
||||
@@ -1260,12 +1260,12 @@ scanner_append_argument (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
literal_p->length = 0;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (literal_p->type & SCANNER_LITERAL_IS_USED)
|
||||
{
|
||||
literal_type = SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_EARLY_CREATE;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
literal_p = (lexer_lit_location_t *) parser_list_append (context_p, &literal_pool_p->literal_pool);
|
||||
@@ -1290,7 +1290,7 @@ scanner_detect_eval_call (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
} /* scanner_detect_eval_call */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Find a let/const declaration of a given literal.
|
||||
@@ -1558,7 +1558,7 @@ scanner_append_hole (parser_context_t *context_p, scanner_context_t *scanner_con
|
||||
literal_p->has_escape = 0;
|
||||
} /* scanner_append_hole */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Reverse the scanner info chain after the scanning is completed.
|
||||
@@ -1625,13 +1625,13 @@ scanner_cleanup (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
case SCANNER_TYPE_WHILE:
|
||||
case SCANNER_TYPE_FOR_IN:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case SCANNER_TYPE_FOR_OF:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case SCANNER_TYPE_CASE:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case SCANNER_TYPE_INITIALIZER:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
{
|
||||
size = sizeof (scanner_location_info_t);
|
||||
break;
|
||||
@@ -1649,15 +1649,15 @@ scanner_cleanup (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
default:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (scanner_info_p->type == SCANNER_TYPE_END_ARGUMENTS
|
||||
|| scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION
|
||||
|| scanner_info_p->type == SCANNER_TYPE_CLASS_CONSTRUCTOR
|
||||
|| scanner_info_p->type == SCANNER_TYPE_ERR_REDECLARED
|
||||
|| scanner_info_p->type == SCANNER_TYPE_ERR_ASYNC_FUNCTION);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_ASSERT (scanner_info_p->type == SCANNER_TYPE_END_ARGUMENTS);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1685,13 +1685,13 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
|
||||
JERRY_UNUSED (check_type);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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
|
||||
: 0);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_ASSERT (check_type == PARSER_CHECK_BLOCK_CONTEXT);
|
||||
JERRY_ASSERT (info_p->type == SCANNER_TYPE_BLOCK);
|
||||
|
||||
@@ -1702,7 +1702,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
uint8_t data = data_p[0];
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint32_t type = data & SCANNER_STREAM_TYPE_MASK;
|
||||
|
||||
if (JERRY_UNLIKELY (type == SCANNER_STREAM_TYPE_HOLE))
|
||||
@@ -1755,9 +1755,9 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_ASSERT ((data & SCANNER_STREAM_TYPE_MASK) == SCANNER_STREAM_TYPE_VAR);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (!(data & SCANNER_STREAM_UINT16_DIFF))
|
||||
{
|
||||
@@ -1775,7 +1775,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
data_p += 2 + 2;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (check_type == PARSER_CHECK_GLOBAL_CONTEXT)
|
||||
&& (type == SCANNER_STREAM_TYPE_VAR
|
||||
|| (type == SCANNER_STREAM_TYPE_FUNC && !(context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL))
|
||||
@@ -1807,7 +1807,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if ((data & SCANNER_STREAM_NO_REG)
|
||||
|| scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
@@ -1821,7 +1821,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
return false;
|
||||
} /* scanner_is_context_needed */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Try to scan/parse the ".target" part in the "new.target" expression.
|
||||
@@ -1859,7 +1859,7 @@ scanner_try_scan_new_target (parser_context_t *context_p) /**< parser/scanner co
|
||||
return false;
|
||||
} /* scanner_try_scan_new_target */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Description of "arguments" literal string.
|
||||
@@ -1889,7 +1889,7 @@ scanner_create_unused_literal (parser_context_t *context_p, /**< context */
|
||||
context_p->literal_count++;
|
||||
} /* scanner_create_unused_literal */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Emit checks for redeclared bindings in the global lexical scope.
|
||||
*/
|
||||
@@ -1947,12 +1947,12 @@ scanner_check_variables (parser_context_t *context_p) /**< context */
|
||||
lexer_construct_literal_object (context_p, &literal, LEXER_NEW_IDENT_LITERAL);
|
||||
literal.char_p += data_p[1];
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
if (type == SCANNER_STREAM_TYPE_IMPORT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_USED;
|
||||
|
||||
@@ -1971,7 +1971,7 @@ scanner_check_variables (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_flush_cbc (context_p);
|
||||
} /* scanner_check_variables */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Create and/or initialize var/let/const/function/etc. variables.
|
||||
@@ -2034,9 +2034,9 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
&& !SCANNER_STREAM_TYPE_IS_ARG (type)
|
||||
&& !SCANNER_STREAM_TYPE_IS_ARG_FUNC (type)));
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
JERRY_ASSERT (type != SCANNER_STREAM_TYPE_IMPORT || (data_p[0] & SCANNER_STREAM_NO_REG));
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
if (type == SCANNER_STREAM_TYPE_HOLE)
|
||||
{
|
||||
@@ -2091,7 +2091,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
if (option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_BODY)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if ((context_p->status_flags & PARSER_LEXICAL_BLOCK_NEEDED)
|
||||
&& (type == SCANNER_STREAM_TYPE_ARG_VAR || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR))
|
||||
{
|
||||
@@ -2107,7 +2107,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
parser_emit_cbc_ext_literal_from_token (context_p, CBC_EXT_COPY_FROM_ARG);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
literal.char_p += data_p[1];
|
||||
continue;
|
||||
@@ -2131,9 +2131,9 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (!(context_p->status_flags & PARSER_FUNCTION_IS_PARSING_ARGS));
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_scope_stack_t *function_map_p = scope_stack_p - 2;
|
||||
uint16_t literal_index = context_p->lit_object.index;
|
||||
@@ -2149,13 +2149,13 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
|
||||
cbc_opcode_t opcode = CBC_SET_VAR_FUNC;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_emit_cbc_literal_value (context_p,
|
||||
(uint16_t) opcode,
|
||||
@@ -2172,19 +2172,19 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
|
||||
scope_stack_p->map_from = context_p->lit_object.index;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (info_type == SCANNER_TYPE_FUNCTION)
|
||||
{
|
||||
if (type != SCANNER_STREAM_TYPE_LET
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
&& type != SCANNER_STREAM_TYPE_IMPORT
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
&& type != SCANNER_STREAM_TYPE_CONST)
|
||||
{
|
||||
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_GLOBAL;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint16_t map_to;
|
||||
uint16_t func_init_opcode = CBC_INIT_ARG_OR_FUNC;
|
||||
@@ -2194,14 +2194,14 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
map_to = (uint16_t) (PARSER_REGISTER_START + scope_stack_reg_top);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
scope_stack_p->map_to = (uint16_t) (scope_stack_reg_top + 1);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
scope_stack_p->map_to = map_to;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
scope_stack_reg_top++;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
switch (type)
|
||||
{
|
||||
case SCANNER_STREAM_TYPE_CONST:
|
||||
@@ -2223,18 +2223,18 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
|
||||
func_init_opcode = CBC_SET_VAR_FUNC;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
else
|
||||
{
|
||||
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_USED;
|
||||
map_to = context_p->lit_object.index;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint16_t scope_stack_map_to = 0;
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
scope_stack_p->map_to = map_to;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (info_type == SCANNER_TYPE_FUNCTION)
|
||||
{
|
||||
@@ -2243,7 +2243,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
|
||||
switch (type)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case SCANNER_STREAM_TYPE_LET:
|
||||
case SCANNER_STREAM_TYPE_CONST:
|
||||
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG:
|
||||
@@ -2260,14 +2260,14 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
/* FALLTHRU */
|
||||
}
|
||||
case SCANNER_STREAM_TYPE_LOCAL:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case SCANNER_STREAM_TYPE_VAR:
|
||||
{
|
||||
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
|
||||
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint16_t opcode;
|
||||
|
||||
switch (type)
|
||||
@@ -2308,44 +2308,44 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
uint16_t opcode = ((option_flags & SCANNER_CREATE_VARS_IS_SCRIPT) ? CBC_CREATE_VAR_EVAL
|
||||
: CBC_CREATE_VAR);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
parser_emit_cbc_literal (context_p, opcode, map_to);
|
||||
break;
|
||||
}
|
||||
case SCANNER_STREAM_TYPE_ARG:
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case SCANNER_STREAM_TYPE_ARG_VAR:
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case SCANNER_STREAM_TYPE_ARG_FUNC:
|
||||
{
|
||||
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
|
||||
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
scope_stack_map_to |= PARSER_SCOPE_STACK_NO_FUNCTION_COPY;
|
||||
|
||||
/* Argument initializers of functions with mapped 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_MAPPED_ARGUMENTS)
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (scope_stack_reg_top < PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
{
|
||||
@@ -2355,9 +2355,9 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
scope_stack_p->map_to = scope_stack_map_to;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
scope_stack_p++;
|
||||
@@ -2381,7 +2381,7 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
literal.char_p -= data_p[1];
|
||||
if (!(context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL)
|
||||
|| !scanner_scope_find_let_declaration (context_p, &literal))
|
||||
@@ -2394,9 +2394,9 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
literal.char_p += data_p[1];
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
func_init_opcode = CBC_CREATE_VAR_FUNC_EVAL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
|
||||
parser_emit_cbc_literal_value (context_p, func_init_opcode, context_p->literal_count, map_to);
|
||||
@@ -2426,23 +2426,23 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
lexer_construct_literal_object (context_p, &lexer_arguments_literal, lexer_arguments_literal.type);
|
||||
|
||||
scope_stack_p->map_from = context_p->lit_object.index;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
scope_stack_p->map_to = 0;
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
scope_stack_p->map_to = context_p->lit_object.index;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
scope_stack_p++;
|
||||
}
|
||||
|
||||
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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (info_type == SCANNER_TYPE_FUNCTION)
|
||||
{
|
||||
context_p->scope_stack_global_end = context_p->scope_stack_top;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (context_p->register_count < scope_stack_reg_top)
|
||||
{
|
||||
@@ -2488,15 +2488,15 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
return stack_item_p->map_to;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* scanner_decode_map_to */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Find the given literal index in the scope stack
|
||||
@@ -2586,7 +2586,7 @@ scanner_literal_is_created (parser_context_t *context_p, /**< context */
|
||||
return (scope_stack_p->map_to & PARSER_SCOPE_STACK_IS_LOCAL_CREATED) != 0;
|
||||
} /* scanner_literal_is_created */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
+201
-201
File diff suppressed because it is too large
Load Diff
@@ -39,18 +39,18 @@ typedef enum
|
||||
SCANNER_TYPE_WHILE, /**< while statement */
|
||||
SCANNER_TYPE_FOR, /**< for statement */
|
||||
SCANNER_TYPE_FOR_IN, /**< for-in statement */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
SCANNER_TYPE_FOR_OF, /**< for-of statement */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
SCANNER_TYPE_SWITCH, /**< switch statement */
|
||||
SCANNER_TYPE_CASE, /**< case statement */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
SCANNER_TYPE_INITIALIZER, /**< destructuring binding or assignment pattern with initializer */
|
||||
SCANNER_TYPE_CLASS_CONSTRUCTOR, /**< class constructor */
|
||||
SCANNER_TYPE_LET_EXPRESSION, /**< let expression */
|
||||
SCANNER_TYPE_ERR_REDECLARED, /**< syntax error: a variable is redeclared */
|
||||
SCANNER_TYPE_ERR_ASYNC_FUNCTION, /**< an invalid async function follows */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} scanner_info_type_t;
|
||||
|
||||
/**
|
||||
@@ -146,30 +146,30 @@ typedef enum
|
||||
SCANNER_STREAM_TYPE_END, /**< end of scanner data */
|
||||
SCANNER_STREAM_TYPE_HOLE, /**< no name is assigned to this argument */
|
||||
SCANNER_STREAM_TYPE_VAR, /**< var declaration */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
SCANNER_STREAM_TYPE_IMPORT, /**< module import */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC, /**< destructuring argument declaration which
|
||||
* is later initialized with a function */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
SCANNER_STREAM_TYPE_FUNC, /**< function declaration */
|
||||
} scanner_compressed_stream_types_t;
|
||||
|
||||
@@ -183,7 +183,7 @@ typedef enum
|
||||
*/
|
||||
#define SCANNER_STREAM_TYPE_IS_FUNCTION(type) ((type) >= SCANNER_STREAM_TYPE_ARG_FUNC)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Checks whether the decoded type represents a function argument.
|
||||
@@ -197,7 +197,7 @@ typedef enum
|
||||
#define SCANNER_STREAM_TYPE_IS_ARG_FUNC(type) \
|
||||
((type) == SCANNER_STREAM_TYPE_ARG_FUNC || (type) == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC)
|
||||
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Checks whether the decoded type represents a function argument.
|
||||
@@ -209,7 +209,7 @@ typedef enum
|
||||
*/
|
||||
#define SCANNER_STREAM_TYPE_IS_ARG_FUNC(type) ((type) == SCANNER_STREAM_TYPE_ARG_FUNC)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Constants for u8_arg flags in scanner_function_info_t.
|
||||
@@ -218,12 +218,12 @@ typedef enum
|
||||
{
|
||||
SCANNER_FUNCTION_ARGUMENTS_NEEDED = (1 << 0), /**< arguments object needs to be created */
|
||||
SCANNER_FUNCTION_MAPPED_ARGUMENTS = (1 << 1), /**< arguments object should be mapped */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} scanner_function_flags_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -275,22 +275,22 @@ void
|
||||
re_append_char (re_compiler_ctx_t *re_ctx_p, /**< RegExp bytecode context */
|
||||
const lit_code_point_t cp) /**< code point */
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const size_t size = (re_ctx_p->flags & RE_FLAG_UNICODE) ? sizeof (lit_code_point_t) : sizeof (ecma_char_t);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_UNUSED (re_ctx_p);
|
||||
const size_t size = sizeof (ecma_char_t);
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint8_t *dest_p = re_bytecode_reserve (re_ctx_p, size);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
re_encode_u32 (dest_p, cp);
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
JERRY_ASSERT (cp <= LIT_UTF16_CODE_UNIT_MAX);
|
||||
re_encode_u16 (dest_p, (ecma_char_t) cp);
|
||||
@@ -304,22 +304,22 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const size_t size = (re_ctx_p->flags & RE_FLAG_UNICODE) ? sizeof (lit_code_point_t) : sizeof (ecma_char_t);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_UNUSED (re_ctx_p);
|
||||
const size_t size = sizeof (ecma_char_t);
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint8_t *dest_p = re_bytecode_insert (re_ctx_p, offset, size);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
re_encode_u32 (dest_p, cp);
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
JERRY_ASSERT (cp <= LIT_UTF16_CODE_UNIT_MAX);
|
||||
re_encode_u16 (dest_p, (ecma_char_t) cp);
|
||||
@@ -336,16 +336,16 @@ re_get_char (const uint8_t **bc_p, /**< reference to bytecode pointer */
|
||||
{
|
||||
lit_code_point_t cp;
|
||||
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
JERRY_UNUSED (unicode);
|
||||
#else /* ENABLED (JERRY_ES2015) */
|
||||
#else /* ENABLED (JERRY_ESNEXT) */
|
||||
if (unicode)
|
||||
{
|
||||
cp = re_decode_u32 (*bc_p);
|
||||
*bc_p += sizeof (lit_code_point_t);
|
||||
}
|
||||
else
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
{
|
||||
cp = re_decode_u16 (*bc_p);
|
||||
*bc_p += sizeof (ecma_char_t);
|
||||
@@ -592,13 +592,13 @@ re_dump_bytecode (re_compiler_ctx_t *re_ctx_p) /**< RegExp bytecode context */
|
||||
JERRY_DEBUG_MSG ("\n");
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case RE_OP_UNICODE_PERIOD:
|
||||
{
|
||||
JERRY_DEBUG_MSG ("UNICODE_PERIOD\n");
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case RE_OP_PERIOD:
|
||||
{
|
||||
JERRY_DEBUG_MSG ("PERIOD\n");
|
||||
|
||||
@@ -86,9 +86,9 @@ typedef enum
|
||||
|
||||
RE_OP_CLASS_ESCAPE, /**< class escape */
|
||||
RE_OP_CHAR_CLASS, /**< character class */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
RE_OP_UNICODE_PERIOD, /**< period in full unicode mode */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
RE_OP_PERIOD, /**< period in non-unicode mode */
|
||||
RE_OP_CHAR, /**< any code point */
|
||||
RE_OP_BYTE, /**< 1-byte utf8 character */
|
||||
|
||||
@@ -394,7 +394,7 @@ re_count_groups (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context */
|
||||
}
|
||||
} /* re_count_groups */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Check if a code point is a Syntax character
|
||||
*
|
||||
@@ -419,7 +419,7 @@ re_is_syntax_char (lit_code_point_t cp) /**< code point */
|
||||
|| cp == LIT_CHAR_RIGHT_BRACE
|
||||
|| cp == LIT_CHAR_VLINE);
|
||||
} /* re_is_syntax_char */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Parse a Character Escape or a Character Class Escape.
|
||||
@@ -445,12 +445,12 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
return ECMA_VALUE_EMPTY;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid escape sequence"));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Legacy octal escape sequence */
|
||||
if (lit_char_is_octal_digit (*re_ctx_p->input_curr_p))
|
||||
@@ -547,12 +547,12 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid control escape sequence"));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
re_ctx_p->token.value = LIT_CHAR_BACKSLASH;
|
||||
re_ctx_p->input_curr_p--;
|
||||
@@ -570,12 +570,12 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid hex escape sequence"));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
re_ctx_p->token.value = LIT_CHAR_LOWERCASE_X;
|
||||
break;
|
||||
@@ -589,7 +589,7 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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
|
||||
@@ -604,12 +604,12 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
re_ctx_p->input_curr_p += 6;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
if (re_ctx_p->input_curr_p + 1 < re_ctx_p->input_end_p
|
||||
@@ -639,7 +639,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid unicode escape sequence"));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
re_ctx_p->token.value = LIT_CHAR_LOWERCASE_U;
|
||||
break;
|
||||
@@ -647,7 +647,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
/* Identity escape */
|
||||
default:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* Must be '/', or one of SyntaxCharacter */
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE
|
||||
&& ch != LIT_CHAR_SLASH
|
||||
@@ -655,7 +655,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid escape"));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
re_ctx_p->token.value = ch;
|
||||
}
|
||||
}
|
||||
@@ -832,12 +832,12 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Nothing to repeat."));
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Lone quantifier bracket."));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
re_ctx_p->input_curr_p++;
|
||||
re_ctx_p->token.type = RE_TOK_CHAR;
|
||||
@@ -846,7 +846,7 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
|
||||
/* Check quantifier */
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case LIT_CHAR_RIGHT_SQUARE:
|
||||
case LIT_CHAR_RIGHT_BRACE:
|
||||
{
|
||||
@@ -857,13 +857,13 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
|
||||
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
default:
|
||||
{
|
||||
re_ctx_p->token.type = RE_TOK_CHAR;
|
||||
re_ctx_p->token.value = ch;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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)
|
||||
@@ -875,7 +875,7 @@ 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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Check quantifier */
|
||||
break;
|
||||
@@ -996,13 +996,13 @@ 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 ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (*re_ctx_p->input_curr_p == LIT_CHAR_MINUS)
|
||||
{
|
||||
re_ctx_p->input_curr_p++;
|
||||
current = LIT_CHAR_MINUS;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (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
|
||||
@@ -1032,12 +1032,12 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
|
||||
}
|
||||
}
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (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 /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
current = lit_cesu8_read_next (&re_ctx_p->input_curr_p);
|
||||
@@ -1059,12 +1059,12 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
|
||||
continue;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid character class"));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (start != RE_INVALID_CP)
|
||||
{
|
||||
@@ -1204,11 +1204,11 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
|
||||
}
|
||||
case RE_TOK_PERIOD:
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
re_append_opcode (re_ctx_p, (re_ctx_p->flags & RE_FLAG_UNICODE) ? RE_OP_UNICODE_PERIOD : RE_OP_PERIOD);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
re_append_opcode (re_ctx_p, RE_OP_PERIOD);
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
re_insert_atom_iterator (re_ctx_p, atom_offset);
|
||||
break;
|
||||
@@ -1255,7 +1255,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
|
||||
return result;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
re_ctx_p->token.qmin = 1;
|
||||
@@ -1263,7 +1263,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
|
||||
re_ctx_p->token.greedy = true;
|
||||
}
|
||||
else
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
{
|
||||
re_parse_quantifier (re_ctx_p);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user