Rework usages/naming of configuration macros [part 1] (#2793)
There are quite a few configuration macros in the project. As discussed in the #2520 issue there are a few awkward constructs. Main changes: * Renamed all CONFIG_DISABLE_<name>_BUILTIN macro to JERRY_BUILTIN_<name> format. * The special JERRY_BUILTINS macro specifies the basic config for all es5.1 builtins. * Renamed all CONFIG_DISABLE_ES2015_<name> to JERRY_ES2015_<name> format. * The special JERRY_ES2015 macro specifies the basic config for all es2015 builtins. * Renamed UNICODE_CASE_CONVERSION to JERRY_UNICODE_CASE_CONVERSION. * Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE. * All options (in this change) can have a value of 0 or 1. * Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE. JERRY_REGEXP_STRICT_MODE is set to 0 by default. * Reworked CONFIG_ECMA_NUMBER_TYPE macro to JERRY_NUMBER_TYPE_FLOAT64 name and now it uses the value 1 for 64 bit floating point numbers and 0 for 32 bit floating point number. By default the 64-bit floating point number mode is enabled. * All new JERRY_ defines can be used wit the `#if ENABLED (JERRY_...)` construct to test if the feature is enabled or not. * Added/replaced a few config.h includes to correctly propagate the macro values. * Added sanity checks for each macro to avoid incorrectly set values. * Updated profile documentation. * The CMake feature names are not updated at this point. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
committed by
Robert Fancsik
parent
722d092528
commit
40f7b1c27f
@@ -64,19 +64,19 @@
|
||||
|
||||
#define CBC_HAS_POP_STACK_BYTE_ARG (CBC_HAS_BYTE_ARG | CBC_POP_STACK_BYTE_ARG)
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
/**
|
||||
* Checks whether the current opcode is a super constructor call
|
||||
*/
|
||||
#define CBC_SUPER_CALL_OPERATION(opcode) \
|
||||
((opcode) >= PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_CALL) \
|
||||
&& (opcode) <= PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_CALL_BLOCK))
|
||||
#else /* CONFIG_DISABLE_ES2015_CLASS */
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
/**
|
||||
* Checks whether the current opcode is a super constructor call
|
||||
*/
|
||||
#define CBC_SUPER_CALL_OPERATION(opcode) false
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
/* Debug macro. */
|
||||
#define CBC_ARGS_EQ(op, types) \
|
||||
|
||||
@@ -277,7 +277,7 @@ lexer_skip_spaces (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* lexer_skip_spaces */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
/**
|
||||
* Skip all the continuous empty statements.
|
||||
*/
|
||||
@@ -293,7 +293,7 @@ lexer_skip_empty_statements (parser_context_t *context_p) /**< context */
|
||||
lexer_skip_spaces (context_p);
|
||||
}
|
||||
} /* lexer_skip_empty_statements */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
/**
|
||||
* Keyword data.
|
||||
@@ -354,9 +354,9 @@ static const keyword_string_t keywords_with_length_4[] =
|
||||
*/
|
||||
static const keyword_string_t keywords_with_length_5[] =
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
LEXER_KEYWORD ("await", LEXER_KEYW_AWAIT),
|
||||
#endif /* !CONFIG_DISABLE_ES2015 */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
LEXER_KEYWORD ("break", LEXER_KEYW_BREAK),
|
||||
LEXER_KEYWORD ("catch", LEXER_KEYW_CATCH),
|
||||
LEXER_KEYWORD ("class", LEXER_KEYW_CLASS),
|
||||
@@ -625,12 +625,12 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
size_t length = 0;
|
||||
uint8_t has_escape = false;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
if (str_end_character == LIT_CHAR_RIGHT_BRACE)
|
||||
{
|
||||
str_end_character = LIT_CHAR_GRAVE_ACCENT;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -773,7 +773,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT &&
|
||||
source_p[0] == LIT_CHAR_DOLLAR_SIGN &&
|
||||
source_p + 1 < source_end_p &&
|
||||
@@ -782,7 +782,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
source_p++;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
|
||||
if (*source_p >= LEXER_UTF8_4BYTE_START)
|
||||
{
|
||||
@@ -801,7 +801,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
/* Subtract -1 because column is increased below. */
|
||||
column--;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT)
|
||||
{
|
||||
/* Newline (without backslash) is part of the string. */
|
||||
@@ -836,7 +836,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
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)))
|
||||
@@ -863,12 +863,12 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_STRING_TOO_LONG);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
context_p->token.type = ((str_end_character != LIT_CHAR_GRAVE_ACCENT) ? LEXER_LITERAL
|
||||
: LEXER_TEMPLATE_LITERAL);
|
||||
#else /* CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#else /* !ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
context_p->token.type = LEXER_LITERAL;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
|
||||
/* Fill literal data. */
|
||||
context_p->token.lit_location.char_p = string_start_p;
|
||||
@@ -1152,7 +1152,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (length >= 3
|
||||
&& context_p->source_p[1] == LIT_CHAR_DOT
|
||||
&& context_p->source_p[2] == LIT_CHAR_DOT)
|
||||
@@ -1161,7 +1161,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
length = 3;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
context_p->token.type = LEXER_DOT;
|
||||
length = 1;
|
||||
@@ -1265,14 +1265,14 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
if (context_p->source_p[1] == (uint8_t) LIT_CHAR_GREATER_THAN)
|
||||
{
|
||||
context_p->token.type = LEXER_ARROW;
|
||||
length = 2;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
}
|
||||
|
||||
context_p->token.type = LEXER_ASSIGN;
|
||||
@@ -1327,9 +1327,9 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
|
||||
case LIT_CHAR_SINGLE_QUOTE:
|
||||
case LIT_CHAR_DOUBLE_QUOTE:
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
case LIT_CHAR_GRAVE_ACCENT:
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
{
|
||||
lexer_parse_string (context_p);
|
||||
return;
|
||||
@@ -1368,7 +1368,7 @@ lexer_check_next_character (parser_context_t *context_p, /**< context */
|
||||
&& context_p->source_p[0] == (uint8_t) character);
|
||||
} /* lexer_check_next_character */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
|
||||
/**
|
||||
* Checks whether the next token is a type used for detecting arrow functions.
|
||||
@@ -1414,7 +1414,7 @@ lexer_check_arrow (parser_context_t *context_p) /**< context */
|
||||
return LEXER_EOS;
|
||||
} /* lexer_check_arrow */
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
/**
|
||||
* Search or append the string to the literal pool.
|
||||
@@ -1555,12 +1555,12 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
uint8_t str_end_character = source_p[-1];
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
if (str_end_character == LIT_CHAR_RIGHT_BRACE)
|
||||
{
|
||||
str_end_character = LIT_CHAR_GRAVE_ACCENT;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -1697,7 +1697,7 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
else if (str_end_character == LIT_CHAR_GRAVE_ACCENT
|
||||
&& source_p[0] == LIT_CHAR_DOLLAR_SIGN
|
||||
&& source_p[1] == LIT_CHAR_LEFT_BRACE)
|
||||
@@ -1706,7 +1706,7 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
|
||||
JERRY_ASSERT (source_p < context_p->source_end_p);
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
|
||||
if (*source_p >= LEXER_UTF8_4BYTE_START)
|
||||
{
|
||||
@@ -1998,7 +1998,7 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
|
||||
result_index = context_p->literal_count;
|
||||
context_p->literal_count++;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
if (!(extra_status_flags & PARSER_IS_ARROW_FUNCTION))
|
||||
{
|
||||
compiled_code_p = parser_parse_function (context_p, extra_status_flags);
|
||||
@@ -2007,9 +2007,9 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
compiled_code_p = parser_parse_arrow_function (context_p, extra_status_flags);
|
||||
}
|
||||
#else /* CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#else /* !ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
compiled_code_p = parser_parse_function (context_p, extra_status_flags);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
literal_p->u.bytecode_p = compiled_code_p;
|
||||
literal_p->type = LEXER_FUNCTION_LITERAL;
|
||||
@@ -2024,7 +2024,7 @@ void
|
||||
lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
|
||||
bool parse_only) /**< parse only */
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
const uint8_t *source_p = context_p->source_p;
|
||||
const uint8_t *regex_start_p = context_p->source_p;
|
||||
const uint8_t *regex_end_p = regex_start_p;
|
||||
@@ -2223,10 +2223,10 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
|
||||
context_p->lit_object.literal_p = literal_p;
|
||||
context_p->lit_object.index = (uint16_t) (context_p->literal_count - 1);
|
||||
context_p->lit_object.type = LEXER_LITERAL_OBJECT_ANY;
|
||||
#else /* CONFIG_DISABLE_REGEXP_BUILTIN */
|
||||
#else /* !ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
JERRY_UNUSED (parse_only);
|
||||
parser_raise_error (context_p, PARSER_ERR_UNSUPPORTED_REGEXP);
|
||||
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
} /* lexer_construct_regexp_object */
|
||||
|
||||
/**
|
||||
@@ -2290,11 +2290,11 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
lexer_skip_spaces (context_p);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
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 /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
context_p->token.line = context_p->line;
|
||||
context_p->token.column = context_p->column;
|
||||
@@ -2328,14 +2328,14 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (is_class_method
|
||||
&& lexer_compare_raw_identifier_to_current (context_p, "static", 6))
|
||||
{
|
||||
context_p->token.type = LEXER_KEYW_STATIC;
|
||||
return;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
create_literal_object = true;
|
||||
}
|
||||
@@ -2345,7 +2345,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
lexer_parse_string (context_p);
|
||||
create_literal_object = true;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
else if (context_p->source_p[0] == LIT_CHAR_LEFT_SQUARE)
|
||||
{
|
||||
context_p->source_p += 1;
|
||||
@@ -2360,7 +2360,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
else if (!(ident_opts & LEXER_OBJ_IDENT_ONLY_IDENTIFIERS) && context_p->source_p[0] == LIT_CHAR_RIGHT_BRACE)
|
||||
{
|
||||
context_p->token.type = LEXER_RIGHT_BRACE;
|
||||
@@ -2389,14 +2389,14 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (create_literal_object)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (is_class_method
|
||||
&& lexer_compare_raw_identifier_to_current (context_p, "constructor", 11))
|
||||
{
|
||||
context_p->token.type = LEXER_CLASS_CONSTRUCTOR;
|
||||
return;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
lexer_construct_literal_object (context_p,
|
||||
&context_p->token.lit_location,
|
||||
@@ -2449,9 +2449,9 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
|
||||
lexer_next_token (context_p);
|
||||
|
||||
if (context_p->token.type == LEXER_LITERAL
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
|| context_p->token.type == LEXER_LEFT_SQUARE
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|| context_p->token.type == LEXER_RIGHT_BRACE)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -39,12 +39,12 @@ typedef enum
|
||||
LEXER_LIT_TRUE, /**< true (not a keyword!) */
|
||||
LEXER_LIT_FALSE, /**< false (not a keyword!) */
|
||||
LEXER_LIT_NULL, /**< null (not a keyword!) */
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
LEXER_TEMPLATE_LITERAL, /**< multi segment template literal */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
LEXER_THREE_DOTS, /**< ... (rest or spread operator) */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
/* Unary operators
|
||||
* IMPORTANT: update CBC_UNARY_OP_TOKEN_TO_OPCODE and
|
||||
@@ -121,9 +121,9 @@ typedef enum
|
||||
LEXER_SEMICOLON, /**< ";" */
|
||||
LEXER_COLON, /**< ":" */
|
||||
LEXER_COMMA, /**< "," */
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
LEXER_ARROW, /**< "=>" */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
LEXER_KEYW_BREAK, /**< break */
|
||||
LEXER_KEYW_DO, /**< do */
|
||||
@@ -154,29 +154,29 @@ typedef enum
|
||||
LEXER_SCAN_SWITCH, /**< special value for switch pre-scan */
|
||||
LEXER_CLASS_CONSTRUCTOR, /**< special value for class constructor method */
|
||||
|
||||
#ifdef CONFIG_DISABLE_ES2015
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
/* Future reserved words: these keywords
|
||||
* must form a group after all other keywords. */
|
||||
#define LEXER_FIRST_FUTURE_RESERVED_WORD LEXER_KEYW_CLASS
|
||||
#endif /* CONFIG_DISABLE_ES2015 */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
LEXER_KEYW_CLASS, /**< class */
|
||||
LEXER_KEYW_EXTENDS, /**< extends */
|
||||
LEXER_KEYW_SUPER, /**< super */
|
||||
LEXER_KEYW_CONST, /**< const */
|
||||
LEXER_KEYW_EXPORT, /**< export */
|
||||
LEXER_KEYW_IMPORT, /**< import */
|
||||
#ifndef CONFIG_DISABLE_ES2015
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* Future reserved words: these keywords
|
||||
* must form a group after all other keywords.
|
||||
* Note:
|
||||
* Tokens from LEXER_KEYW_CLASS to LEXER_KEYW_IMPORT
|
||||
* are no longer future reserved words in ES2015. */
|
||||
#define LEXER_FIRST_FUTURE_RESERVED_WORD LEXER_KEYW_ENUM
|
||||
#endif /* !CONFIG_DISABLE_ES2015 */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
LEXER_KEYW_ENUM, /**< enum */
|
||||
#ifndef CONFIG_DISABLE_ES2015
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
LEXER_KEYW_AWAIT, /**< await */
|
||||
#endif /* !CONFIG_DISABLE_ES2015 */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Future strict reserved words: these keywords
|
||||
* must form a group after future reserved words. */
|
||||
@@ -188,25 +188,25 @@ typedef enum
|
||||
LEXER_KEYW_PACKAGE, /**< package */
|
||||
LEXER_KEYW_PROTECTED, /**< protected */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* Context dependent strict reserved words:
|
||||
* See also: ECMA-262 v6, 11.6.2.1 */
|
||||
#define LEXER_FIRST_CONTEXT_DEPENDENT_RESERVED_WORD LEXER_KEYW_STATIC
|
||||
LEXER_KEYW_STATIC, /**< static */
|
||||
#else /* CONFIG_DISABLE_ES2015 */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
/* Context dependent strict reserved words:
|
||||
* See also: ECMA-262 v6, 11.6.2.1 */
|
||||
#define LEXER_FIRST_CONTEXT_DEPENDENT_RESERVED_WORD
|
||||
#endif /* !CONFIG_DISABLE_ES2015 */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Context dependent future strict reserved words:
|
||||
* See also: ECMA-262 v6, 11.6.2.1 */
|
||||
#define LEXER_FIRST_CONTEXT_DEPENDENT_FUTURE_RESERVED_WORD LEXER_KEYW_LET
|
||||
LEXER_KEYW_LET, /**< let */
|
||||
LEXER_KEYW_YIELD, /**< yield */
|
||||
#ifdef CONFIG_DISABLE_ES2015
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
LEXER_KEYW_STATIC, /**< static */
|
||||
#endif /* CONFIG_DISABLE_ES2015 */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
} lexer_token_type_t;
|
||||
|
||||
#define LEXER_NEWLINE_LS_PS_BYTE_1 0xe2
|
||||
|
||||
@@ -249,7 +249,7 @@ parser_parse_array_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* parser_parse_array_literal */
|
||||
|
||||
#ifdef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
/**
|
||||
* Object literal item types.
|
||||
*/
|
||||
@@ -346,13 +346,13 @@ 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 /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
|
||||
#ifdef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#error "Class support requires ES2015 object literal support"
|
||||
#endif /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
/**
|
||||
* Parse class as an object literal.
|
||||
@@ -634,9 +634,9 @@ parser_parse_class (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_parse_class */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
/**
|
||||
* Parse object initializer method definition.
|
||||
*
|
||||
@@ -658,7 +658,7 @@ parser_parse_object_method (parser_context_t *context_p) /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_parse_object_method */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
/**
|
||||
* Parse object literal.
|
||||
@@ -670,9 +670,9 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
|
||||
parser_emit_cbc (context_p, CBC_CREATE_OBJECT);
|
||||
|
||||
#ifdef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
parser_stack_push_uint8 (context_p, PARSER_OBJECT_PROPERTY_START);
|
||||
#endif /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -690,25 +690,25 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
uint32_t status_flags;
|
||||
cbc_ext_opcode_t opcode;
|
||||
uint16_t literal_index, function_literal_index;
|
||||
#ifdef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
parser_object_literal_item_types_t item_type;
|
||||
#endif /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
if (context_p->token.type == LEXER_PROPERTY_GETTER)
|
||||
{
|
||||
status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE | PARSER_IS_PROPERTY_GETTER;
|
||||
opcode = CBC_EXT_SET_GETTER;
|
||||
#ifdef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
item_type = PARSER_OBJECT_PROPERTY_GETTER;
|
||||
#endif /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
}
|
||||
else
|
||||
{
|
||||
status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE | PARSER_IS_PROPERTY_SETTER;
|
||||
opcode = CBC_EXT_SET_SETTER;
|
||||
#ifdef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
item_type = PARSER_OBJECT_PROPERTY_SETTER;
|
||||
#endif /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
}
|
||||
|
||||
lexer_expect_object_literal_id (context_p, LEXER_OBJ_IDENT_ONLY_IDENTIFIERS);
|
||||
@@ -716,25 +716,25 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
/* This assignment is a nop for computed getters/setters. */
|
||||
literal_index = context_p->lit_object.index;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_RIGHT_SQUARE)
|
||||
{
|
||||
opcode = ((opcode == CBC_EXT_SET_GETTER) ? CBC_EXT_SET_COMPUTED_GETTER
|
||||
: CBC_EXT_SET_COMPUTED_SETTER);
|
||||
}
|
||||
#else /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#else /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
parser_append_object_literal_item (context_p, literal_index, item_type);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
parser_flush_cbc (context_p);
|
||||
function_literal_index = lexer_construct_function_object (context_p, status_flags);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (opcode >= CBC_EXT_SET_COMPUTED_GETTER)
|
||||
{
|
||||
literal_index = function_literal_index;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
parser_emit_cbc_literal (context_p,
|
||||
CBC_PUSH_LITERAL,
|
||||
@@ -747,7 +747,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
break;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
case LEXER_RIGHT_SQUARE:
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
@@ -779,23 +779,23 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
default:
|
||||
{
|
||||
uint16_t literal_index = context_p->lit_object.index;
|
||||
|
||||
#ifdef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
parser_line_counter_t start_line = context_p->token.line;
|
||||
parser_line_counter_t start_column = context_p->token.column;
|
||||
#else /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
parser_append_object_literal_item (context_p,
|
||||
literal_index,
|
||||
PARSER_OBJECT_PROPERTY_VALUE);
|
||||
#else /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
parser_line_counter_t start_line = context_p->token.line;
|
||||
parser_line_counter_t start_column = context_p->token.column;
|
||||
#endif /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_LEFT_PAREN)
|
||||
{
|
||||
parser_parse_object_method (context_p);
|
||||
@@ -834,7 +834,7 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
if (context_p->token.type != LEXER_COLON)
|
||||
{
|
||||
@@ -868,14 +868,14 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
while (context_p->stack_top_uint8 != PARSER_OBJECT_PROPERTY_START)
|
||||
{
|
||||
parser_stack_pop (context_p, NULL, 3);
|
||||
}
|
||||
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
#endif /* CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
} /* parser_parse_object_literal */
|
||||
|
||||
/**
|
||||
@@ -988,7 +988,7 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
|
||||
context_p->last_cbc.literal_object_type = LEXER_LITERAL_OBJECT_ANY;
|
||||
} /* parser_parse_function_expression */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
|
||||
/**
|
||||
* Checks whether the bracketed expression is an argument list of an arrow function.
|
||||
@@ -1059,9 +1059,9 @@ parser_check_arrow_function (parser_context_t *context_p) /**< context */
|
||||
return false;
|
||||
} /* parser_check_arrow_function */
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
|
||||
/**
|
||||
* Parse template literal.
|
||||
@@ -1165,7 +1165,7 @@ parser_parse_template_literal (parser_context_t *context_p) /**< context */
|
||||
return;
|
||||
} /* parser_parse_template_literal */
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
|
||||
/**
|
||||
* Parse and record unary operators, and parse the primary literal.
|
||||
@@ -1214,7 +1214,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
/* Parse primary expression. */
|
||||
switch (context_p->token.type)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
case LEXER_TEMPLATE_LITERAL:
|
||||
{
|
||||
if (context_p->source_p[-1] != LIT_CHAR_GRAVE_ACCENT)
|
||||
@@ -1226,10 +1226,10 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
/* The string is a normal string literal. */
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
case LEXER_LITERAL:
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
if (context_p->token.lit_location.type == LEXER_IDENT_LITERAL)
|
||||
{
|
||||
switch (lexer_check_arrow (context_p))
|
||||
@@ -1258,7 +1258,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
if (context_p->token.lit_location.type == LEXER_IDENT_LITERAL
|
||||
|| context_p->token.lit_location.type == LEXER_STRING_LITERAL)
|
||||
@@ -1366,7 +1366,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
case LEXER_KEYW_THIS:
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags))
|
||||
{
|
||||
if (context_p->status_flags & PARSER_CLASS_IMPLICIT_SUPER)
|
||||
@@ -1380,11 +1380,11 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
parser_emit_cbc (context_p, CBC_PUSH_THIS);
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
break;
|
||||
}
|
||||
case LEXER_LIT_TRUE:
|
||||
@@ -1402,7 +1402,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
parser_emit_cbc (context_p, CBC_PUSH_NULL);
|
||||
break;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_parse_class (context_p, false);
|
||||
@@ -1446,8 +1446,8 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_raise_error (context_p, PARSER_ERR_UNEXPECTED_SUPER_REFERENCE);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
case LEXER_RIGHT_PAREN:
|
||||
{
|
||||
if (context_p->stack_top_uint8 == LEXER_LEFT_PAREN
|
||||
@@ -1462,7 +1462,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
default:
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_PRIMARY_EXP_EXPECTED);
|
||||
@@ -1589,12 +1589,12 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
||||
context_p->last_cbc_opcode = CBC_PUSH_PROP_THIS_LITERAL_REFERENCE;
|
||||
opcode = CBC_CALL_PROP;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
else if (context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_CONSTRUCTOR_SUPER))
|
||||
{
|
||||
opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_SUPER_CALL);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
else if ((context_p->status_flags & (PARSER_INSIDE_WITH | PARSER_RESOLVE_BASE_FOR_CALLS))
|
||||
&& PARSER_IS_PUSH_LITERAL (context_p->last_cbc_opcode)
|
||||
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL)
|
||||
@@ -1656,7 +1656,7 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
||||
|
||||
if (is_eval)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (context_p->status_flags & PARSER_CLASS_HAS_SUPER)
|
||||
{
|
||||
parser_flush_cbc (context_p);
|
||||
@@ -1665,20 +1665,20 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
parser_emit_cbc (context_p, CBC_EVAL);
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if ((context_p->status_flags & PARSER_CLASS_SUPER_PROP_REFERENCE) && opcode == CBC_CALL_PROP)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_SUPER_PROP_CALL);
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_CLASS_SUPER_PROP_REFERENCE;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
if (call_arguments == 0)
|
||||
{
|
||||
@@ -1912,14 +1912,14 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */
|
||||
parser_stack_push_uint16 (context_p, context_p->last_cbc.literal_index);
|
||||
parser_stack_push_uint8 (context_p, CBC_ASSIGN_PROP_LITERAL);
|
||||
context_p->last_cbc_opcode = PARSER_CBC_UNAVAILABLE;
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (context_p->status_flags & PARSER_CLASS_SUPER_PROP_REFERENCE)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_SUPER_PROP_ASSIGN);
|
||||
parser_flush_cbc (context_p);
|
||||
}
|
||||
context_p->status_flags &= (uint32_t) ~PARSER_CLASS_SUPER_PROP_REFERENCE;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -45,9 +45,9 @@ typedef enum
|
||||
PARSER_IS_FUNC_EXPRESSION = (1u << 3), /**< a function expression is parsed */
|
||||
PARSER_IS_PROPERTY_GETTER = (1u << 4), /**< a property getter function is parsed */
|
||||
PARSER_IS_PROPERTY_SETTER = (1u << 5), /**< a property setter function is parsed */
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
PARSER_FUNCTION_HAS_REST_PARAM = (1u << 6), /**< function has rest parameter */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
PARSER_HAS_NON_STRICT_ARG = (1u << 7), /**< the function has arguments which
|
||||
* are not supported in strict mode */
|
||||
PARSER_ARGUMENTS_NEEDED = (1u << 8), /**< arguments object must be created */
|
||||
@@ -65,11 +65,11 @@ typedef enum
|
||||
* after the last byte code */
|
||||
PARSER_DEBUGGER_BREAKPOINT_APPENDED = (1u << 17), /**< pending (unsent) breakpoint
|
||||
* info is available */
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
PARSER_IS_ARROW_FUNCTION = (1u << 18), /**< an arrow function is parsed */
|
||||
PARSER_ARROW_PARSE_ARGS = (1u << 19), /**< parse the argument list of an arrow function */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
/* These four status flags must be in this order. See PARSER_CLASS_PARSE_OPTS_OFFSET. */
|
||||
PARSER_CLASS_CONSTRUCTOR = (1u << 20), /**< a class constructor is parsed (this value must be kept in
|
||||
* in sync with ECMA_PARSE_CLASS_CONSTRUCTOR) */
|
||||
@@ -77,7 +77,7 @@ typedef enum
|
||||
PARSER_CLASS_IMPLICIT_SUPER = (1u << 22), /**< class has implicit parent class */
|
||||
PARSER_CLASS_STATIC_FUNCTION = (1u << 23), /**< this function is a static class method */
|
||||
PARSER_CLASS_SUPER_PROP_REFERENCE = (1u << 24), /**< super property call or assignment */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
} parser_general_flags_t;
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ typedef enum
|
||||
*/
|
||||
#define PARSER_STRICT_MODE_MASK 0x1
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
/**
|
||||
* Offset between PARSER_CLASS_CONSTRUCTOR and ECMA_PARSE_CLASS_CONSTRUCTOR
|
||||
*/
|
||||
@@ -139,7 +139,7 @@ typedef enum
|
||||
*/
|
||||
#define PARSER_IS_CLASS_CONSTRUCTOR_SUPER(flag) \
|
||||
(((flag) & PARSER_CLASS_CONSTRUCTOR_SUPER) == PARSER_CLASS_CONSTRUCTOR_SUPER)
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
/* The maximum of PARSER_CBC_STREAM_PAGE_SIZE is 127. */
|
||||
#define PARSER_CBC_STREAM_PAGE_SIZE \
|
||||
@@ -296,7 +296,7 @@ typedef struct
|
||||
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
/**
|
||||
* String struct for storing the module path.
|
||||
*/
|
||||
@@ -347,7 +347,7 @@ typedef struct
|
||||
parser_module_node_t *imports_p; /**< import item of the current context */
|
||||
parser_module_node_t *exports_p; /**< export item of the current context */
|
||||
} parser_module_context_t;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
/**
|
||||
* Those members of a context which needs
|
||||
@@ -395,10 +395,10 @@ typedef struct
|
||||
parser_saved_context_t *last_context_p; /**< last saved context */
|
||||
parser_stack_iterator_t last_statement; /**< last statement position */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
parser_module_context_t *module_context_p; /**< shared module context inside the parser */
|
||||
parser_module_node_t *module_current_node_p; /**< import / export node that is being processed */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
/* Lexer members. */
|
||||
lexer_token_t token; /**< current token */
|
||||
@@ -549,12 +549,12 @@ void parser_set_continues_to_current_position (parser_context_t *context_p, pars
|
||||
|
||||
void lexer_next_token (parser_context_t *context_p);
|
||||
bool lexer_check_next_character (parser_context_t *context_p, lit_utf8_byte_t character);
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
void lexer_skip_empty_statements (parser_context_t *context_p);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
lexer_token_type_t lexer_check_arrow (parser_context_t *context_p);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
void lexer_parse_string (parser_context_t *context_p);
|
||||
void lexer_expect_identifier (parser_context_t *context_p, uint8_t literal_type);
|
||||
void lexer_scan_identifier (parser_context_t *context_p, bool property_name);
|
||||
@@ -581,11 +581,11 @@ uint8_t lexer_convert_binary_lvalue_token_to_binary (uint8_t token);
|
||||
/* Parser functions. */
|
||||
|
||||
void parser_parse_expression (parser_context_t *context_p, int options);
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
void parser_parse_class (parser_context_t *context_p, bool is_statement);
|
||||
void parser_parse_super_class_context_start (parser_context_t *context_p);
|
||||
void parser_parse_super_class_context_end (parser_context_t *context_p, bool is_statement);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -606,7 +606,7 @@ void parser_scan_until (parser_context_t *context_p, lexer_range_t *range_p, lex
|
||||
void parser_parse_statements (parser_context_t *context_p);
|
||||
void parser_free_jumps (parser_stack_iterator_t iterator);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
@@ -636,7 +636,7 @@ void parser_module_add_item_to_node (parser_context_t *context_p,
|
||||
lexer_literal_t *local_name_p,
|
||||
bool is_import_item);
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -646,9 +646,9 @@ void parser_module_add_item_to_node (parser_context_t *context_p,
|
||||
*/
|
||||
|
||||
ecma_compiled_code_t *parser_parse_function (parser_context_t *context_p, uint32_t status_flags);
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
ecma_compiled_code_t *parser_parse_arrow_function (parser_context_t *context_p, uint32_t status_flags);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
/* Error management. */
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "js-parser-internal.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
@@ -600,4 +600,4 @@ parser_module_handle_from_clause (parser_context_t *context_p) /**< parser conte
|
||||
|
||||
lexer_next_token (context_p);
|
||||
} /* parser_module_handle_from_clause */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
@@ -35,18 +35,18 @@ typedef enum
|
||||
{
|
||||
SCAN_MODE_PRIMARY_EXPRESSION, /**< scanning primary expression */
|
||||
SCAN_MODE_PRIMARY_EXPRESSION_AFTER_NEW, /**< scanning primary expression after new */
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
SCAN_MODE_ARROW_FUNCTION, /**< arrow function might follows */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
SCAN_MODE_POST_PRIMARY_EXPRESSION, /**< scanning post primary expression */
|
||||
SCAN_MODE_PRIMARY_EXPRESSION_END, /**< scanning primary expression end */
|
||||
SCAN_MODE_STATEMENT, /**< scanning statement */
|
||||
SCAN_MODE_FUNCTION_ARGUMENTS, /**< scanning function arguments */
|
||||
SCAN_MODE_PROPERTY_NAME, /**< scanning property name */
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
SCAN_MODE_CLASS_DECLARATION, /**< scanning class declaration */
|
||||
SCAN_MODE_CLASS_METHOD, /**< scanning class method */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
} scan_modes_t;
|
||||
|
||||
/**
|
||||
@@ -64,19 +64,19 @@ typedef enum
|
||||
SCAN_STACK_BLOCK_STATEMENT, /**< block statement group */
|
||||
SCAN_STACK_BLOCK_EXPRESSION, /**< block expression group */
|
||||
SCAN_STACK_BLOCK_PROPERTY, /**< block property group */
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
SCAN_STACK_COMPUTED_PROPERTY, /**< computed property name */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
SCAN_STACK_TEMPLATE_STRING, /**< template string */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
SCAN_STACK_CLASS, /**< class language element */
|
||||
SCAN_STACK_CLASS_EXTENDS, /**< class extends expression */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
SCAN_STACK_FUNCTION_PARAMETERS, /**< function parameter initializer */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
} scan_stack_modes_t;
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ parser_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
*mode = SCAN_MODE_PROPERTY_NAME;
|
||||
return true;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
case LEXER_TEMPLATE_LITERAL:
|
||||
{
|
||||
if (context_p->source_p[-1] != LIT_CHAR_GRAVE_ACCENT)
|
||||
@@ -141,9 +141,9 @@ parser_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
/* The string is a normal string literal. */
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
case LEXER_LITERAL:
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
{
|
||||
bool is_ident = (context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
|
||||
|
||||
@@ -151,7 +151,7 @@ parser_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
: SCAN_MODE_POST_PRIMARY_EXPRESSION);
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
case LEXER_KEYW_THIS:
|
||||
case LEXER_LIT_TRUE:
|
||||
case LEXER_LIT_FALSE:
|
||||
@@ -160,14 +160,14 @@ parser_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
*mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_BLOCK_EXPRESSION);
|
||||
*mode = SCAN_MODE_CLASS_DECLARATION;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
case LEXER_RIGHT_SQUARE:
|
||||
{
|
||||
if (stack_top != SCAN_STACK_SQUARE_BRACKETED_EXPRESSION)
|
||||
@@ -189,11 +189,11 @@ parser_scan_primary_expression (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
case LEXER_RIGHT_PAREN:
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
*mode = SCAN_MODE_ARROW_FUNCTION;
|
||||
#else /* CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#else /* !ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
*mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
if (stack_top == SCAN_STACK_PAREN_STATEMENT)
|
||||
{
|
||||
@@ -336,29 +336,29 @@ parser_scan_primary_expression_end (parser_context_t *context_p, /**< context */
|
||||
|
||||
if ((type == LEXER_RIGHT_SQUARE && stack_top == SCAN_STACK_SQUARE_BRACKETED_EXPRESSION)
|
||||
|| (type == LEXER_RIGHT_PAREN && stack_top == SCAN_STACK_PAREN_EXPRESSION)
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
|| (type == LEXER_LEFT_BRACE && stack_top == SCAN_STACK_CLASS_EXTENDS)
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|| (type == LEXER_RIGHT_BRACE && stack_top == SCAN_STACK_OBJECT_LITERAL))
|
||||
{
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
*mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
if (type == LEXER_RIGHT_PAREN)
|
||||
{
|
||||
*mode = SCAN_MODE_ARROW_FUNCTION;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (stack_top == SCAN_STACK_CLASS_EXTENDS)
|
||||
{
|
||||
*mode = SCAN_MODE_CLASS_METHOD;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
if (type == LEXER_RIGHT_BRACE && stack_top == SCAN_STACK_TEMPLATE_STRING)
|
||||
{
|
||||
context_p->source_p--;
|
||||
@@ -376,7 +376,7 @@ parser_scan_primary_expression_end (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
|
||||
*mode = SCAN_MODE_STATEMENT;
|
||||
if (type == LEXER_RIGHT_PAREN && stack_top == SCAN_STACK_PAREN_STATEMENT)
|
||||
@@ -385,7 +385,7 @@ parser_scan_primary_expression_end (parser_context_t *context_p, /**< context */
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_RIGHT_SQUARE && stack_top == SCAN_STACK_COMPUTED_PROPERTY)
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
@@ -421,9 +421,9 @@ parser_scan_primary_expression_end (parser_context_t *context_p, /**< context */
|
||||
*mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
return false;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_RIGHT_PAREN && stack_top == SCAN_STACK_FUNCTION_PARAMETERS)
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
@@ -437,15 +437,15 @@ parser_scan_primary_expression_end (parser_context_t *context_p, /**< context */
|
||||
*mode = SCAN_MODE_STATEMENT;
|
||||
return false;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
|
||||
/* Check whether we can enter to statement mode. */
|
||||
if (stack_top != SCAN_STACK_BLOCK_STATEMENT
|
||||
&& stack_top != SCAN_STACK_BLOCK_EXPRESSION
|
||||
&& stack_top != SCAN_STACK_BLOCK_PROPERTY
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
&& stack_top != SCAN_STACK_CLASS
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
&& !(stack_top == SCAN_STACK_HEAD && end_type == LEXER_SCAN_SWITCH))
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_EXPRESSION);
|
||||
@@ -569,9 +569,9 @@ parser_scan_statement (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
if (stack_top == SCAN_STACK_BLOCK_STATEMENT
|
||||
|| stack_top == SCAN_STACK_BLOCK_EXPRESSION
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
|| stack_top == SCAN_STACK_CLASS
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|| stack_top == SCAN_STACK_BLOCK_PROPERTY)
|
||||
{
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
@@ -580,12 +580,12 @@ parser_scan_statement (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
*mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
else if (stack_top == SCAN_STACK_CLASS)
|
||||
{
|
||||
*mode = SCAN_MODE_CLASS_METHOD;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
else if (stack_top == SCAN_STACK_BLOCK_PROPERTY)
|
||||
{
|
||||
*mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
@@ -612,14 +612,14 @@ parser_scan_statement (parser_context_t *context_p, /**< context */
|
||||
*mode = SCAN_MODE_FUNCTION_ARGUMENTS;
|
||||
return false;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_BLOCK_STATEMENT);
|
||||
*mode = SCAN_MODE_CLASS_DECLARATION;
|
||||
return false;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
default:
|
||||
{
|
||||
break;
|
||||
@@ -637,11 +637,11 @@ parser_scan_statement (parser_context_t *context_p, /**< context */
|
||||
*mode = SCAN_MODE_STATEMENT;
|
||||
return false;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
*mode = SCAN_MODE_ARROW_FUNCTION;
|
||||
#else /* CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#else /* !ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
*mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -724,7 +724,7 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
case SCAN_MODE_CLASS_DECLARATION:
|
||||
{
|
||||
if (context_p->token.type == LEXER_LITERAL && context_p->token.lit_location.type == LEXER_IDENT_LITERAL)
|
||||
@@ -777,8 +777,8 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
mode = SCAN_MODE_FUNCTION_ARGUMENTS;
|
||||
continue;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
case SCAN_MODE_ARROW_FUNCTION:
|
||||
{
|
||||
if (type == LEXER_ARROW)
|
||||
@@ -801,7 +801,7 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
case SCAN_MODE_POST_PRIMARY_EXPRESSION:
|
||||
{
|
||||
if (parser_scan_post_primary_expression (context_p, type, &mode))
|
||||
@@ -836,16 +836,16 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
case SCAN_MODE_FUNCTION_ARGUMENTS:
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
JERRY_ASSERT (stack_top == SCAN_STACK_BLOCK_STATEMENT
|
||||
|| stack_top == SCAN_STACK_BLOCK_EXPRESSION
|
||||
|| stack_top == SCAN_STACK_CLASS
|
||||
|| stack_top == SCAN_STACK_BLOCK_PROPERTY);
|
||||
#else /* CONFIG_DISABLE_ES2015_CLASS */
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
JERRY_ASSERT (stack_top == SCAN_STACK_BLOCK_STATEMENT
|
||||
|| stack_top == SCAN_STACK_BLOCK_EXPRESSION
|
||||
|| stack_top == SCAN_STACK_BLOCK_PROPERTY);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
if (context_p->token.type == LEXER_LITERAL
|
||||
&& (context_p->token.lit_location.type == LEXER_IDENT_LITERAL
|
||||
@@ -865,12 +865,12 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->token.type == LEXER_THREE_DOTS)
|
||||
{
|
||||
lexer_next_token (context_p);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
if (context_p->token.type != LEXER_LITERAL
|
||||
|| context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
|
||||
@@ -887,14 +887,14 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_ASSIGN)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_FUNCTION_PARAMETERS);
|
||||
mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
|
||||
if (context_p->token.type != LEXER_RIGHT_PAREN)
|
||||
{
|
||||
@@ -916,14 +916,14 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_scan_identifier (context_p, true);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_LEFT_SQUARE)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_COMPUTED_PROPERTY);
|
||||
mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
if (context_p->token.type == LEXER_RIGHT_BRACE)
|
||||
{
|
||||
@@ -939,14 +939,14 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_BLOCK_PROPERTY);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_LEFT_SQUARE)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_COMPUTED_PROPERTY);
|
||||
mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
if (context_p->token.type != LEXER_LITERAL)
|
||||
{
|
||||
@@ -959,7 +959,7 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_LEFT_PAREN)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_BLOCK_PROPERTY);
|
||||
@@ -978,7 +978,7 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
mode = SCAN_MODE_POST_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_OBJECT_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
if (context_p->token.type != LEXER_COLON)
|
||||
{
|
||||
|
||||
@@ -324,7 +324,7 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
|
||||
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_VAR;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
if (context_p->module_context_p != NULL && context_p->module_current_node_p != NULL)
|
||||
{
|
||||
parser_module_add_item_to_node (context_p,
|
||||
@@ -333,7 +333,7 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
|
||||
context_p->lit_object.literal_p,
|
||||
false);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
@@ -400,7 +400,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
|
||||
|
||||
name_p = context_p->lit_object.literal_p;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
if (context_p->module_context_p != NULL && context_p->module_current_node_p != NULL)
|
||||
{
|
||||
parser_module_add_item_to_node (context_p,
|
||||
@@ -409,7 +409,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
|
||||
name_p,
|
||||
false);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
status_flags = PARSER_IS_FUNCTION | PARSER_IS_CLOSURE;
|
||||
if (context_p->lit_object.type != LEXER_LITERAL_OBJECT_ANY)
|
||||
@@ -621,7 +621,7 @@ parser_parse_with_statement_end (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* parser_parse_with_statement_end */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
/**
|
||||
* Parse super class context like a with statement (starting part).
|
||||
*/
|
||||
@@ -690,7 +690,7 @@ parser_parse_super_class_context_end (parser_context_t *context_p, /**< context
|
||||
|
||||
parser_set_branch_to_current_position (context_p, &with_statement.branch);
|
||||
} /* parser_parse_super_class_context_end */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
/**
|
||||
* Parse do-while statement (ending part).
|
||||
@@ -1675,7 +1675,7 @@ parser_parse_continue_statement (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
} /* parser_parse_continue_statement */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
/**
|
||||
* Parse import statement.
|
||||
*/
|
||||
@@ -1818,7 +1818,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 /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
/**
|
||||
* Parse label statement.
|
||||
@@ -2057,15 +2057,15 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
case LEXER_KEYW_CLASS:
|
||||
{
|
||||
parser_parse_class (context_p, true);
|
||||
continue;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
case LEXER_KEYW_IMPORT:
|
||||
{
|
||||
parser_parse_import_statement (context_p);
|
||||
@@ -2077,7 +2077,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
parser_parse_export_statement (context_p);
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
case LEXER_KEYW_FUNCTION:
|
||||
{
|
||||
@@ -2209,7 +2209,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
|| context_p->token.type == LEXER_SEMICOLON
|
||||
|| context_p->token.type == LEXER_RIGHT_BRACE)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (JERRY_UNLIKELY (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags)))
|
||||
{
|
||||
if (context_p->status_flags & PARSER_CLASS_IMPLICIT_SUPER)
|
||||
@@ -2224,20 +2224,20 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
parser_emit_cbc (context_p, CBC_RETURN_WITH_BLOCK);
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
break;
|
||||
}
|
||||
|
||||
parser_parse_expression (context_p, PARSE_EXPR);
|
||||
|
||||
bool return_with_literal = (context_p->last_cbc_opcode == CBC_PUSH_LITERAL);
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
return_with_literal = return_with_literal && !PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
if (return_with_literal)
|
||||
{
|
||||
@@ -2245,18 +2245,18 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (JERRY_UNLIKELY (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags)))
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_CONSTRUCTOR_RETURN);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
parser_emit_cbc (context_p, CBC_RETURN);
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2358,7 +2358,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
/* There is no lexer_next_token here, since the
|
||||
* next token belongs to the parent context. */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (JERRY_UNLIKELY (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags)))
|
||||
{
|
||||
if (context_p->status_flags & PARSER_CLASS_IMPLICIT_SUPER)
|
||||
@@ -2372,7 +2372,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
parser_emit_cbc (context_p, CBC_RETURN);
|
||||
parser_flush_cbc (context_p);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
return;
|
||||
}
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_RIGHT_SQUARE);
|
||||
|
||||
@@ -898,7 +898,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Case statement must be in a switch block.";
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
case PARSER_ERR_MULTIPLE_CLASS_CONSTRUCTORS:
|
||||
{
|
||||
return "Multiple constructors are not allowed.";
|
||||
@@ -915,7 +915,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Super is not allowed to be used here.";
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
case PARSER_ERR_LEFT_PAREN_EXPECTED:
|
||||
{
|
||||
return "Expected '(' token.";
|
||||
@@ -932,12 +932,12 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Expected ']' token.";
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
case PARSER_ERR_RIGHT_BRACE_EXPECTED:
|
||||
{
|
||||
return "Expected '}' token.";
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
case PARSER_ERR_COLON_EXPECTED:
|
||||
{
|
||||
return "Expected ':' token.";
|
||||
@@ -1038,15 +1038,15 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Duplicated label.";
|
||||
}
|
||||
#if (!defined (CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER) \
|
||||
|| !defined (CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER))
|
||||
#if ((ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)) \
|
||||
|| (ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)))
|
||||
case PARSER_ERR_DUPLICATED_ARGUMENT_NAMES:
|
||||
{
|
||||
return "Duplicated function argument names are not allowed here.";
|
||||
}
|
||||
#endif /* (!defined (CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
|| !defined (CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER)) */
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
|
||||
#endif /* ((ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER))
|
||||
|| (ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER))) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
case PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER:
|
||||
{
|
||||
return "Rest parameter must be the last formal parameter.";
|
||||
@@ -1055,7 +1055,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Rest parameter may not have a default initializer.";
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
case PARSER_ERR_OBJECT_PROPERTY_REDEFINED:
|
||||
{
|
||||
return "Property of object literal redefined.";
|
||||
@@ -1065,7 +1065,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
return "Non-strict argument definition.";
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
case PARSER_ERR_MODULE_REQUEST_NOT_FOUND:
|
||||
{
|
||||
return "Import request not found in the module.";
|
||||
@@ -1102,7 +1102,7 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Import and export statements must be in the global context.";
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_PARSE_STRICT_MODE == (int) PARSER_IS_STRICT,
|
||||
ecma_parse_strict_mode_must_be_equal_to_parser_is_strict);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
JERRY_STATIC_ASSERT ((ECMA_PARSE_CLASS_CONSTRUCTOR << PARSER_CLASS_PARSE_OPTS_OFFSET) == PARSER_CLASS_CONSTRUCTOR,
|
||||
ecma_class_parse_options_must_be_able_to_be_shifted_to_ecma_general_flags);
|
||||
#endif /* !CONFIG_DISABLE_ES2015 */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@@ -602,18 +602,18 @@ parser_generate_initializers (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
JERRY_ASSERT ((argument_count - 1) == context_p->argument_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
JERRY_ASSERT (argument_count == context_p->argument_count);
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
}
|
||||
|
||||
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
|
||||
@@ -712,13 +712,13 @@ parser_generate_initializers (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
JERRY_ASSERT ((argument_count - 1) == context_p->argument_count);
|
||||
return dst_p;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
JERRY_ASSERT (argument_count == context_p->argument_count);
|
||||
return dst_p;
|
||||
@@ -994,12 +994,12 @@ parse_print_literal (ecma_compiled_code_t *compiled_code_p, /**< compiled code *
|
||||
const_literal_end = args_p->const_literal_end;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_REST_PARAMETER)
|
||||
{
|
||||
argument_end++;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
parser_list_iterator_init (literal_pool_p, &literal_iterator);
|
||||
|
||||
@@ -1214,19 +1214,19 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
JERRY_DEBUG_MSG (",no_lexical_env");
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION)
|
||||
{
|
||||
JERRY_DEBUG_MSG (",arrow");
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_CONSTRUCTOR)
|
||||
{
|
||||
JERRY_DEBUG_MSG (",constructor");
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
JERRY_DEBUG_MSG ("]\n");
|
||||
|
||||
@@ -1564,12 +1564,12 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
PARSER_NEXT_BYTE (page_p, offset);
|
||||
length++;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (ext_opcode == CBC_EXT_CONSTRUCTOR_RETURN)
|
||||
{
|
||||
last_opcode = CBC_RETURN;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015 */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
#ifdef JERRY_ENABLE_LINE_INFO
|
||||
if (ext_opcode == CBC_EXT_LINE)
|
||||
@@ -1769,13 +1769,13 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
compiled_code_p->refs = 1;
|
||||
compiled_code_p->status_flags = CBC_CODE_FLAGS_FUNCTION;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
JERRY_ASSERT (context_p->argument_count > 0);
|
||||
context_p->argument_count--;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
if (needs_uint16_arguments)
|
||||
{
|
||||
@@ -1828,26 +1828,26 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
if (context_p->status_flags & PARSER_IS_ARROW_FUNCTION)
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_ARROW_FUNCTION;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if (context_p->status_flags & PARSER_CLASS_CONSTRUCTOR)
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_CONSTRUCTOR;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_REST_PARAMETER;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
literal_pool_p = (ecma_value_t *) byte_code_p;
|
||||
literal_pool_p -= context_p->register_count;
|
||||
@@ -2188,10 +2188,10 @@ static void
|
||||
parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
lexer_token_type_t end_type) /**< expected end type */
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
bool duplicated_argument_names = false;
|
||||
bool initializer_found = false;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
|
||||
if (context_p->token.type == end_type)
|
||||
{
|
||||
@@ -2202,7 +2202,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
uint16_t literal_count = context_p->literal_count;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER);
|
||||
@@ -2218,7 +2218,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
context_p->status_flags |= PARSER_FUNCTION_HAS_REST_PARAM;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
if (context_p->token.type != LEXER_LITERAL
|
||||
|| context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
|
||||
@@ -2252,13 +2252,13 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
lexer_literal_t *literal_p;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
if (initializer_found)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_DUPLICATED_ARGUMENT_NAMES);
|
||||
}
|
||||
duplicated_argument_names = true;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
|
||||
if (context_p->literal_count >= PARSER_MAXIMUM_NUMBER_OF_LITERALS)
|
||||
{
|
||||
@@ -2296,15 +2296,15 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
if (context_p->token.type == LEXER_ASSIGN)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
|
||||
parser_branch_t skip_init;
|
||||
|
||||
@@ -2324,7 +2324,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_set_branch_to_current_position (context_p, &skip_init);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
|
||||
if (context_p->token.type != LEXER_COMMA)
|
||||
{
|
||||
@@ -2398,13 +2398,13 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
context.last_statement.current_p = NULL;
|
||||
context.status_flags |= parse_opts & PARSER_STRICT_MODE_MASK;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
context.module_context_p = NULL;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
context.status_flags |= PARSER_GET_CLASS_PARSER_OPTS (parse_opts);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
context.token.flags = 0;
|
||||
context.line = 1;
|
||||
@@ -2479,13 +2479,13 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
JERRY_ASSERT (context.last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
|
||||
JERRY_ASSERT (context.allocated_buffer_p == NULL);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
if (context.module_context_p != NULL)
|
||||
{
|
||||
parser_module_handle_requests (&context);
|
||||
ecma_module_load_modules (&context);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
compiled_code_p = parser_post_processing (&context);
|
||||
parser_list_free (&context.literal_pool);
|
||||
@@ -2535,9 +2535,9 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
parser_module_context_cleanup (&context);
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
parser_stack_free (&context);
|
||||
|
||||
return compiled_code_p;
|
||||
@@ -2653,13 +2653,13 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
JERRY_DEBUG_MSG ("\n--- %s parsing start ---\n\n",
|
||||
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor"
|
||||
: "Function");
|
||||
#else /* CONFIG_DISABLE_ES2015_CLASS */
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
JERRY_DEBUG_MSG ("\n--- Function parsing start ---\n\n");
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@@ -2712,25 +2712,25 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
|
||||
lexer_next_token (context_p);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
if ((context_p->status_flags & PARSER_CLASS_CONSTRUCTOR_SUPER) == PARSER_CLASS_CONSTRUCTOR_SUPER)
|
||||
{
|
||||
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
parser_parse_statements (context_p);
|
||||
compiled_code_p = parser_post_processing (context_p);
|
||||
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
JERRY_DEBUG_MSG ("\n--- %s parsing end ---\n\n",
|
||||
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor"
|
||||
: "Function");
|
||||
#else /* CONFIG_DISABLE_ES2015_CLASS */
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
JERRY_DEBUG_MSG ("\n--- Function parsing end ---\n\n");
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@@ -2739,7 +2739,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
return compiled_code_p;
|
||||
} /* parser_parse_function */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
|
||||
/**
|
||||
* Parse arrow function code
|
||||
@@ -2757,9 +2757,9 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
|
||||
&& (status_flags & PARSER_IS_ARROW_FUNCTION));
|
||||
parser_save_context (context_p, &saved_context);
|
||||
context_p->status_flags |= status_flags | PARSER_ARGUMENTS_NOT_NEEDED;
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
context_p->status_flags |= saved_context.status_flags & PARSER_CLASS_HAS_SUPER;
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context_p->is_show_opcodes)
|
||||
@@ -2857,7 +2857,7 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
|
||||
return compiled_code_p;
|
||||
} /* parser_parse_arrow_function */
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
|
||||
/**
|
||||
* Raise a parse error
|
||||
@@ -2866,12 +2866,12 @@ void
|
||||
parser_raise_error (parser_context_t *context_p, /**< context */
|
||||
parser_error_t error) /**< error code */
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
if (context_p->module_context_p != NULL)
|
||||
{
|
||||
parser_module_free_saved_names (context_p->module_current_node_p);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
parser_saved_context_t *saved_context_p = context_p->last_context_p;
|
||||
|
||||
|
||||
@@ -79,21 +79,21 @@ typedef enum
|
||||
PARSER_ERR_MULTIPLE_DEFAULTS_NOT_ALLOWED, /**< multiple default cases are not allowed */
|
||||
PARSER_ERR_DEFAULT_NOT_IN_SWITCH, /**< default statement is not in switch block */
|
||||
PARSER_ERR_CASE_NOT_IN_SWITCH, /**< case statement is not in switch block */
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
PARSER_ERR_MULTIPLE_CLASS_CONSTRUCTORS, /**< multiple class constructor */
|
||||
PARSER_ERR_CLASS_CONSTRUCTOR_AS_ACCESSOR, /**< class constructor cannot be an accessor */
|
||||
PARSER_ERR_CLASS_STATIC_PROTOTYPE, /**< static method name 'prototype' is not allowed */
|
||||
PARSER_ERR_UNEXPECTED_SUPER_REFERENCE, /**< unexpected super keyword */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
|
||||
PARSER_ERR_LEFT_PAREN_EXPECTED, /**< left paren expected */
|
||||
PARSER_ERR_LEFT_BRACE_EXPECTED, /**< left brace expected */
|
||||
PARSER_ERR_RIGHT_PAREN_EXPECTED, /**< right paren expected */
|
||||
PARSER_ERR_RIGHT_SQUARE_EXPECTED, /**< right square expected */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#if ENABLED (JERRY_ES2015_TEMPLATE_STRINGS)
|
||||
PARSER_ERR_RIGHT_BRACE_EXPECTED, /**< right brace expected */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#endif /* ENABLED (JERRY_ES2015_TEMPLATE_STRINGS) */
|
||||
PARSER_ERR_COLON_EXPECTED, /**< colon expected */
|
||||
PARSER_ERR_COLON_FOR_CONDITIONAL_EXPECTED, /**< colon expected for conditional expression */
|
||||
PARSER_ERR_SEMICOLON_EXPECTED, /**< semicolon expected */
|
||||
@@ -120,18 +120,16 @@ typedef enum
|
||||
PARSER_ERR_INVALID_RETURN, /**< return must be inside a function */
|
||||
PARSER_ERR_INVALID_RIGHT_SQUARE, /**< right square must terminate a block */
|
||||
PARSER_ERR_DUPLICATED_LABEL, /**< duplicated label */
|
||||
#if (!defined (CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER) \
|
||||
|| !defined (CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER))
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) || ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
PARSER_ERR_DUPLICATED_ARGUMENT_NAMES, /**< duplicated argument names */
|
||||
#endif /* (!defined (CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
|| !defined (CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER)) */
|
||||
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) || ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER, /**< formal parameter after rest parameter */
|
||||
PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER, /**< rest parameter default initializer */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
PARSER_ERR_OBJECT_PROPERTY_REDEFINED, /**< property of object literal redefined */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
PARSER_ERR_RIGHT_PAREN_COMMA_FROM_EXPECTED, /**< rigth paren or comma or from expected */
|
||||
PARSER_ERR_FROM_EXPECTED, /**< from expected */
|
||||
PARSER_ERR_STRING_EXPECTED, /**< string literal expected */
|
||||
@@ -141,7 +139,7 @@ typedef enum
|
||||
PARSER_ERR_MODULE_REQUEST_LIMIT_REACHED, /**< maximum number of requests reached */
|
||||
PARSER_ERR_MODULE_UNEXPECTED, /**< unexpected import or export statement */
|
||||
PARSER_ERR_LEFT_PAREN_MULTIPLY_LITERAL_EXPECTED, /**< left paren or multiply or literal expected */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
|
||||
PARSER_ERR_NON_STRICT_ARG_DEFINITION /**< non-strict argument definition */
|
||||
} parser_error_t;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "re-bytecode.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@@ -443,4 +443,4 @@ re_dump_bytecode (re_bytecode_ctx_t *bc_ctx_p) /**< RegExp bytecode context */
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#ifndef RE_BYTECODE_H
|
||||
#define RE_BYTECODE_H
|
||||
|
||||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
@@ -124,5 +124,5 @@ void re_dump_bytecode (re_bytecode_ctx_t *bc_ctx);
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
#endif /* !RE_BYTECODE_H */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "re-compiler.h"
|
||||
#include "re-parser.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@@ -675,4 +675,4 @@ re_compile_bytecode (const re_compiled_code_t **out_bytecode_p, /**< [out] point
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#ifndef RE_COMPILER_H
|
||||
#define RE_COMPILER_H
|
||||
|
||||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "re-bytecode.h"
|
||||
@@ -60,5 +60,5 @@ void re_cache_gc_run (void);
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
#endif /* !RE_COMPILER_H */
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "re-compiler.h"
|
||||
#include "re-parser.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@@ -890,9 +890,9 @@ re_parse_next_token (re_parser_ctx_t *parser_ctx_p, /**< RegExp parser context *
|
||||
}
|
||||
case LIT_CHAR_LEFT_BRACE:
|
||||
{
|
||||
#ifdef ENABLE_REGEXP_STRICT_MODE
|
||||
#if ENABLED (JERRY_REGEXP_STRICT_MODE)
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid RegExp token."));
|
||||
#else /* !ENABLE_REGEXP_STRICT_MODE */
|
||||
#else /* !ENABLED (JERRY_REGEXP_STRICT_MODE) */
|
||||
const lit_utf8_byte_t *input_curr_p = parser_ctx_p->input_curr_p;
|
||||
|
||||
lit_utf8_decr (&parser_ctx_p->input_curr_p);
|
||||
@@ -917,7 +917,7 @@ re_parse_next_token (re_parser_ctx_t *parser_ctx_p, /**< RegExp parser context *
|
||||
parser_ctx_p->input_curr_p = input_curr_p;
|
||||
ret_value = ECMA_VALUE_EMPTY;
|
||||
}
|
||||
#endif /* ENABLE_REGEXP_STRICT_MODE */
|
||||
#endif /* ENABLED (JERRY_REGEXP_STRICT_MODE) */
|
||||
break;
|
||||
}
|
||||
case LIT_CHAR_NULL:
|
||||
@@ -943,4 +943,4 @@ re_parse_next_token (re_parser_ctx_t *parser_ctx_p, /**< RegExp parser context *
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#ifndef RE_PARSER_H
|
||||
#define RE_PARSER_H
|
||||
|
||||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@@ -113,5 +113,5 @@ re_parse_next_token (re_parser_ctx_t *parser_ctx_p, re_token_t *out_token_p);
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
#endif /* !RE_PARSER_H */
|
||||
|
||||
Reference in New Issue
Block a user