FunctionLiteral* ParserTraits::ParseFunctionLiteral(
const AstRawString* name, Scanner::Location function_name_location,
- bool name_is_strict_reserved, FunctionKind kind,
+ FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
return parser_->ParseFunctionLiteral(
- name, function_name_location, name_is_strict_reserved, kind,
+ name, function_name_location, function_name_validity, kind,
function_token_position, type, arity_restriction, ok);
}
shared_info->end_position());
} else {
result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(),
- false, // Strict mode name already checked.
- shared_info->kind(), RelocInfo::kNoPosition,
- function_type,
+ kSkipFunctionNameCheck, shared_info->kind(),
+ RelocInfo::kNoPosition, function_type,
FunctionLiteral::NORMAL_ARITY, &ok);
}
// Make sure the results agree.
const AstRawString* name = ParseIdentifierOrStrictReservedWord(
&is_strict_reserved, CHECK_OK);
FunctionLiteral* fun =
- ParseFunctionLiteral(name, scanner()->location(), is_strict_reserved,
+ ParseFunctionLiteral(name, scanner()->location(),
+ is_strict_reserved ? kFunctionNameIsStrictReserved
+ : kFunctionNameValidityUnknown,
is_generator ? FunctionKind::kGeneratorFunction
: FunctionKind::kNormalFunction,
pos, FunctionLiteral::DECLARATION,
FunctionLiteral* Parser::ParseFunctionLiteral(
const AstRawString* function_name, Scanner::Location function_name_location,
- bool name_is_strict_reserved, FunctionKind kind, int function_token_pos,
- FunctionLiteral::FunctionType function_type,
+ FunctionNameValidity function_name_validity, FunctionKind kind,
+ int function_token_pos, FunctionLiteral::FunctionType function_type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
// Function ::
// '(' FormalParameterList? ')' '{' FunctionBody '}'
// Validate name and parameter names. We can do this only after parsing the
// function, since the function can declare itself strict.
- CheckFunctionName(language_mode(), kind, function_name,
- name_is_strict_reserved, function_name_location,
- CHECK_OK);
+ CheckFunctionName(language_mode(), function_name, function_name_validity,
+ function_name_location, CHECK_OK);
const bool use_strict_params =
!parsing_state.is_simple_parameter_list || IsConciseMethod(kind);
const bool allow_duplicate_parameters =
Expression* ParseV8Intrinsic(bool* ok);
FunctionLiteral* ParseFunctionLiteral(
const AstRawString* name, Scanner::Location function_name_location,
- bool name_is_strict_reserved, FunctionKind kind,
+ FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
V8_INLINE void SkipLazyFunctionBody(
FunctionLiteral* ParseFunctionLiteral(
const AstRawString* name, Scanner::Location function_name_location,
- bool name_is_strict_reserved, FunctionKind kind,
+ FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
PreParserExpression PreParserTraits::ParseFunctionLiteral(
PreParserIdentifier name, Scanner::Location function_name_location,
- bool name_is_strict_reserved, FunctionKind kind,
+ FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
return pre_parser_->ParseFunctionLiteral(
- name, function_name_location, name_is_strict_reserved, kind,
+ name, function_name_location, function_name_validity, kind,
function_token_position, type, arity_restriction, ok);
}
bool is_strict_reserved = false;
Identifier name = ParseIdentifierOrStrictReservedWord(
&is_strict_reserved, CHECK_OK);
- ParseFunctionLiteral(name, scanner()->location(), is_strict_reserved,
+ ParseFunctionLiteral(name, scanner()->location(),
+ is_strict_reserved ? kFunctionNameIsStrictReserved
+ : kFunctionNameValidityUnknown,
is_generator ? FunctionKind::kGeneratorFunction
: FunctionKind::kNormalFunction,
pos, FunctionLiteral::DECLARATION,
PreParser::Expression PreParser::ParseFunctionLiteral(
Identifier function_name, Scanner::Location function_name_location,
- bool name_is_strict_reserved, FunctionKind kind, int function_token_pos,
- FunctionLiteral::FunctionType function_type,
+ FunctionNameValidity function_name_validity, FunctionKind kind,
+ int function_token_pos, FunctionLiteral::FunctionType function_type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
// Function ::
// '(' FormalParameterList? ')' '{' FunctionBody '}'
// Validate name and parameter names. We can do this only after parsing the
// function, since the function can declare itself strict.
- CheckFunctionName(language_mode(), kind, function_name,
- name_is_strict_reserved, function_name_location, CHECK_OK);
+ CheckFunctionName(language_mode(), function_name, function_name_validity,
+ function_name_location, CHECK_OK);
const bool strict_formal_parameters =
!parsing_state.is_simple_parameter_list || IsConciseMethod(kind);
const bool allow_duplicate_parameters =
namespace v8 {
namespace internal {
+
+enum FunctionNameValidity {
+ kFunctionNameIsStrictReserved,
+ kSkipFunctionNameCheck,
+ kFunctionNameValidityUnknown
+};
+
+
// Common base class shared between parser and pre-parser. Traits encapsulate
// the differences between Parser and PreParser:
// Checking the name of a function literal. This has to be done after parsing
// the function, since the function can declare itself strict.
- void CheckFunctionName(LanguageMode language_mode, FunctionKind kind,
- IdentifierT function_name,
- bool function_name_is_strict_reserved,
- const Scanner::Location& function_name_loc,
- bool* ok) {
- // Property names are never checked.
- if (IsConciseMethod(kind) || IsAccessorFunction(kind)) return;
+ void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name,
+ FunctionNameValidity function_name_validity,
+ const Scanner::Location& function_name_loc, bool* ok) {
+ if (function_name_validity == kSkipFunctionNameCheck) return;
// The function name needs to be checked in strict mode.
if (is_sloppy(language_mode)) return;
*ok = false;
return;
}
- if (function_name_is_strict_reserved) {
+ if (function_name_validity == kFunctionNameIsStrictReserved) {
Traits::ReportMessageAt(function_name_loc,
MessageTemplate::kUnexpectedStrictReserved);
*ok = false;
PreParserExpression ParseV8Intrinsic(bool* ok);
PreParserExpression ParseFunctionLiteral(
PreParserIdentifier name, Scanner::Location function_name_location,
- bool name_is_strict_reserved, FunctionKind kind,
+ FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
Expression ParseFunctionLiteral(
Identifier name, Scanner::Location function_name_location,
- bool name_is_strict_reserved, FunctionKind kind, int function_token_pos,
- FunctionLiteral::FunctionType function_type,
+ FunctionNameValidity function_name_validity, FunctionKind kind,
+ int function_token_pos, FunctionLiteral::FunctionType function_type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
void ParseLazyFunctionLiteralBody(bool* ok,
Scanner::BookmarkScope* bookmark = nullptr);
if (!in_class) kind = WithObjectLiteralBit(kind);
value = this->ParseFunctionLiteral(
- name, scanner()->location(),
- false, // reserved words are allowed here
- kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
+ name, scanner()->location(), kSkipFunctionNameCheck, kind,
+ RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
FunctionLiteral::NORMAL_ARITY,
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
FunctionKind kind = FunctionKind::kAccessorFunction;
if (!in_class) kind = WithObjectLiteralBit(kind);
typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral(
- name, scanner()->location(),
- false, // reserved words are allowed here
- kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
+ name, scanner()->location(), kSkipFunctionNameCheck, kind,
+ RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY,
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
function_type = FunctionLiteral::NAMED_EXPRESSION;
}
result = this->ParseFunctionLiteral(
- name, function_name_location, is_strict_reserved_name,
+ name, function_name_location,
+ is_strict_reserved_name ? kFunctionNameIsStrictReserved
+ : kFunctionNameValidityUnknown,
is_generator ? FunctionKind::kGeneratorFunction
: FunctionKind::kNormalFunction,
function_token_position, function_type, FunctionLiteral::NORMAL_ARITY,
'intl402/13.2.1_5': [PASS, FAIL],
'intl402/13.3.0_7': [PASS, FAIL],
- # These tests fail in nosnap in strict mode
- # https://code.google.com/p/v8/issues/detail?id=4198
- 'built-ins/String/S15.5.1.1_A1_T6': [PASS, FAIL_OK],
- 'built-ins/eval/S15.1.2.1_A1.1_T1': [PASS, FAIL_OK],
- 'built-ins/eval/S15.1.2.1_A1.1_T2': [PASS, FAIL_OK],
- 'built-ins/eval/S15.1.2.1_A4.3': [PASS, FAIL_OK],
- 'built-ins/eval/S15.1.2.1_A4.4': [PASS, FAIL_OK],
- 'language/eval-code/10.4.2-1-1': [PASS, FAIL_OK],
- 'language/eval-code/10.4.2-1-2': [PASS, FAIL_OK],
- 'language/eval-code/10.4.2-1-3': [PASS, FAIL_OK],
- 'language/eval-code/10.4.2-1-5': [PASS, FAIL_OK],
- 'language/eval-code/S10.4.2.1_A1': [PASS, FAIL_OK],
- 'language/function-code/10.4.3-1-19-s': [PASS, FAIL_OK],
- 'language/function-code/10.4.3-1-19gs': [PASS, FAIL_OK],
- 'language/function-code/10.4.3-1-20-s': [PASS, FAIL_OK],
- 'language/function-code/10.4.3-1-20gs': [PASS, FAIL_OK],
- 'language/statements/variable/12.2.1-10-s': [PASS, FAIL_OK],
- 'language/statements/variable/12.2.1-20-s': [PASS, FAIL_OK],
- 'language/statements/variable/12.2.1-21-s': [PASS, FAIL_OK],
- 'language/statements/variable/12.2.1-9-s': [PASS, FAIL_OK],
-
##################### DELIBERATE INCOMPATIBILITIES #####################
'built-ins/Math/exp/S15.8.2.8_A6': [PASS, FAIL_OK], # Math.exp (less precise with --fast-math)