Revert "Revert "Upgrade to 5.0.71.48"" DO NOT MERGE
This reverts commit f2e3994fa5148cc3d9946666f0b0596290192b0e,
and updates the x64 makefile properly so it doesn't break that
build.
FPIIM-449
Change-Id: Ib83e35bfbae6af627451c926a9650ec57c045605
(cherry picked from commit 109988c7ccb6f3fd1a58574fa3dfb88beaef6632)
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index 64511ac..d335c8b 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -94,11 +94,10 @@
PreParserIdentifier name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
- FunctionLiteral::ArityRestriction arity_restriction,
LanguageMode language_mode, bool* ok) {
return pre_parser_->ParseFunctionLiteral(
name, function_name_location, function_name_validity, kind,
- function_token_position, type, arity_restriction, language_mode, ok);
+ function_token_position, type, language_mode, ok);
}
@@ -451,8 +450,7 @@
: kFunctionNameValidityUnknown,
is_generator ? FunctionKind::kGeneratorFunction
: FunctionKind::kNormalFunction,
- pos, FunctionLiteral::kDeclaration,
- FunctionLiteral::kNormalArity, language_mode(),
+ pos, FunctionLiteral::kDeclaration, language_mode(),
CHECK_OK);
return Statement::FunctionDeclaration();
}
@@ -575,7 +573,7 @@
int decl_pos = peek_position();
PreParserExpression pattern = PreParserExpression::Default();
{
- ExpressionClassifier pattern_classifier;
+ ExpressionClassifier pattern_classifier(this);
Token::Value next = peek();
pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
@@ -591,17 +589,12 @@
}
}
- is_pattern = (pattern.IsObjectLiteral() || pattern.IsArrayLiteral()) &&
- !pattern.is_parenthesized();
-
- bool is_for_iteration_variable =
- var_context == kForStatement &&
- (peek() == Token::IN || PeekContextualKeyword(CStrVector("of")));
+ is_pattern = pattern.IsObjectLiteral() || pattern.IsArrayLiteral();
Scanner::Location variable_loc = scanner()->location();
nvars++;
if (Check(Token::ASSIGN)) {
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
ParseAssignmentExpression(var_context != kForStatement, &classifier,
CHECK_OK);
ValidateExpression(&classifier, CHECK_OK);
@@ -611,7 +604,7 @@
*first_initializer_loc = variable_loc;
}
} else if ((require_initializer || is_pattern) &&
- !is_for_iteration_variable) {
+ (var_context != kForStatement || !PeekInOrOf())) {
PreParserTraits::ReportMessageAt(
Scanner::Location(decl_pos, scanner()->location().end_pos),
MessageTemplate::kDeclarationMissingInitializer,
@@ -655,7 +648,7 @@
IsClassConstructor(function_state_->kind())) {
bool is_this = peek() == Token::THIS;
Expression expr = Expression::Default();
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
if (is_this) {
expr = ParseStrongInitializationExpression(&classifier, CHECK_OK);
} else {
@@ -691,7 +684,7 @@
}
bool starts_with_identifier = peek_any_identifier();
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
Expression expr = ParseExpression(true, &classifier, CHECK_OK);
ValidateExpression(&classifier, CHECK_OK);
@@ -924,40 +917,40 @@
ParseVariableDeclarations(kForStatement, &decl_count, &is_lexical,
&is_binding_pattern, &first_initializer_loc,
&bindings_loc, CHECK_OK);
- bool accept_IN = decl_count >= 1;
- if (accept_IN && CheckInOrOf(&mode, ok)) {
+ if (CheckInOrOf(&mode, ok)) {
if (!*ok) return Statement::Default();
if (decl_count != 1) {
- const char* loop_type =
- mode == ForEachStatement::ITERATE ? "for-of" : "for-in";
PreParserTraits::ReportMessageAt(
bindings_loc, MessageTemplate::kForInOfLoopMultiBindings,
- loop_type);
+ ForEachStatement::VisitModeString(mode));
*ok = false;
return Statement::Default();
}
if (first_initializer_loc.IsValid() &&
(is_strict(language_mode()) || mode == ForEachStatement::ITERATE ||
is_lexical || is_binding_pattern)) {
- if (mode == ForEachStatement::ITERATE) {
- ReportMessageAt(first_initializer_loc,
- MessageTemplate::kForOfLoopInitializer);
- } else {
- // TODO(caitp): This should be an error in sloppy mode, too.
- ReportMessageAt(first_initializer_loc,
- MessageTemplate::kForInLoopInitializer);
- }
+ PreParserTraits::ReportMessageAt(
+ first_initializer_loc, MessageTemplate::kForInOfLoopInitializer,
+ ForEachStatement::VisitModeString(mode));
*ok = false;
return Statement::Default();
}
- ParseExpression(true, CHECK_OK);
+
+ if (mode == ForEachStatement::ITERATE) {
+ ExpressionClassifier classifier(this);
+ ParseAssignmentExpression(true, &classifier, CHECK_OK);
+ RewriteNonPattern(&classifier, CHECK_OK);
+ } else {
+ ParseExpression(true, CHECK_OK);
+ }
+
Expect(Token::RPAREN, CHECK_OK);
ParseSubStatement(CHECK_OK);
return Statement::Default();
}
} else {
int lhs_beg_pos = peek_position();
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
Expression lhs = ParseExpression(false, &classifier, CHECK_OK);
int lhs_end_pos = scanner()->location().end_pos;
is_let_identifier_expression =
@@ -980,7 +973,15 @@
lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor,
kSyntaxError, CHECK_OK);
}
- ParseExpression(true, CHECK_OK);
+
+ if (mode == ForEachStatement::ITERATE) {
+ ExpressionClassifier classifier(this);
+ ParseAssignmentExpression(true, &classifier, CHECK_OK);
+ RewriteNonPattern(&classifier, CHECK_OK);
+ } else {
+ ParseExpression(true, CHECK_OK);
+ }
+
Expect(Token::RPAREN, CHECK_OK);
ParseSubStatement(CHECK_OK);
return Statement::Default();
@@ -1054,7 +1055,7 @@
if (tok == Token::CATCH) {
Consume(Token::CATCH);
Expect(Token::LPAREN, CHECK_OK);
- ExpressionClassifier pattern_classifier;
+ ExpressionClassifier pattern_classifier(this);
ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
ValidateBindingPattern(&pattern_classifier, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
@@ -1099,7 +1100,6 @@
Identifier function_name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_pos, FunctionLiteral::FunctionType function_type,
- FunctionLiteral::ArityRestriction arity_restriction,
LanguageMode language_mode, bool* ok) {
// Function ::
// '(' FormalParameterList? ')' '{' FunctionBody '}'
@@ -1112,7 +1112,7 @@
FunctionState function_state(&function_state_, &scope_, function_scope, kind,
&factory);
DuplicateFinder duplicate_finder(scanner()->unicode_cache());
- ExpressionClassifier formals_classifier(&duplicate_finder);
+ ExpressionClassifier formals_classifier(this, &duplicate_finder);
Expect(Token::LPAREN, CHECK_OK);
int start_position = scanner()->location().beg_pos;
@@ -1122,8 +1122,7 @@
Expect(Token::RPAREN, CHECK_OK);
int formals_end_position = scanner()->location().end_pos;
- CheckArityRestrictions(formals.arity, arity_restriction,
- formals.has_rest, start_position,
+ CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position,
formals_end_position, CHECK_OK);
// See Parser::ParseFunctionLiteral for more information about lazy parsing
@@ -1219,7 +1218,7 @@
bool has_extends = Check(Token::EXTENDS);
if (has_extends) {
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
ParseLeftHandSideExpression(&classifier, CHECK_OK);
ValidateExpression(&classifier, CHECK_OK);
}
@@ -1235,7 +1234,7 @@
bool is_computed_name = false; // Classes do not care about computed
// property names here.
Identifier name;
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
ParsePropertyDefinition(&checker, in_class, has_extends, is_static,
&is_computed_name, &has_seen_constructor,
&classifier, &name, CHECK_OK);
@@ -1259,7 +1258,7 @@
// Allow "eval" or "arguments" for backward compatibility.
ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
Scanner::Location spread_pos;
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
ParseArguments(&spread_pos, &classifier, ok);
ValidateExpression(&classifier, CHECK_OK);