Detect keyword type even if the keyword is identifier. (#3448)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg 2019-12-16 13:36:26 +01:00 committed by Dániel Bátyai
parent e0d8c4ca10
commit b1237dbc5a
10 changed files with 95 additions and 175 deletions

View File

@ -469,6 +469,7 @@ static const keyword_string_t keywords_with_length_4[] =
LEXER_KEYWORD ("case", LEXER_KEYW_CASE),
LEXER_KEYWORD ("else", LEXER_KEYW_ELSE),
LEXER_KEYWORD ("enum", LEXER_KEYW_ENUM),
LEXER_KEYWORD ("eval", LEXER_KEYW_EVAL),
LEXER_KEYWORD ("null", LEXER_LIT_NULL),
LEXER_KEYWORD ("this", LEXER_KEYW_THIS),
LEXER_KEYWORD ("true", LEXER_LIT_TRUE),
@ -537,6 +538,7 @@ static const keyword_string_t keywords_with_length_8[] =
*/
static const keyword_string_t keywords_with_length_9[] =
{
LEXER_KEYWORD ("arguments", LEXER_KEYW_ARGUMENTS),
LEXER_KEYWORD ("interface", LEXER_KEYW_INTERFACE),
LEXER_KEYWORD ("protected", LEXER_KEYW_PROTECTED),
};
@ -600,6 +602,9 @@ typedef enum
LEXER_PARSE_CHECK_PART_AND_RETURN = (1 << 2), /**< check identifier part and return */
} lexer_parse_options_t;
JERRY_STATIC_ASSERT (LEXER_FIRST_NON_RESERVED_KEYWORD < LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD,
lexer_first_non_reserved_keyword_must_be_before_lexer_first_future_strict_reserved_word);
/**
* Parse identifier.
*
@ -749,7 +754,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
JERRY_ASSERT (length > 0);
context_p->token.type = LEXER_LITERAL;
context_p->token.ident_is_strict_keyword = false;
context_p->token.keyword_type = LEXER_EOS;
context_p->token.lit_location.type = LEXER_IDENT_LITERAL;
context_p->token.lit_location.has_escape = has_escape;
@ -792,50 +797,52 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
if (compare_result == 0)
{
if (JERRY_UNLIKELY (keyword_p->type >= LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD))
context_p->token.keyword_type = (uint8_t) keyword_p->type;
if (JERRY_LIKELY (keyword_p->type < LEXER_FIRST_NON_RESERVED_KEYWORD))
{
#if ENABLED (JERRY_ES2015)
if (keyword_p->type == LEXER_KEYW_YIELD && (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION))
if (ident_start_p == buffer_p)
{
if (ident_start_p == buffer_p)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_KEYWORD);
}
if (context_p->status_flags & PARSER_DISALLOW_YIELD)
{
parser_raise_error (context_p, PARSER_ERR_YIELD_NOT_ALLOWED);
}
context_p->token.type = (uint8_t) LEXER_KEYW_YIELD;
break;
/* Escape sequences are not allowed in a keyword. */
parser_raise_error (context_p, PARSER_ERR_INVALID_KEYWORD);
}
if (keyword_p->type == LEXER_KEYW_LET && !context_p->token.lit_location.has_escape)
{
if (context_p->status_flags & PARSER_IS_STRICT)
{
context_p->token.type = (uint8_t) LEXER_KEYW_LET;
}
break;
}
#endif /* ENABLED (JERRY_ES2015) */
if (context_p->status_flags & PARSER_IS_STRICT)
{
parser_raise_error (context_p, PARSER_ERR_STRICT_IDENT_NOT_ALLOWED);
}
context_p->token.ident_is_strict_keyword = true;
context_p->token.type = (uint8_t) keyword_p->type;
break;
}
if (ident_start_p == buffer_p)
#if ENABLED (JERRY_ES2015)
if (keyword_p->type == LEXER_KEYW_YIELD && (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION))
{
parser_raise_error (context_p, PARSER_ERR_INVALID_KEYWORD);
if (ident_start_p == buffer_p)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_KEYWORD);
}
if (context_p->status_flags & PARSER_DISALLOW_YIELD)
{
parser_raise_error (context_p, PARSER_ERR_YIELD_NOT_ALLOWED);
}
context_p->token.type = (uint8_t) LEXER_KEYW_YIELD;
break;
}
context_p->token.type = (uint8_t) keyword_p->type;
if (keyword_p->type == LEXER_KEYW_LET && ident_start_p != buffer_p)
{
if (context_p->status_flags & PARSER_IS_STRICT)
{
context_p->token.type = (uint8_t) LEXER_KEYW_LET;
}
break;
}
#endif /* ENABLED (JERRY_ES2015) */
if (keyword_p->type >= LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD
&& (context_p->status_flags & PARSER_IS_STRICT))
{
parser_raise_error (context_p, PARSER_ERR_STRICT_IDENT_NOT_ALLOWED);
}
break;
}
}
@ -1187,7 +1194,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
size_t length;
context_p->token.type = LEXER_LITERAL;
context_p->token.ident_is_strict_keyword = false;
context_p->token.keyword_type = LEXER_EOS;
context_p->token.extra_value = LEXER_NUMBER_DECIMAL;
context_p->token.lit_location.char_p = source_p;
context_p->token.lit_location.type = LEXER_NUMBER_LITERAL;
@ -2164,25 +2171,6 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
literal_type,
literal_p->has_escape);
context_p->lit_object.type = LEXER_LITERAL_OBJECT_ANY;
if (literal_p->length == 4
&& source_p[0] == LIT_CHAR_LOWERCASE_E
&& source_p[3] == LIT_CHAR_LOWERCASE_L
&& source_p[1] == LIT_CHAR_LOWERCASE_V
&& source_p[2] == LIT_CHAR_LOWERCASE_A)
{
context_p->lit_object.type = LEXER_LITERAL_OBJECT_EVAL;
}
if (literal_p->length == 9
&& source_p[0] == LIT_CHAR_LOWERCASE_A
&& source_p[8] == LIT_CHAR_LOWERCASE_S
&& memcmp (source_p + 1, "rgument", 7) == 0)
{
context_p->lit_object.type = LEXER_LITERAL_OBJECT_ARGUMENTS;
}
if (destination_start_p != local_byte_array)
{
JERRY_ASSERT (context_p->u.allocated_buffer_p == destination_start_p);
@ -2260,7 +2248,6 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
{
context_p->lit_object.literal_p = literal_p;
context_p->lit_object.index = (uint16_t) literal_index;
context_p->lit_object.type = LEXER_LITERAL_OBJECT_ANY;
return false;
}
@ -2282,7 +2269,6 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
context_p->lit_object.literal_p = literal_p;
context_p->lit_object.index = (uint16_t) literal_index;
context_p->lit_object.type = LEXER_LITERAL_OBJECT_ANY;
context_p->literal_count++;
return false;
@ -2624,12 +2610,11 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
literal_p->u.bytecode_p = (ecma_compiled_code_t *) re_bytecode_p;
context_p->token.type = LEXER_LITERAL;
context_p->token.ident_is_strict_keyword = false;
context_p->token.keyword_type = LEXER_EOS;
context_p->token.lit_location.type = LEXER_REGEXP_LITERAL;
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 /* !ENABLED (JERRY_BUILTIN_REGEXP) */
JERRY_UNUSED (parse_only);
parser_raise_error (context_p, PARSER_ERR_UNSUPPORTED_REGEXP);
@ -2664,22 +2649,16 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
literal_type);
if (literal_type != LEXER_STRING_LITERAL
&& (context_p->status_flags & PARSER_IS_STRICT)
&& context_p->lit_object.type != LEXER_LITERAL_OBJECT_ANY)
&& (context_p->status_flags & PARSER_IS_STRICT))
{
parser_error_t error;
if (context_p->lit_object.type == LEXER_LITERAL_OBJECT_EVAL)
if (context_p->token.keyword_type == LEXER_KEYW_EVAL)
{
error = PARSER_ERR_EVAL_NOT_ALLOWED;
parser_raise_error (context_p, PARSER_ERR_EVAL_NOT_ALLOWED);
}
else
else if (context_p->token.keyword_type == LEXER_KEYW_ARGUMENTS)
{
JERRY_ASSERT (context_p->lit_object.type == LEXER_LITERAL_OBJECT_ARGUMENTS);
error = PARSER_ERR_ARGUMENTS_NOT_ALLOWED;
parser_raise_error (context_p, PARSER_ERR_ARGUMENTS_NOT_ALLOWED);
}
parser_raise_error (context_p, error);
}
return;
}
@ -2690,7 +2669,7 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
/* When parsing default exports for modules, it is not required by functions or classes to have identifiers.
* In this case we use a synthetic name for them. */
context_p->token.type = LEXER_LITERAL;
context_p->token.ident_is_strict_keyword = false;
context_p->token.keyword_type = LEXER_EOS;
context_p->token.lit_location.type = LEXER_IDENT_LITERAL;
context_p->token.lit_location.has_escape = false;
lexer_construct_literal_object (context_p, &lexer_default_literal, literal_type);
@ -3098,38 +3077,10 @@ lexer_token_is_let (parser_context_t *context_p) /**< context */
{
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL);
const uint8_t *char_p = context_p->token.lit_location.char_p;
return (!(context_p->status_flags & PARSER_IS_STRICT)
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL
&& context_p->token.lit_location.length == 3
&& char_p[0] == LIT_CHAR_LOWERCASE_L
&& char_p[1] == LIT_CHAR_LOWERCASE_E
&& char_p[2] == LIT_CHAR_LOWERCASE_T);
return (context_p->token.keyword_type == LEXER_KEYW_LET
&& !context_p->token.lit_location.has_escape);
} /* lexer_token_is_let */
/**
* Compares the current literal object to an expected identifier
*
* Note:
* Escape sequences are allowed.
*
* @return true if the input identifiers are the same
*/
bool
lexer_literal_object_is_identifier (parser_context_t *context_p, /**< context */
const char *identifier_p, /**< identifier */
size_t identifier_length) /**< identifier length */
{
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
lexer_literal_t *literal_p = context_p->lit_object.literal_p;
return (literal_p->prop.length == identifier_length
&& memcmp (literal_p->u.char_p, identifier_p, identifier_length) == 0);
} /* lexer_literal_object_is_identifier */
#endif /* ENABLED (JERRY_ES2015) */
/**

View File

@ -144,6 +144,17 @@ typedef enum
LEXER_KEYW_THROW, /**< throw */
LEXER_KEYW_TRY, /**< try */
LEXER_KEYW_CLASS, /**< class */
LEXER_KEYW_EXTENDS, /**< extends */
LEXER_KEYW_SUPER, /**< super */
LEXER_KEYW_CONST, /**< const */
LEXER_KEYW_EXPORT, /**< export */
LEXER_KEYW_IMPORT, /**< import */
LEXER_KEYW_ENUM, /**< enum */
#if ENABLED (JERRY_ES2015)
LEXER_KEYW_AWAIT, /**< await */
#endif /* ENABLED (JERRY_ES2015) */
/* These are virtual tokens. */
LEXER_EXPRESSION_START, /**< expression start */
LEXER_PROPERTY_GETTER, /**< property getter function */
@ -153,32 +164,15 @@ typedef enum
LEXER_CLASS_CONSTRUCTOR, /**< special value for class constructor method */
LEXER_INVALID_PATTERN, /**< special value for invalid destructuring pattern */
#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 /* !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 */
#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 /* ENABLED (JERRY_ES2015) */
LEXER_KEYW_ENUM, /**< enum */
#if ENABLED (JERRY_ES2015)
LEXER_KEYW_AWAIT, /**< await */
#endif /* ENABLED (JERRY_ES2015) */
/* Keywords which are not keyword tokens. */
#define LEXER_FIRST_NON_RESERVED_KEYWORD LEXER_KEYW_EVAL
/* Keywords which cannot be assigned in strict mode. */
#define LEXER_FIRST_NON_STRICT_ARGUMENTS LEXER_KEYW_EVAL
LEXER_KEYW_EVAL, /**< eval */
LEXER_KEYW_ARGUMENTS, /**< arguments */
/* Future strict reserved words: these keywords
* must form a group after future reserved words. */
* must form a group after non-reserved keywords. */
#define LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD LEXER_KEYW_IMPLEMENTS
LEXER_KEYW_IMPLEMENTS, /**< implements */
LEXER_KEYW_PRIVATE, /**< private */
@ -246,16 +240,6 @@ typedef enum
LEXER_SCAN_IDENT_PROPERTY = (1u << 1), /**< scan valid property names */
} lexer_scan_ident_opts_t;
/**
* Lexer literal object types.
*/
typedef enum
{
LEXER_LITERAL_OBJECT_ANY, /**< unspecified object type */
LEXER_LITERAL_OBJECT_EVAL, /**< reference is equal to eval */
LEXER_LITERAL_OBJECT_ARGUMENTS, /**< reference is equal to arguments */
} lexer_literal_object_type_t;
/**
* Lexer number types.
*/
@ -283,7 +267,7 @@ typedef struct
typedef struct
{
uint8_t type; /**< token type */
uint8_t ident_is_strict_keyword; /**< identifier is strict reserved keyword */
uint8_t keyword_type; /**< keyword type for identifiers */
uint8_t extra_value; /**< helper value for different purposes */
uint8_t flags; /**< flag bits for the current token */
parser_line_counter_t line; /**< token start line */
@ -298,7 +282,6 @@ typedef struct
{
lexer_literal_t *literal_p; /**< pointer to the literal object */
uint16_t index; /**< literal index */
uint8_t type; /**< literal object type */
} lexer_lit_object_t;
/**

View File

@ -99,22 +99,16 @@ parser_check_invalid_assign (parser_context_t *context_p) /**< context */
{
JERRY_ASSERT (context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL);
if (JERRY_UNLIKELY ((context_p->status_flags & PARSER_IS_STRICT)
&& context_p->last_cbc.literal_object_type != LEXER_LITERAL_OBJECT_ANY))
if (JERRY_UNLIKELY (context_p->status_flags & PARSER_IS_STRICT))
{
parser_error_t error;
if (context_p->last_cbc.literal_object_type == LEXER_LITERAL_OBJECT_EVAL)
if (context_p->last_cbc.literal_keyword_type == LEXER_KEYW_EVAL)
{
error = PARSER_ERR_EVAL_CANNOT_ASSIGNED;
parser_raise_error (context_p, PARSER_ERR_EVAL_CANNOT_ASSIGNED);
}
else
else if (context_p->last_cbc.literal_keyword_type == LEXER_KEYW_ARGUMENTS)
{
JERRY_ASSERT (context_p->last_cbc.literal_object_type == LEXER_LITERAL_OBJECT_ARGUMENTS);
error = PARSER_ERR_ARGUMENTS_CANNOT_ASSIGNED;
parser_raise_error (context_p, PARSER_ERR_ARGUMENTS_CANNOT_ASSIGNED);
}
parser_raise_error (context_p, error);
}
} /* parser_check_invalid_assign */
@ -1054,8 +1048,7 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
}
#endif /* ENABLED (JERRY_DEBUGGER) */
if (context_p->token.ident_is_strict_keyword
|| context_p->lit_object.type != LEXER_LITERAL_OBJECT_ANY)
if (context_p->token.keyword_type >= LEXER_FIRST_NON_STRICT_ARGUMENTS)
{
status_flags |= PARSER_HAS_NON_STRICT_ARG;
}
@ -1113,7 +1106,7 @@ parser_parse_function_expression (parser_context_t *context_p, /**< context */
}
context_p->last_cbc.literal_type = LEXER_FUNCTION_LITERAL;
context_p->last_cbc.literal_object_type = LEXER_LITERAL_OBJECT_ANY;
context_p->last_cbc.literal_keyword_type = LEXER_EOS;
} /* parser_parse_function_expression */
#if ENABLED (JERRY_ES2015)
@ -1176,7 +1169,7 @@ parser_parse_template_literal (parser_context_t *context_p) /**< context */
context_p->last_cbc_opcode = CBC_ADD_TWO_LITERALS;
context_p->last_cbc.value = context_p->lit_object.index;
context_p->last_cbc.literal_type = context_p->token.lit_location.type;
context_p->last_cbc.literal_object_type = context_p->lit_object.type;
context_p->last_cbc.literal_keyword_type = context_p->token.keyword_type;
}
else
{
@ -1374,14 +1367,14 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
cbc_opcode_t opcode = CBC_PUSH_LITERAL;
if (context_p->lit_object.type != LEXER_LITERAL_OBJECT_EVAL)
if (context_p->token.keyword_type != LEXER_KEYW_EVAL)
{
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
{
context_p->last_cbc_opcode = CBC_PUSH_TWO_LITERALS;
context_p->last_cbc.value = context_p->lit_object.index;
context_p->last_cbc.literal_type = context_p->token.lit_location.type;
context_p->last_cbc.literal_object_type = context_p->lit_object.type;
context_p->last_cbc.literal_keyword_type = context_p->token.keyword_type;
break;
}
@ -1390,7 +1383,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
context_p->last_cbc_opcode = CBC_PUSH_THREE_LITERALS;
context_p->last_cbc.third_literal_index = context_p->lit_object.index;
context_p->last_cbc.literal_type = context_p->token.lit_location.type;
context_p->last_cbc.literal_object_type = context_p->lit_object.type;
context_p->last_cbc.literal_keyword_type = context_p->token.keyword_type;
break;
}
@ -1460,7 +1453,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
}
context_p->last_cbc.literal_type = LEXER_REGEXP_LITERAL;
context_p->last_cbc.literal_object_type = LEXER_LITERAL_OBJECT_ANY;
context_p->last_cbc.literal_keyword_type = LEXER_EOS;
break;
}
case LEXER_KEYW_THIS:
@ -1704,7 +1697,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
else
{
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL
&& context_p->last_cbc.literal_object_type == LEXER_LITERAL_OBJECT_EVAL
&& context_p->last_cbc.literal_keyword_type == LEXER_KEYW_EVAL
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL)
{
is_eval = true;
@ -2460,8 +2453,7 @@ parser_pattern_process_assignment (parser_context_t *context_p, /**< context */
lexer_construct_literal_object (context_p, &context_p->token.lit_location, LEXER_IDENT_LITERAL);
if (flags & PARSER_PATTERN_LEXICAL
&& !(context_p->status_flags & PARSER_IS_STRICT)
&& lexer_literal_object_is_identifier (context_p, "let", 3))
&& context_p->token.keyword_type == LEXER_KEYW_LET)
{
parser_raise_error (context_p, PARSER_ERR_LEXICAL_LET_BINDING);
}

View File

@ -207,7 +207,7 @@ typedef struct
uint16_t value; /**< other argument (second literal or byte). */
uint16_t third_literal_index; /**< literal index argument */
uint8_t literal_type; /**< last literal type */
uint8_t literal_object_type; /**< last literal object type */
uint8_t literal_keyword_type; /**< last literal keyword type */
} cbc_argument_t;
/* Useful parser macros. */
@ -653,8 +653,6 @@ bool lexer_current_is_literal (parser_context_t *context_p, const lexer_lit_loca
bool lexer_token_is_identifier (parser_context_t *context_p, const char *identifier_p,
size_t identifier_length);
bool lexer_token_is_let (parser_context_t *context_p);
bool lexer_literal_object_is_identifier (parser_context_t *context_p, const char *identifier_p,
size_t identifier_length);
#endif /* ENABLED (JERRY_ES2015) */
bool lexer_compare_literal_to_string (parser_context_t *context_p, const char *string_p, size_t string_length);
uint8_t lexer_convert_binary_lvalue_token_to_binary (uint8_t token);

View File

@ -367,7 +367,7 @@ parser_module_parse_export_clause (parser_context_t *context_p) /**< parser cont
/* 15.2.3.1 The referenced binding cannot be a reserved word. */
if (context_p->token.type != LEXER_LITERAL
|| context_p->token.lit_location.type != LEXER_IDENT_LITERAL
|| context_p->token.ident_is_strict_keyword)
|| context_p->token.keyword_type >= LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD)
{
parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_EXPECTED);
}

