Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "js-parser-internal.h"
|
||||
#include "js-scanner-internal.h"
|
||||
@@ -40,11 +41,9 @@ JERRY_STATIC_ASSERT (PARSER_MAXIMUM_NUMBER_OF_LITERALS + PARSER_MAXIMUM_NUMBER_O
|
||||
JERRY_STATIC_ASSERT ((SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG & SCANNER_LITERAL_IS_LOCAL) == 0,
|
||||
is_arrow_arg_binding_flag_must_not_use_local_flags);
|
||||
|
||||
JERRY_STATIC_ASSERT ((SCANNER_LITERAL_IS_LET & SCANNER_LITERAL_IS_LOCAL) != 0,
|
||||
is_let_flag_must_use_local_flags);
|
||||
JERRY_STATIC_ASSERT ((SCANNER_LITERAL_IS_LET & SCANNER_LITERAL_IS_LOCAL) != 0, is_let_flag_must_use_local_flags);
|
||||
|
||||
JERRY_STATIC_ASSERT ((SCANNER_LITERAL_IS_CONST & SCANNER_LITERAL_IS_LOCAL) != 0,
|
||||
is_const_flag_must_use_local_flags);
|
||||
JERRY_STATIC_ASSERT ((SCANNER_LITERAL_IS_CONST & SCANNER_LITERAL_IS_LOCAL) != 0, is_const_flag_must_use_local_flags);
|
||||
|
||||
JERRY_STATIC_ASSERT ((SCANNER_LITERAL_IS_FUNC_DECLARATION & SCANNER_LITERAL_IS_LOCAL) != 0,
|
||||
is_func_declaration_flag_must_use_local_flags);
|
||||
@@ -400,8 +399,7 @@ scanner_scope_find_lexical_declaration (parser_context_t *context_p, /**< contex
|
||||
ecma_string_t *name_p;
|
||||
uint32_t flags = context_p->global_status_flags;
|
||||
|
||||
if (!(flags & ECMA_PARSE_EVAL)
|
||||
|| (!(flags & ECMA_PARSE_DIRECT_EVAL) && (context_p->status_flags & PARSER_IS_STRICT)))
|
||||
if (!(flags & ECMA_PARSE_EVAL) || (!(flags & ECMA_PARSE_DIRECT_EVAL) && (context_p->status_flags & PARSER_IS_STRICT)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -487,9 +485,8 @@ scanner_push_literal_pool (parser_context_t *context_p, /**< context */
|
||||
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);
|
||||
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 */
|
||||
@@ -535,8 +532,7 @@ scanner_push_literal_pool (parser_context_t *context_p, /**< context */
|
||||
return literal_pool_p;
|
||||
} /* scanner_push_literal_pool */
|
||||
|
||||
JERRY_STATIC_ASSERT (PARSER_MAXIMUM_IDENT_LENGTH <= UINT8_MAX,
|
||||
maximum_ident_length_must_fit_in_a_byte);
|
||||
JERRY_STATIC_ASSERT (PARSER_MAXIMUM_IDENT_LENGTH <= UINT8_MAX, maximum_ident_length_must_fit_in_a_byte);
|
||||
|
||||
/**
|
||||
* Checks whether a literal is equal to "arguments".
|
||||
@@ -782,8 +778,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
|| ((type & (SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_ARG))
|
||||
&& (status_flags & SCANNER_LITERAL_POOL_FUNCTION)))
|
||||
{
|
||||
JERRY_ASSERT ((status_flags & SCANNER_LITERAL_POOL_FUNCTION)
|
||||
|| !(literal_p->type & SCANNER_LITERAL_IS_ARG));
|
||||
JERRY_ASSERT ((status_flags & SCANNER_LITERAL_POOL_FUNCTION) || !(literal_p->type & SCANNER_LITERAL_IS_ARG));
|
||||
|
||||
if (literal_p->length == 0)
|
||||
{
|
||||
@@ -852,9 +847,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
if (prev_literal_pool_p != NULL && literal_p->length > 0)
|
||||
{
|
||||
/* Propagate literal to upper level. */
|
||||
lexer_lit_location_t *literal_location_p = scanner_add_custom_literal (context_p,
|
||||
prev_literal_pool_p,
|
||||
literal_p);
|
||||
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
|
||||
@@ -878,8 +871,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
|
||||
const uint8_t mask = (SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_IS_LOCAL);
|
||||
|
||||
if ((type & SCANNER_LITERAL_IS_ARG)
|
||||
|| (literal_location_p->type & mask) == SCANNER_LITERAL_IS_LET
|
||||
if ((type & SCANNER_LITERAL_IS_ARG) || (literal_location_p->type & mask) == SCANNER_LITERAL_IS_LET
|
||||
|| (literal_location_p->type & mask) == SCANNER_LITERAL_IS_CONST)
|
||||
{
|
||||
/* Clears the SCANNER_LITERAL_IS_VAR and SCANNER_LITERAL_IS_FUNC flags
|
||||
@@ -1071,8 +1063,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
type = (uint8_t) (type + 1);
|
||||
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_ARG_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR);
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_ARG_VAR || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR);
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
}
|
||||
@@ -1263,9 +1254,8 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
|
||||
uint8_t type = literal_p->type;
|
||||
const uint8_t mask = (SCANNER_LITERAL_IS_ARG
|
||||
| SCANNER_LITERAL_IS_DESTRUCTURED_ARG
|
||||
| SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG);
|
||||
const uint8_t mask =
|
||||
(SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_IS_DESTRUCTURED_ARG | SCANNER_LITERAL_IS_ARROW_DESTRUCTURED_ARG);
|
||||
|
||||
if ((type & mask) != SCANNER_LITERAL_IS_ARG)
|
||||
{
|
||||
@@ -1333,9 +1323,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */
|
||||
else if (prev_literal_pool_p != NULL)
|
||||
{
|
||||
/* Propagate literal to upper level. */
|
||||
lexer_lit_location_t *literal_location_p = scanner_add_custom_literal (context_p,
|
||||
prev_literal_pool_p,
|
||||
literal_p);
|
||||
lexer_lit_location_t *literal_location_p = scanner_add_custom_literal (context_p, prev_literal_pool_p, literal_p);
|
||||
type |= SCANNER_LITERAL_NO_REG | SCANNER_LITERAL_IS_USED;
|
||||
literal_location_p->type |= type;
|
||||
}
|
||||
@@ -1441,7 +1429,7 @@ scanner_add_custom_literal (parser_context_t *context_p, /**< context */
|
||||
*
|
||||
* @return pointer to the literal
|
||||
*/
|
||||
extern inline lexer_lit_location_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline lexer_lit_location_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
scanner_add_literal (parser_context_t *context_p, /**< context */
|
||||
scanner_context_t *scanner_context_p) /**< scanner context */
|
||||
{
|
||||
@@ -1460,9 +1448,8 @@ extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
scanner_add_reference (parser_context_t *context_p, /**< context */
|
||||
scanner_context_t *scanner_context_p) /**< scanner 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);
|
||||
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 */
|
||||
@@ -1555,8 +1542,7 @@ void
|
||||
scanner_detect_eval_call (parser_context_t *context_p, /**< context */
|
||||
scanner_context_t *scanner_context_p) /**< scanner context */
|
||||
{
|
||||
if (context_p->token.keyword_type == LEXER_KEYW_EVAL
|
||||
&& lexer_check_next_character (context_p, LIT_CHAR_LEFT_PAREN))
|
||||
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);
|
||||
@@ -1608,12 +1594,10 @@ scanner_detect_invalid_var (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
|
||||
{
|
||||
if ((literal_p->type & SCANNER_LITERAL_IS_LOCAL)
|
||||
&& !(literal_p->type & SCANNER_LITERAL_IS_ARG)
|
||||
if ((literal_p->type & SCANNER_LITERAL_IS_LOCAL) && !(literal_p->type & SCANNER_LITERAL_IS_ARG)
|
||||
&& !((literal_p->type & SCANNER_LITERAL_IS_FUNC)
|
||||
&& (literal_pool_p->status_flags & SCANNER_LITERAL_POOL_FUNCTION))
|
||||
&& (literal_p->type & SCANNER_LITERAL_IS_LOCAL) != SCANNER_LITERAL_IS_LOCAL
|
||||
&& literal_p->length == length)
|
||||
&& (literal_p->type & SCANNER_LITERAL_IS_LOCAL) != SCANNER_LITERAL_IS_LOCAL && literal_p->length == length)
|
||||
{
|
||||
if (JERRY_LIKELY (!(literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)))
|
||||
{
|
||||
@@ -1635,8 +1619,7 @@ scanner_detect_invalid_var (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
|
||||
{
|
||||
if ((literal_p->type & SCANNER_LITERAL_IS_LOCAL)
|
||||
&& !(literal_p->type & SCANNER_LITERAL_IS_ARG)
|
||||
if ((literal_p->type & SCANNER_LITERAL_IS_LOCAL) && !(literal_p->type & SCANNER_LITERAL_IS_ARG)
|
||||
&& !((literal_p->type & SCANNER_LITERAL_IS_FUNC)
|
||||
&& (literal_pool_p->status_flags & SCANNER_LITERAL_POOL_FUNCTION))
|
||||
&& (literal_p->type & SCANNER_LITERAL_IS_LOCAL) != SCANNER_LITERAL_IS_LOCAL
|
||||
@@ -1662,9 +1645,7 @@ void
|
||||
scanner_detect_invalid_let (parser_context_t *context_p, /**< context */
|
||||
lexer_lit_location_t *let_literal_p) /**< let literal */
|
||||
{
|
||||
if (let_literal_p->type & (SCANNER_LITERAL_IS_ARG
|
||||
| SCANNER_LITERAL_IS_VAR
|
||||
| SCANNER_LITERAL_IS_LOCAL))
|
||||
if (let_literal_p->type & (SCANNER_LITERAL_IS_ARG | SCANNER_LITERAL_IS_VAR | SCANNER_LITERAL_IS_LOCAL))
|
||||
{
|
||||
scanner_raise_redeclaration_error (context_p);
|
||||
}
|
||||
@@ -1698,8 +1679,8 @@ scanner_push_class_declaration (parser_context_t *context_p, /**< context */
|
||||
parser_stack_push_uint8 (context_p, stack_mode);
|
||||
lexer_next_token (context_p);
|
||||
|
||||
bool class_has_name = (context_p->token.type == LEXER_LITERAL
|
||||
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
|
||||
bool class_has_name =
|
||||
(context_p->token.type == LEXER_LITERAL && context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
|
||||
|
||||
if (class_has_name)
|
||||
{
|
||||
@@ -1737,9 +1718,8 @@ scanner_push_class_declaration (parser_context_t *context_p, /**< context */
|
||||
else if (is_export_default)
|
||||
{
|
||||
lexer_lit_location_t *name_literal_p;
|
||||
name_literal_p = scanner_add_custom_literal (context_p,
|
||||
scanner_context_p->active_literal_pool_p->prev_p,
|
||||
&lexer_default_literal);
|
||||
name_literal_p =
|
||||
scanner_add_custom_literal (context_p, scanner_context_p->active_literal_pool_p->prev_p, &lexer_default_literal);
|
||||
|
||||
name_literal_p->type |= SCANNER_LITERAL_IS_LET | SCANNER_LITERAL_NO_REG;
|
||||
scanner_context_p->active_literal_pool_p->no_declarations++;
|
||||
@@ -1889,8 +1869,7 @@ scanner_reverse_info_list (parser_context_t *context_p) /**< context */
|
||||
|
||||
last_scanner_info_p = scanner_info_p;
|
||||
scanner_info_p = next_scanner_info_p;
|
||||
}
|
||||
while (scanner_info_p->type != SCANNER_TYPE_END);
|
||||
} while (scanner_info_p->type != SCANNER_TYPE_END);
|
||||
|
||||
context_p->next_scanner_info_p->next_p = scanner_info_p;
|
||||
context_p->next_scanner_info_p = last_scanner_info_p;
|
||||
@@ -1959,13 +1938,12 @@ scanner_cleanup (parser_context_t *context_p) /**< context */
|
||||
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_CLASS_CONSTRUCTOR
|
||||
|| 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);
|
||||
JERRY_ASSERT (
|
||||
scanner_info_p->type == SCANNER_TYPE_END_ARGUMENTS || scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS
|
||||
|| scanner_info_p->type == SCANNER_TYPE_CLASS_CONSTRUCTOR
|
||||
|| 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 */
|
||||
@@ -2000,8 +1978,8 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
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 */
|
||||
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);
|
||||
@@ -2026,8 +2004,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (JERRY_UNLIKELY (SCANNER_STREAM_TYPE_IS_ARGUMENTS (type)))
|
||||
{
|
||||
if ((data & SCANNER_STREAM_NO_REG)
|
||||
|| scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
if ((data & SCANNER_STREAM_NO_REG) || scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2041,48 +2018,37 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
#ifndef JERRY_NDEBUG
|
||||
if (check_type == PARSER_CHECK_BLOCK_CONTEXT)
|
||||
{
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_LET
|
||||
|| type == SCANNER_STREAM_TYPE_CONST
|
||||
|| type == SCANNER_STREAM_TYPE_LOCAL
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_VAR || type == SCANNER_STREAM_TYPE_LET
|
||||
|| type == SCANNER_STREAM_TYPE_CONST || type == SCANNER_STREAM_TYPE_LOCAL
|
||||
|| type == SCANNER_STREAM_TYPE_FUNC);
|
||||
}
|
||||
else if (check_type == PARSER_CHECK_GLOBAL_CONTEXT)
|
||||
{
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
const bool is_import = (type == SCANNER_STREAM_TYPE_IMPORT);
|
||||
#else
|
||||
#else /* !JERRY_MODULE_SYSTEM */
|
||||
const bool is_import = true;
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/* FIXME: a private declarative lexical environment should always be present
|
||||
* for modules. Remove SCANNER_STREAM_TYPE_IMPORT after it is implemented. */
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_LET
|
||||
|| type == SCANNER_STREAM_TYPE_CONST
|
||||
|| type == SCANNER_STREAM_TYPE_FUNC
|
||||
|| is_import);
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_VAR || type == SCANNER_STREAM_TYPE_LET
|
||||
|| type == SCANNER_STREAM_TYPE_CONST || type == SCANNER_STREAM_TYPE_FUNC || is_import);
|
||||
|
||||
/* Only let/const can be stored in registers */
|
||||
JERRY_ASSERT ((data & SCANNER_STREAM_NO_REG)
|
||||
|| (type == SCANNER_STREAM_TYPE_FUNC && (context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL))
|
||||
|| type == SCANNER_STREAM_TYPE_LET
|
||||
|| type == SCANNER_STREAM_TYPE_CONST);
|
||||
|| type == SCANNER_STREAM_TYPE_LET || type == SCANNER_STREAM_TYPE_CONST);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (check_type == PARSER_CHECK_FUNCTION_CONTEXT);
|
||||
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_LET
|
||||
|| type == SCANNER_STREAM_TYPE_CONST
|
||||
|| type == SCANNER_STREAM_TYPE_LOCAL
|
||||
|| type == SCANNER_STREAM_TYPE_ARG
|
||||
|| type == SCANNER_STREAM_TYPE_ARG_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_ARG_FUNC
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_VAR || type == SCANNER_STREAM_TYPE_LET
|
||||
|| type == SCANNER_STREAM_TYPE_CONST || type == SCANNER_STREAM_TYPE_LOCAL
|
||||
|| type == SCANNER_STREAM_TYPE_ARG || type == SCANNER_STREAM_TYPE_ARG_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_ARG_FUNC || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC
|
||||
|| type == SCANNER_STREAM_TYPE_FUNC);
|
||||
}
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@@ -2116,24 +2082,21 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (JERRY_UNLIKELY (check_type == PARSER_CHECK_GLOBAL_CONTEXT)
|
||||
&& (type == SCANNER_STREAM_TYPE_VAR
|
||||
|| (type == SCANNER_STREAM_TYPE_FUNC && !(context_p->global_status_flags & ECMA_PARSE_EVAL))
|
||||
|| is_import))
|
||||
|| (type == SCANNER_STREAM_TYPE_FUNC && !(context_p->global_status_flags & ECMA_PARSE_EVAL)) || is_import))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (JERRY_UNLIKELY (check_type == PARSER_CHECK_FUNCTION_CONTEXT))
|
||||
{
|
||||
if (SCANNER_STREAM_TYPE_IS_ARG_FUNC (type)
|
||||
|| type == SCANNER_STREAM_TYPE_ARG_VAR
|
||||
if (SCANNER_STREAM_TYPE_IS_ARG_FUNC (type) || type == SCANNER_STREAM_TYPE_ARG_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR)
|
||||
{
|
||||
/* The return value is true, if the variable is stored in the lexical environment
|
||||
* or all registers have already been used for function arguments. This can be
|
||||
* inprecise in the latter case, but this is a very rare corner case. A more
|
||||
* sophisticated check would require to decode the literal. */
|
||||
if ((data & SCANNER_STREAM_NO_REG)
|
||||
|| scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
if ((data & SCANNER_STREAM_NO_REG) || scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2147,8 +2110,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
if ((data & SCANNER_STREAM_NO_REG)
|
||||
|| scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
if ((data & SCANNER_STREAM_NO_REG) || scope_stack_reg_top >= PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2202,10 +2164,10 @@ scanner_try_scan_new_target (parser_context_t *context_p) /**< parser/scanner co
|
||||
/**
|
||||
* Description of "arguments" literal string.
|
||||
*/
|
||||
const lexer_lit_location_t lexer_arguments_literal =
|
||||
{
|
||||
(const uint8_t *) "arguments", 9, LEXER_IDENT_LITERAL, LEXER_LIT_LOCATION_IS_ASCII
|
||||
};
|
||||
const lexer_lit_location_t lexer_arguments_literal = { (const uint8_t *) "arguments",
|
||||
9,
|
||||
LEXER_IDENT_LITERAL,
|
||||
LEXER_LIT_LOCATION_IS_ASCII };
|
||||
|
||||
/**
|
||||
* Create an unused literal.
|
||||
@@ -2247,8 +2209,7 @@ scanner_check_variables (parser_context_t *context_p) /**< context */
|
||||
uint32_t type = next_data_p[0] & SCANNER_STREAM_TYPE_MASK;
|
||||
const uint8_t *data_p = next_data_p;
|
||||
|
||||
JERRY_ASSERT (type != SCANNER_STREAM_TYPE_HOLE
|
||||
&& !SCANNER_STREAM_TYPE_IS_ARG (type)
|
||||
JERRY_ASSERT (type != SCANNER_STREAM_TYPE_HOLE && !SCANNER_STREAM_TYPE_IS_ARG (type)
|
||||
&& !SCANNER_STREAM_TYPE_IS_ARG_FUNC (type));
|
||||
JERRY_ASSERT (data_p[0] & SCANNER_STREAM_NO_REG);
|
||||
|
||||
@@ -2280,8 +2241,8 @@ scanner_check_variables (parser_context_t *context_p) /**< context */
|
||||
|
||||
literal.length = data_p[1];
|
||||
literal.type = LEXER_IDENT_LITERAL;
|
||||
literal.status_flags = ((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE
|
||||
: LEXER_LIT_LOCATION_NO_OPTS);
|
||||
literal.status_flags =
|
||||
((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE : LEXER_LIT_LOCATION_NO_OPTS);
|
||||
|
||||
lexer_construct_literal_object (context_p, &literal, LEXER_NEW_IDENT_LITERAL);
|
||||
literal.char_p += data_p[1];
|
||||
@@ -2374,8 +2335,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
const uint8_t *data_p = next_data_p;
|
||||
|
||||
JERRY_ASSERT ((option_flags & (SCANNER_CREATE_VARS_IS_FUNCTION_BODY | SCANNER_CREATE_VARS_IS_FUNCTION_ARGS))
|
||||
|| (type != SCANNER_STREAM_TYPE_HOLE
|
||||
&& !SCANNER_STREAM_TYPE_IS_ARG (type)
|
||||
|| (type != SCANNER_STREAM_TYPE_HOLE && !SCANNER_STREAM_TYPE_IS_ARG (type)
|
||||
&& !SCANNER_STREAM_TYPE_IS_ARG_FUNC (type)));
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
@@ -2394,8 +2354,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
|
||||
uint8_t mask = SCANNER_FUNCTION_ARGUMENTS_NEEDED | SCANNER_FUNCTION_HAS_COMPLEX_ARGUMENT;
|
||||
|
||||
if (!(context_p->status_flags & PARSER_IS_STRICT)
|
||||
&& (info_u8_arg & mask) == SCANNER_FUNCTION_ARGUMENTS_NEEDED)
|
||||
if (!(context_p->status_flags & PARSER_IS_STRICT) && (info_u8_arg & mask) == SCANNER_FUNCTION_ARGUMENTS_NEEDED)
|
||||
{
|
||||
scanner_create_unused_literal (context_p, LEXER_FLAG_FUNCTION_ARGUMENT);
|
||||
}
|
||||
@@ -2430,8 +2389,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
|
||||
uint16_t map_to;
|
||||
|
||||
if (!(data_p[0] & SCANNER_STREAM_NO_REG)
|
||||
&& scope_stack_reg_top < PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
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);
|
||||
|
||||
@@ -2531,8 +2489,8 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
literal.length = data_p[1];
|
||||
literal.type = LEXER_IDENT_LITERAL;
|
||||
literal.status_flags = ((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE
|
||||
: LEXER_LIT_LOCATION_NO_OPTS);
|
||||
literal.status_flags =
|
||||
((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE : LEXER_LIT_LOCATION_NO_OPTS);
|
||||
|
||||
/* Literal must be exists. */
|
||||
lexer_construct_literal_object (context_p, &literal, LEXER_IDENT_LITERAL);
|
||||
@@ -2548,8 +2506,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if ((option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_ARGS)
|
||||
&& !SCANNER_STREAM_TYPE_IS_ARG_FUNC (type))
|
||||
else if ((option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_ARGS) && !SCANNER_STREAM_TYPE_IS_ARG_FUNC (type))
|
||||
{
|
||||
/* Function arguments must come first. */
|
||||
break;
|
||||
@@ -2557,8 +2514,8 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
|
||||
literal.length = data_p[1];
|
||||
literal.type = LEXER_IDENT_LITERAL;
|
||||
literal.status_flags = ((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE
|
||||
: LEXER_LIT_LOCATION_NO_OPTS);
|
||||
literal.status_flags =
|
||||
((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE : LEXER_LIT_LOCATION_NO_OPTS);
|
||||
|
||||
lexer_construct_literal_object (context_p, &literal, LEXER_NEW_IDENT_LITERAL);
|
||||
literal.char_p += data_p[1];
|
||||
@@ -2625,8 +2582,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
uint16_t map_to;
|
||||
uint16_t func_init_opcode = CBC_INIT_ARG_OR_FUNC;
|
||||
|
||||
if (!(data_p[0] & SCANNER_STREAM_NO_REG)
|
||||
&& scope_stack_reg_top < PARSER_MAXIMUM_NUMBER_OF_REGISTERS)
|
||||
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);
|
||||
|
||||
@@ -2736,8 +2692,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_LOCAL
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG
|
||||
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_LOCAL || type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_VAR
|
||||
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC);
|
||||
|
||||
@@ -2746,8 +2701,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
}
|
||||
#else /* !JERRY_ESNEXT */
|
||||
uint16_t opcode = ((option_flags & SCANNER_CREATE_VARS_IS_SCRIPT) ? CBC_CREATE_VAR_EVAL
|
||||
: CBC_CREATE_VAR);
|
||||
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);
|
||||
@@ -2932,9 +2886,8 @@ scanner_save_literal (parser_context_t *context_p, /**< context */
|
||||
/* Registers must be found in the scope stack. */
|
||||
JERRY_ASSERT (scope_stack_p > context_p->scope_stack_p);
|
||||
scope_stack_p--;
|
||||
}
|
||||
while (scope_stack_p->map_from == PARSER_SCOPE_STACK_FUNC
|
||||
|| literal_index != (scope_stack_p->map_to & PARSER_SCOPE_STACK_REGISTER_MASK));
|
||||
} while (scope_stack_p->map_from == PARSER_SCOPE_STACK_FUNC
|
||||
|| literal_index != (scope_stack_p->map_to & PARSER_SCOPE_STACK_REGISTER_MASK));
|
||||
|
||||
literal_index = scope_stack_p->map_from;
|
||||
PARSER_GET_LITERAL (literal_index)->status_flags |= LEXER_FLAG_USED;
|
||||
@@ -2967,9 +2920,8 @@ scanner_literal_is_const_reg (parser_context_t *context_p, /**< context */
|
||||
/* Registers must be found in the scope stack. */
|
||||
JERRY_ASSERT (scope_stack_p > context_p->scope_stack_p);
|
||||
scope_stack_p--;
|
||||
}
|
||||
while (scope_stack_p->map_from == PARSER_SCOPE_STACK_FUNC
|
||||
|| literal_index != (scope_stack_p->map_to & PARSER_SCOPE_STACK_REGISTER_MASK));
|
||||
} while (scope_stack_p->map_from == PARSER_SCOPE_STACK_FUNC
|
||||
|| literal_index != (scope_stack_p->map_to & PARSER_SCOPE_STACK_REGISTER_MASK));
|
||||
|
||||
return (scope_stack_p->map_to & PARSER_SCOPE_STACK_IS_CONST_REG) != 0;
|
||||
} /* scanner_literal_is_const_reg */
|
||||
@@ -2992,8 +2944,7 @@ scanner_literal_is_created (parser_context_t *context_p, /**< context */
|
||||
/* These literals must be found in the scope stack. */
|
||||
JERRY_ASSERT (scope_stack_p > context_p->scope_stack_p);
|
||||
scope_stack_p--;
|
||||
}
|
||||
while (literal_index != scope_stack_p->map_from);
|
||||
} while (literal_index != scope_stack_p->map_from);
|
||||
|
||||
JERRY_ASSERT ((scope_stack_p->map_to & PARSER_SCOPE_STACK_REGISTER_MASK) == 0);
|
||||
|
||||
@@ -3015,8 +2966,7 @@ scanner_literal_exists (parser_context_t *context_p, /**< context */
|
||||
|
||||
while (scope_stack_p-- > context_p->scope_stack_p)
|
||||
{
|
||||
if (scope_stack_p->map_from != PARSER_SCOPE_STACK_FUNC
|
||||
&& scanner_decode_map_to (scope_stack_p) == literal_index)
|
||||
if (scope_stack_p->map_from != PARSER_SCOPE_STACK_FUNC && scanner_decode_map_to (scope_stack_p) == literal_index)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user