Remove ES_NEXT macro (#4915)

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

Co-authored-by: Martin Negyokru negyokru@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2022-01-31 16:46:00 +01:00
committed by GitHub
parent 76403606d0
commit 4924f9fd31
973 changed files with 1902 additions and 8240 deletions
+7 -201
View File
@@ -36,8 +36,6 @@
JERRY_STATIC_ASSERT (PARSER_MAXIMUM_NUMBER_OF_LITERALS + PARSER_MAXIMUM_NUMBER_OF_REGISTERS < PARSER_REGISTER_START,
maximum_number_of_literals_plus_registers_must_be_less_than_register_start);
#if JERRY_ESNEXT
JERRY_STATIC_ASSERT ((SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG & SCANNER_LITERAL_IS_LOCAL) == 0,
is_arrow_arg_binding_flag_must_not_use_local_flags);
@@ -57,8 +55,6 @@ JERRY_STATIC_ASSERT (SCANNER_LITERAL_IS_FUNC_DECLARATION != SCANNER_LITERAL_IS_D
JERRY_STATIC_ASSERT (PARSER_SCOPE_STACK_IS_CONST_REG == PARSER_SCOPE_STACK_IS_LOCAL_CREATED,
scope_stack_is_const_reg_and_scope_stack_is_local_created_must_be_the_same);
#endif /* JERRY_ESNEXT */
/**
* Raise a scanner error.
*/
@@ -70,8 +66,6 @@ scanner_raise_error (parser_context_t *context_p) /**< context */
JERRY_ASSERT (0);
} /* scanner_raise_error */
#if JERRY_ESNEXT
/**
* Raise a variable redeclaration error.
*/
@@ -84,8 +78,6 @@ scanner_raise_redeclaration_error (parser_context_t *context_p) /**< context */
scanner_raise_error (context_p);
} /* scanner_raise_redeclaration_error */
#endif /* JERRY_ESNEXT */
/**
* Allocate memory for scanner.
*
@@ -138,24 +130,18 @@ scanner_get_stream_size (scanner_info_t *info_p, /**< scanner info block */
switch (data_p[0] & SCANNER_STREAM_TYPE_MASK)
{
case SCANNER_STREAM_TYPE_VAR:
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_LET:
case SCANNER_STREAM_TYPE_CONST:
case SCANNER_STREAM_TYPE_LOCAL:
#endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM
case SCANNER_STREAM_TYPE_IMPORT:
#endif /* JERRY_MODULE_SYSTEM */
case SCANNER_STREAM_TYPE_ARG:
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_ARG_VAR:
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG:
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR:
#endif /* JERRY_MODULE_SYSTEM */
case SCANNER_STREAM_TYPE_ARG_FUNC:
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC:
#endif /* JERRY_ESNEXT */
case SCANNER_STREAM_TYPE_FUNC:
{
break;
@@ -409,8 +395,6 @@ scanner_literal_is_arguments (lexer_lit_location_t *literal_p) /**< literal */
return lexer_compare_identifier_to_string (literal_p, (const uint8_t *) "arguments", 9);
} /* scanner_literal_is_arguments */
#if JERRY_ESNEXT
/**
* Find if there is a duplicated argument in the given context
*
@@ -577,8 +561,6 @@ scanner_scope_find_lexical_declaration (parser_context_t *context_p, /**< contex
return false;
} /* scanner_scope_find_lexical_declaration */
#endif /* JERRY_ESNEXT */
/**
* Push a new literal pool.
*
@@ -599,16 +581,11 @@ scanner_push_literal_pool (parser_context_t *context_p, /**< context */
JERRY_ASSERT (prev_literal_pool_p != NULL);
status_flags |= SCANNER_LITERAL_POOL_NO_ARGUMENTS;
#if JERRY_ESNEXT
const uint16_t copied_flags =
(SCANNER_LITERAL_POOL_IN_WITH | SCANNER_LITERAL_POOL_GENERATOR | SCANNER_LITERAL_POOL_ASYNC);
#else /* !JERRY_ESNEXT */
const uint16_t copied_flags = SCANNER_LITERAL_POOL_IN_WITH;
#endif /* JERRY_ESNEXT */
status_flags |= (uint16_t) (prev_literal_pool_p->status_flags & copied_flags);
}
#if JERRY_ESNEXT
else
{
context_p->status_flags &= (uint32_t) ~(PARSER_IS_GENERATOR_FUNCTION | PARSER_IS_ASYNC_FUNCTION);
@@ -623,7 +600,6 @@ scanner_push_literal_pool (parser_context_t *context_p, /**< context */
context_p->status_flags |= PARSER_IS_ASYNC_FUNCTION;
}
}
#endif /* JERRY_ESNEXT */
if (prev_literal_pool_p != NULL)
{
@@ -671,13 +647,11 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
scanner_literal_pool_t *literal_pool_p = scanner_context_p->active_literal_pool_p;
scanner_literal_pool_t *prev_literal_pool_p = literal_pool_p->prev_p;
#if JERRY_ESNEXT
const uint32_t arrow_super_flags = (SCANNER_LITERAL_POOL_ARROW | SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE);
if ((literal_pool_p->status_flags & arrow_super_flags) == arrow_super_flags)
{
prev_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE;
}
#endif /* JERRY_ESNEXT */
if (JERRY_UNLIKELY (literal_pool_p->source_p == NULL))
{
@@ -702,7 +676,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
arguments_type = SCANNER_ARGUMENTS_MAY_PRESENT_IN_EVAL;
}
#if JERRY_ESNEXT
if (status_flags & SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS)
{
arguments_type = SCANNER_ARGUMENTS_PRESENT;
@@ -713,15 +686,13 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
status_flags &= (uint16_t) ~SCANNER_LITERAL_POOL_NO_ARGUMENTS;
}
}
#endif /* JERRY_ESNEXT */
uint8_t can_eval_types = 0;
#if JERRY_ESNEXT
if (prev_literal_pool_p == NULL && !(context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL))
{
can_eval_types |= SCANNER_LITERAL_IS_FUNC;
}
#endif /* JERRY_ESNEXT */
if ((status_flags & SCANNER_LITERAL_POOL_CAN_EVAL) && prev_literal_pool_p != NULL)
{
@@ -759,13 +730,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
if (!(status_flags & SCANNER_LITERAL_POOL_NO_ARGUMENTS) && scanner_literal_is_arguments (literal_p))
{
#if JERRY_ESNEXT
JERRY_ASSERT (arguments_type != SCANNER_ARGUMENTS_NOT_PRESENT);
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT
|| arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT_IN_EVAL);
#endif /* JERRY_ESNEXT */
status_flags |= SCANNER_LITERAL_POOL_NO_ARGUMENTS;
if (type & SCANNER_LITERAL_IS_ARG)
@@ -775,7 +740,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
arguments_type = SCANNER_ARGUMENTS_NOT_PRESENT;
last_argument_p = literal_p;
}
#if JERRY_ESNEXT
else if (type & SCANNER_LITERAL_IS_LOCAL)
{
if (arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT || arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT_IN_EVAL)
@@ -806,15 +770,8 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
}
}
}
#else /* !JERRY_ESNEXT */
else if (type & SCANNER_LITERAL_IS_FUNC)
{
arguments_type = SCANNER_ARGUMENTS_NOT_PRESENT;
}
#endif /* JERRY_ESNEXT */
else
{
#if JERRY_ESNEXT
if ((type & SCANNER_LITERAL_IS_VAR)
&& (arguments_type == SCANNER_ARGUMENTS_PRESENT || arguments_type == SCANNER_ARGUMENTS_PRESENT_NO_REG))
{
@@ -831,7 +788,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
literal_p->type = type;
no_declarations--;
}
#endif /* JERRY_ESNEXT */
if ((type & SCANNER_LITERAL_NO_REG) || arguments_type == SCANNER_ARGUMENTS_MAY_PRESENT_IN_EVAL)
{
@@ -842,17 +798,12 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
arguments_type = SCANNER_ARGUMENTS_PRESENT;
}
#if JERRY_ESNEXT
/* The SCANNER_LITERAL_IS_ARG may be set above. */
if (!(type & SCANNER_LITERAL_IS_ARG))
{
literal_p->type = 0;
continue;
}
#else /* !JERRY_ESNEXT */
literal_p->type = 0;
continue;
#endif /* JERRY_ESNEXT */
}
}
else if (type & SCANNER_LITERAL_IS_ARG)
@@ -860,7 +811,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
last_argument_p = literal_p;
}
#if JERRY_ESNEXT
if ((status_flags & SCANNER_LITERAL_POOL_FUNCTION)
&& (type & SCANNER_LITERAL_IS_LOCAL_FUNC) == SCANNER_LITERAL_IS_FUNC)
{
@@ -878,7 +828,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
type &= (uint8_t) ~SCANNER_LITERAL_IS_FUNC;
literal_p->type = type;
}
#endif /* JERRY_ESNEXT */
if ((type & SCANNER_LITERAL_IS_LOCAL)
|| ((type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_ARG))
@@ -904,7 +853,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
no_declarations++;
#if JERRY_ESNEXT
if ((type & (SCANNER_LITERAL_IS_CONST | SCANNER_LITERAL_IS_ARG)) == SCANNER_LITERAL_IS_CONST)
{
JERRY_ASSERT (type & SCANNER_LITERAL_IS_LET);
@@ -913,14 +861,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
literal_p->type = (uint8_t) (type & ~SCANNER_LITERAL_IS_FUNC);
no_declarations--;
}
#else /* !JERRY_ESNEXT */
if (type & SCANNER_LITERAL_IS_LOCAL)
{
/* Catch parameters cannot be functions. */
literal_p->type = (uint8_t) (type & ~SCANNER_LITERAL_IS_FUNC);
no_declarations--;
}
#endif /* JERRY_ESNEXT */
}
intptr_t diff = (intptr_t) (literal_p->char_p - prev_source_p);
@@ -941,9 +881,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
prev_source_p = literal_p->char_p + literal_p->length;
if ((status_flags & SCANNER_LITERAL_POOL_FUNCTION)
#if JERRY_ESNEXT
|| ((type & SCANNER_LITERAL_IS_FUNC) && (status_flags & SCANNER_LITERAL_POOL_IS_STRICT))
#endif /* JERRY_ESNEXT */
|| !(type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_FUNC)))
{
continue;
@@ -956,18 +894,12 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
lexer_lit_location_t *literal_location_p = scanner_add_custom_literal (context_p, prev_literal_pool_p, literal_p);
uint8_t extended_type = literal_location_p->type;
#if JERRY_ESNEXT
const uint16_t no_reg_flags = (SCANNER_LITERAL_POOL_FUNCTION | SCANNER_LITERAL_POOL_CLASS_FIELD);
#else /* !JERRY_ESNEXT */
const uint16_t no_reg_flags = SCANNER_LITERAL_POOL_FUNCTION;
#endif /* JERRY_ESNEXT */
if ((status_flags & no_reg_flags) || (type & SCANNER_LITERAL_NO_REG))
if ((status_flags & (SCANNER_LITERAL_POOL_FUNCTION | SCANNER_LITERAL_POOL_CLASS_FIELD))
|| (type & SCANNER_LITERAL_NO_REG))
{
extended_type |= SCANNER_LITERAL_NO_REG;
}
#if JERRY_ESNEXT
extended_type |= SCANNER_LITERAL_IS_USED;
if (status_flags & SCANNER_LITERAL_POOL_FUNCTION_STATEMENT)
@@ -984,7 +916,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
* for speculative arrow parameters and local (non-var) functions. */
type = 0;
}
#endif /* JERRY_ESNEXT */
type = (uint8_t) (type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_FUNC));
JERRY_ASSERT (type == 0 || !(status_flags & SCANNER_LITERAL_POOL_FUNCTION));
@@ -1046,13 +977,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
no_declarations++;
}
#if JERRY_ESNEXT
const uint16_t is_unmapped = SCANNER_LITERAL_POOL_IS_STRICT | SCANNER_LITERAL_POOL_HAS_COMPLEX_ARGUMENT;
#else /* !JERRY_ESNEXT */
const uint16_t is_unmapped = SCANNER_LITERAL_POOL_IS_STRICT;
#endif /* JERRY_ESNEXT */
if (!(status_flags & is_unmapped))
if (!(status_flags & (SCANNER_LITERAL_POOL_IS_STRICT | SCANNER_LITERAL_POOL_HAS_COMPLEX_ARGUMENT)))
{
mapped_arguments = true;
}
@@ -1072,7 +997,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
last_argument_p = NULL;
}
#if JERRY_ESNEXT
if (status_flags & (SCANNER_LITERAL_POOL_HAS_COMPLEX_ARGUMENT | SCANNER_LITERAL_POOL_ARROW))
{
u8_arg |= SCANNER_FUNCTION_HAS_COMPLEX_ARGUMENT;
@@ -1097,7 +1021,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
u8_arg |= SCANNER_FUNCTION_IS_STRICT;
}
#endif /* JERRY_ESNEXT */
info_p->u8_arg = u8_arg;
info_p->u16_arg = (uint16_t) no_declarations;
@@ -1147,19 +1070,16 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
type = SCANNER_STREAM_TYPE_ARG_FUNC;
#if JERRY_ESNEXT
if (literal_p->type & SCANNER_LITERAL_IS_DESTRUCTURED_ARG)
{
type = SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC;
}
#endif /* JERRY_ESNEXT */
}
}
else if (literal_p->type & SCANNER_LITERAL_IS_ARG)
{
type = SCANNER_STREAM_TYPE_ARG;
#if JERRY_ESNEXT
if (literal_p->type & SCANNER_LITERAL_IS_DESTRUCTURED_ARG)
{
type = SCANNER_STREAM_TYPE_DESTRUCTURED_ARG;
@@ -1171,9 +1091,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_ARG_VAR || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR);
}
#endif /* JERRY_ESNEXT */
}
#if JERRY_ESNEXT
else if (literal_p->type & SCANNER_LITERAL_IS_LET)
{
if (!(literal_p->type & SCANNER_LITERAL_IS_CONST))
@@ -1210,7 +1128,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
type |= SCANNER_STREAM_NO_REG | SCANNER_STREAM_EARLY_CREATE;
}
#endif /* JERRY_ESNEXT */
if (literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)
{
@@ -1282,7 +1199,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
context_p->status_flags &= (uint32_t) ~PARSER_IS_STRICT;
}
#if JERRY_ESNEXT
if (prev_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_GENERATOR)
{
context_p->status_flags |= PARSER_IS_GENERATOR_FUNCTION;
@@ -1300,7 +1216,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
context_p->status_flags &= (uint32_t) ~PARSER_IS_ASYNC_FUNCTION;
}
#endif /* JERRY_ESNEXT */
}
scanner_context_p->active_literal_pool_p = literal_pool_p->prev_p;
@@ -1309,8 +1224,6 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
scanner_free (literal_pool_p, sizeof (scanner_literal_pool_t));
} /* scanner_pop_literal_pool */
#if JERRY_ESNEXT
/**
* Filter out the arguments from a literal pool.
*/
@@ -1467,8 +1380,6 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
scanner_free (literal_pool_p, sizeof (scanner_literal_pool_t));
} /* scanner_filter_arguments */
#endif /* JERRY_ESNEXT */
/**
* Add any literal to the specified literal pool.
*
@@ -1522,13 +1433,11 @@ scanner_add_custom_literal (parser_context_t *context_p, /**< context */
}
}
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (literal_pool_p->status_flags & SCANNER_LITERAL_POOL_CLASS_NAME))
{
literal_pool_p = literal_pool_p->prev_p;
continue;
}
#endif /* JERRY_ESNEXT */
literal_p = (lexer_lit_location_t *) parser_list_append (context_p, &literal_pool_p->literal_pool);
*literal_p = *literal_location_p;
@@ -1565,9 +1474,7 @@ scanner_add_reference (parser_context_t *context_p, /**< context */
{
lexer_lit_location_t *lit_location_p =
scanner_add_custom_literal (context_p, scanner_context_p->active_literal_pool_p, &context_p->token.lit_location);
#if JERRY_ESNEXT
lit_location_p->type |= SCANNER_LITERAL_IS_USED;
#endif /* JERRY_ESNEXT */
if (scanner_context_p->active_literal_pool_p->status_flags & SCANNER_LITERAL_POOL_IN_WITH)
{
@@ -1634,12 +1541,10 @@ scanner_append_argument (parser_context_t *context_p, /**< context */
{
literal_p->length = 0;
#if JERRY_ESNEXT
if (literal_p->type & SCANNER_LITERAL_IS_USED)
{
literal_type = SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_EARLY_CREATE;
}
#endif /* JERRY_ESNEXT */
}
literal_p = (lexer_lit_location_t *) parser_list_append (context_p, &literal_pool_p->literal_pool);
@@ -1699,18 +1604,11 @@ scanner_detect_eval_call (parser_context_t *context_p, /**< context */
{
if (context_p->token.keyword_type == LEXER_KEYW_EVAL && lexer_check_next_character (context_p, LIT_CHAR_LEFT_PAREN))
{
#if JERRY_ESNEXT
const uint16_t flags = (uint16_t) (SCANNER_LITERAL_POOL_CAN_EVAL | SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE);
#else /* !JERRY_ESNEXT */
const uint16_t flags = SCANNER_LITERAL_POOL_CAN_EVAL;
#endif /* JERRY_ESNEXT */
scanner_context_p->active_literal_pool_p->status_flags |= flags;
scanner_context_p->active_literal_pool_p->status_flags |=
(SCANNER_LITERAL_POOL_CAN_EVAL | SCANNER_LITERAL_POOL_HAS_SUPER_REFERENCE);
}
} /* scanner_detect_eval_call */
#if JERRY_ESNEXT
/**
* Throws an error for invalid var statements.
*/
@@ -2005,8 +1903,6 @@ scanner_append_hole (parser_context_t *context_p, scanner_context_t *scanner_con
literal_p->status_flags = LEXER_LIT_LOCATION_NO_OPTS;
} /* scanner_append_hole */
#endif /* JERRY_ESNEXT */
/**
* Reverse the scanner info chain after the scanning is completed.
*/
@@ -2071,15 +1967,11 @@ scanner_cleanup (parser_context_t *context_p) /**< context */
}
case SCANNER_TYPE_WHILE:
case SCANNER_TYPE_FOR_IN:
#if JERRY_ESNEXT
case SCANNER_TYPE_FOR_OF:
#endif /* JERRY_ESNEXT */
case SCANNER_TYPE_CASE:
#if JERRY_ESNEXT
case SCANNER_TYPE_INITIALIZER:
case SCANNER_TYPE_CLASS_FIELD_INITIALIZER_END:
case SCANNER_TYPE_CLASS_STATIC_BLOCK_END:
#endif /* JERRY_ESNEXT */
{
size = sizeof (scanner_location_info_t);
break;
@@ -2095,25 +1987,19 @@ scanner_cleanup (parser_context_t *context_p) /**< context */
size = sizeof (scanner_switch_info_t);
break;
}
#if JERRY_ESNEXT
case SCANNER_TYPE_CLASS_CONSTRUCTOR:
{
scanner_release_private_fields (((scanner_class_info_t *) scanner_info_p)->members);
size = sizeof (scanner_class_info_t);
break;
}
#endif /* JERRY_ESNEXT */
default:
{
#if JERRY_ESNEXT
JERRY_ASSERT (
scanner_info_p->type == SCANNER_TYPE_END_ARGUMENTS || scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS
|| scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION || scanner_info_p->type == SCANNER_TYPE_ERR_REDECLARED
|| scanner_info_p->type == SCANNER_TYPE_ERR_ASYNC_FUNCTION
|| scanner_info_p->type == SCANNER_TYPE_EXPORT_MODULE_SPECIFIER);
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (scanner_info_p->type == SCANNER_TYPE_END_ARGUMENTS);
#endif /* JERRY_ESNEXT */
break;
}
}
@@ -2141,24 +2027,15 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
JERRY_UNUSED (check_type);
#if JERRY_ESNEXT
JERRY_ASSERT ((check_type == PARSER_CHECK_BLOCK_CONTEXT ? info_p->type == SCANNER_TYPE_BLOCK
: info_p->type == SCANNER_TYPE_FUNCTION));
uint32_t scope_stack_reg_top =
(check_type != PARSER_CHECK_GLOBAL_CONTEXT ? context_p->scope_stack_reg_top : 1); /* block result */
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (check_type == PARSER_CHECK_BLOCK_CONTEXT);
JERRY_ASSERT (info_p->type == SCANNER_TYPE_BLOCK);
uint32_t scope_stack_reg_top = context_p->scope_stack_reg_top;
#endif /* !JERRY_NDEBUG */
while (data_p[0] != SCANNER_STREAM_TYPE_END)
{
uint8_t data = data_p[0];
#if JERRY_ESNEXT
uint32_t type = data & SCANNER_STREAM_TYPE_MASK;
if (JERRY_UNLIKELY (check_type == PARSER_CHECK_FUNCTION_CONTEXT))
@@ -2219,11 +2096,6 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|| type == SCANNER_STREAM_TYPE_FUNC);
}
#endif /* !JERRY_NDEBUG */
#else /* !JERRY_ESNEXT */
JERRY_ASSERT ((data & SCANNER_STREAM_TYPE_MASK) == SCANNER_STREAM_TYPE_VAR);
#endif /* JERRY_ESNEXT */
if (!(data & SCANNER_STREAM_UINT16_DIFF))
{
if (data_p[2] != 0)
@@ -2240,7 +2112,6 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
data_p += 2 + 2;
}
#if JERRY_ESNEXT
#if JERRY_MODULE_SYSTEM
const bool is_import = (type == SCANNER_STREAM_TYPE_IMPORT);
#else /* !JERRY_MODULE_SYSTEM */
@@ -2275,7 +2146,6 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
continue;
}
}
#endif /* JERRY_ESNEXT */
if ((data & SCANNER_STREAM_NO_REG) || scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
{
@@ -2288,8 +2158,6 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
return false;
} /* scanner_is_context_needed */
#if JERRY_ESNEXT
/**
* Try to scan/parse the ".target" part in the "new.target" expression.
*
@@ -2326,8 +2194,6 @@ scanner_try_scan_new_target (parser_context_t *context_p) /**< parser/scanner co
return false;
} /* scanner_try_scan_new_target */
#endif /* JERRY_ESNEXT */
/**
* Description of "arguments" literal string.
*/
@@ -2356,7 +2222,6 @@ scanner_create_unused_literal (parser_context_t *context_p, /**< context */
context_p->literal_count++;
} /* scanner_create_unused_literal */
#if JERRY_ESNEXT
/**
* Emit checks for redeclared bindings in the global lexical scope.
*/
@@ -2438,7 +2303,6 @@ scanner_check_variables (parser_context_t *context_p) /**< context */
parser_flush_cbc (context_p);
} /* scanner_check_variables */
#endif /* JERRY_ESNEXT */
/**
* Create and/or initialize var/let/const/function/etc. variables.
@@ -2560,10 +2424,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
map_to = (uint16_t) (PARSER_REGISTER_START + scope_stack_reg_top);
#if JERRY_ESNEXT
scope_stack_p->map_to = (uint16_t) (scope_stack_reg_top + 1);
#endif /* JERRY_ESNEXT */
scope_stack_reg_top++;
}
else
@@ -2573,19 +2434,14 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
#if JERRY_ESNEXT
if (data_p[0] & SCANNER_STREAM_LOCAL_ARGUMENTS)
{
context_p->status_flags |= PARSER_LEXICAL_BLOCK_NEEDED;
}
scope_stack_p->map_to = 0;
#endif /* JERRY_ESNEXT */
}
#if !JERRY_ESNEXT
scope_stack_p->map_to = map_to;
#endif /* !JERRY_ESNEXT */
scope_stack_p++;
#if JERRY_PARSER_DUMP_BYTE_CODE
@@ -2594,7 +2450,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
parser_emit_cbc_ext_literal (context_p, CBC_EXT_CREATE_ARGUMENTS, map_to);
#if JERRY_ESNEXT
if (type == SCANNER_STREAM_TYPE_ARGUMENTS_FUNC)
{
if (JERRY_UNLIKELY (scope_stack_p >= scope_stack_end_p))
@@ -2609,7 +2464,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
scanner_create_unused_literal (context_p, 0);
}
#endif /* JERRY_ESNEXT */
if (option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_ARGS)
{
@@ -2650,7 +2504,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
if (option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_BODY)
{
#if JERRY_ESNEXT
if ((context_p->status_flags & PARSER_LEXICAL_BLOCK_NEEDED)
&& (type == SCANNER_STREAM_TYPE_ARG_VAR || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR))
{
@@ -2667,7 +2520,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
parser_emit_cbc_ext_literal_from_token (context_p, CBC_EXT_COPY_FROM_ARG);
}
}
#endif /* JERRY_ESNEXT */
literal.char_p += data_p[1];
continue;
@@ -2691,9 +2543,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
JERRY_ASSERT (scope_stack_p >= context_p->scope_stack_p + 2);
JERRY_ASSERT (context_p->status_flags & PARSER_IS_FUNCTION);
#if JERRY_ESNEXT
JERRY_ASSERT (!(context_p->status_flags & PARSER_FUNCTION_IS_PARSING_ARGS));
#endif /* JERRY_ESNEXT */
parser_scope_stack_t *function_map_p = scope_stack_p - 2;
uint16_t literal_index = context_p->lit_object.index;
@@ -2709,13 +2559,11 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
cbc_opcode_t opcode = CBC_SET_VAR_FUNC;
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (context_p->status_flags & PARSER_LEXICAL_BLOCK_NEEDED)
&& (function_map_p[0].map_to & PARSER_SCOPE_STACK_REGISTER_MASK) == 0)
{
opcode = CBC_INIT_ARG_OR_FUNC;
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc_literal_value (context_p,
(uint16_t) opcode,
@@ -2732,7 +2580,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
scope_stack_p->map_from = context_p->lit_object.index;
#if JERRY_ESNEXT
if (info_type == SCANNER_TYPE_FUNCTION)
{
if (type != SCANNER_STREAM_TYPE_LET
@@ -2744,7 +2591,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_GLOBAL;
}
}
#endif /* JERRY_ESNEXT */
uint16_t map_to;
uint16_t func_init_opcode = CBC_INIT_ARG_OR_FUNC;
@@ -2752,15 +2598,9 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
if (!(data_p[0] & SCANNER_STREAM_NO_REG) && scope_stack_reg_top < PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
{
map_to = (uint16_t) (PARSER_REGISTER_START + scope_stack_reg_top);
#if JERRY_ESNEXT
scope_stack_p->map_to = (uint16_t) (scope_stack_reg_top + 1);
#else /* !JERRY_ESNEXT */
scope_stack_p->map_to = map_to;
#endif /* JERRY_ESNEXT */
scope_stack_reg_top++;
#if JERRY_ESNEXT
switch (type)
{
case SCANNER_STREAM_TYPE_CONST:
@@ -2782,18 +2622,13 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
}
func_init_opcode = CBC_SET_VAR_FUNC;
#endif /* JERRY_ESNEXT */
}
else
{
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_USED;
map_to = context_p->lit_object.index;
#if JERRY_ESNEXT
uint16_t scope_stack_map_to = 0;
#else /* !JERRY_ESNEXT */
scope_stack_p->map_to = map_to;
#endif /* JERRY_ESNEXT */
if (info_type == SCANNER_TYPE_FUNCTION)
{
@@ -2802,7 +2637,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
switch (type)
{
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_LET:
case SCANNER_STREAM_TYPE_CONST:
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG:
@@ -2819,14 +2653,11 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
/* FALLTHRU */
}
case SCANNER_STREAM_TYPE_LOCAL:
#endif /* JERRY_ESNEXT */
case SCANNER_STREAM_TYPE_VAR:
{
#if JERRY_PARSER_DUMP_BYTE_CODE
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
#if JERRY_ESNEXT
uint16_t opcode;
switch (type)
@@ -2867,43 +2698,34 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
break;
}
}
#else /* !JERRY_ESNEXT */
uint16_t opcode = ((option_flags & SCANNER_CREATE_VARS_IS_SCRIPT) ? CBC_CREATE_VAR_EVAL : CBC_CREATE_VAR);
#endif /* JERRY_ESNEXT */
parser_emit_cbc_literal (context_p, opcode, map_to);
break;
}
case SCANNER_STREAM_TYPE_ARG:
#if JERRY_ESNEXT
case SCANNER_STREAM_TYPE_ARG_VAR:
#endif /* JERRY_ESNEXT */
case SCANNER_STREAM_TYPE_ARG_FUNC:
{
#if JERRY_PARSER_DUMP_BYTE_CODE
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
#if JERRY_ESNEXT
scope_stack_map_to |= PARSER_SCOPE_STACK_NO_FUNCTION_COPY;
/* Argument initializers of functions with simple arguments (e.g. function f(a,b,a) {}) are
* generated here. The other initializers are handled by parser_parse_function_arguments(). */
if (!(info_u8_arg & SCANNER_FUNCTION_HAS_COMPLEX_ARGUMENT))
{
#endif /* JERRY_ESNEXT */
parser_emit_cbc_literal_value (context_p,
CBC_INIT_ARG_OR_FUNC,
(uint16_t) (PARSER_REGISTER_START + scope_stack_reg_top),
map_to);
#if JERRY_ESNEXT
}
else if (data_p[0] & SCANNER_STREAM_EARLY_CREATE)
{
parser_emit_cbc_literal (context_p, CBC_CREATE_LOCAL, map_to);
scope_stack_map_to |= PARSER_SCOPE_STACK_IS_LOCAL_CREATED;
}
#endif /* JERRY_ESNEXT */
if (scope_stack_reg_top < PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
{
@@ -2913,9 +2735,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
}
}
#if JERRY_ESNEXT
scope_stack_p->map_to = scope_stack_map_to;
#endif /* JERRY_ESNEXT */
}
scope_stack_p++;
@@ -2939,7 +2759,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
if (func_init_opcode == CBC_INIT_ARG_OR_FUNC && (option_flags & SCANNER_CREATE_VARS_IS_SCRIPT))
{
#if JERRY_ESNEXT
literal.char_p -= data_p[1];
if (!scanner_scope_find_lexical_declaration (context_p, &literal))
@@ -2952,9 +2771,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
}
}
literal.char_p += data_p[1];
#else /* !JERRY_ESNEXT */
func_init_opcode = CBC_CREATE_VAR_FUNC_EVAL;
#endif /* JERRY_ESNEXT */
}
parser_emit_cbc_literal_value (context_p, func_init_opcode, context_p->literal_count, map_to);
@@ -2970,12 +2786,10 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
context_p->scope_stack_reg_top = (uint16_t) scope_stack_reg_top;
#if JERRY_ESNEXT
if (info_type == SCANNER_TYPE_FUNCTION)
{
context_p->scope_stack_global_end = context_p->scope_stack_top;
}
#endif /* JERRY_ESNEXT */
if (context_p->register_count < scope_stack_reg_top)
{
@@ -3021,16 +2835,10 @@ scanner_decode_map_to (parser_scope_stack_t *stack_item_p) /**< scope stack item
{
JERRY_ASSERT (stack_item_p->map_from != PARSER_SCOPE_STACK_FUNC);
#if JERRY_ESNEXT
uint16_t value = (stack_item_p->map_to & PARSER_SCOPE_STACK_REGISTER_MASK);
return (value == 0) ? stack_item_p->map_from : (uint16_t) (value + (PARSER_REGISTER_START - 1));
#else /* !JERRY_ESNEXT */
return stack_item_p->map_to;
#endif /* JERRY_ESNEXT */
} /* scanner_decode_map_to */
#if JERRY_ESNEXT
/**
* Find the given literal index in the scope stack
* and save it the constant literal pool if the literal is register stored
@@ -3142,8 +2950,6 @@ scanner_literal_exists (parser_context_t *context_p, /**< context */
return false;
} /* scanner_literal_exists */
#endif /* JERRY_ESNEXT */
/**
* @}
* @}