View File

@ -543,8 +543,7 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
#if ENABLED (JERRY_ES2015)
if (declaration_type != LEXER_KEYW_VAR
&& !(context_p->status_flags & PARSER_IS_STRICT)
&& lexer_literal_object_is_identifier (context_p, "let", 3))
&& context_p->token.keyword_type == LEXER_KEYW_LET)
{
parser_raise_error (context_p, PARSER_ERR_LEXICAL_LET_BINDING);
}
@ -679,10 +678,8 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
uint32_t status_flags = PARSER_FUNCTION_CLOSURE;
if (context_p->lit_object.type != LEXER_LITERAL_OBJECT_ANY)
if (context_p->token.keyword_type >= LEXER_FIRST_NON_STRICT_ARGUMENTS)
{
JERRY_ASSERT (context_p->lit_object.type == LEXER_LITERAL_OBJECT_EVAL
|| context_p->lit_object.type == LEXER_LITERAL_OBJECT_ARGUMENTS);
status_flags |= PARSER_HAS_NON_STRICT_ARG;
}

View File

@ -308,7 +308,7 @@ parser_emit_cbc_literal (parser_context_t *context_p, /**< context */
context_p->last_cbc_opcode = opcode;
context_p->last_cbc.literal_index = literal_index;
context_p->last_cbc.literal_type = LEXER_UNUSED_LITERAL;
context_p->last_cbc.literal_object_type = LEXER_LITERAL_OBJECT_ANY;
context_p->last_cbc.literal_keyword_type = LEXER_EOS;
} /* parser_emit_cbc_literal */
/**
@ -330,7 +330,7 @@ parser_emit_cbc_literal_value (parser_context_t *context_p, /**< context */
context_p->last_cbc_opcode = opcode;
context_p->last_cbc.literal_index = literal_index;
context_p->last_cbc.literal_type = LEXER_UNUSED_LITERAL;
context_p->last_cbc.literal_object_type = LEXER_LITERAL_OBJECT_ANY;
context_p->last_cbc.literal_keyword_type = LEXER_EOS;
context_p->last_cbc.value = value;
} /* parser_emit_cbc_literal_value */
@ -351,7 +351,7 @@ parser_emit_cbc_literal_from_token (parser_context_t *context_p, /**< context */
context_p->last_cbc_opcode = opcode;
context_p->last_cbc.literal_index = context_p->lit_object.index;
context_p->last_cbc.literal_type = context_p->token.lit_location.type;
context_p->last_cbc.literal_object_type = context_p->lit_object.type;
context_p->last_cbc.literal_keyword_type = context_p->token.keyword_type;
} /* parser_emit_cbc_literal_from_token */
/**

View File

@ -1729,8 +1729,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
&context_p->token.lit_location,
LEXER_IDENT_LITERAL);
if (context_p->token.ident_is_strict_keyword
|| context_p->lit_object.type != LEXER_LITERAL_OBJECT_ANY)
if (context_p->token.keyword_type >= LEXER_FIRST_NON_STRICT_ARGUMENTS)
{
context_p->status_flags |= PARSER_HAS_NON_STRICT_ARG;
}

View File

@ -1116,7 +1116,7 @@ void
scanner_detect_eval_call (parser_context_t *context_p, /**< context */
scanner_context_t *scanner_context_p) /**< scanner context */
{
if (lexer_compare_identifier_to_string (&context_p->token.lit_location, (const uint8_t *) "eval", 4)
if (context_p->token.keyword_type == LEXER_KEYW_EVAL
&& lexer_check_next_character (context_p, LIT_CHAR_LEFT_PAREN))
{
scanner_context_p->active_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_NO_REG;

View File

@ -376,7 +376,7 @@ scanner_handle_bracket (parser_context_t *context_p, /**< context */
arrow_source_p = NULL;
#endif /* ENABLED (JERRY_ES2015) */
if (lexer_compare_identifier_to_string (&context_p->token.lit_location, (const uint8_t *) "eval", 4))
if (context_p->token.keyword_type == LEXER_KEYW_EVAL)
{
scanner_context_p->active_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_NO_REG;
}