Index: src/preparser.cc |
diff --git a/src/preparser.cc b/src/preparser.cc |
index 6145834d35650dcff5d7f24a4216278feffc5fb9..652c1ba75d79f6430b0c292b06ea5a3978f9399b 100644 |
--- a/src/preparser.cc |
+++ b/src/preparser.cc |
@@ -55,18 +55,6 @@ int isfinite(double value); |
namespace v8 { |
namespace internal { |
- |
-void PreParserTraits::CheckStrictModeLValue(PreParserExpression expression, |
- bool* ok) { |
- if (expression.IsIdentifier() && |
- expression.AsIdentifier().IsEvalOrArguments()) { |
- pre_parser_->ReportMessage("strict_eval_arguments", |
- Vector<const char*>::empty()); |
- *ok = false; |
- } |
-} |
- |
- |
void PreParserTraits::ReportMessageAt(Scanner::Location location, |
const char* message, |
Vector<const char*> args) { |
@@ -123,6 +111,12 @@ PreParserExpression PreParserTraits::ExpressionFromString( |
} |
+PreParserExpression PreParserTraits::ParseAssignmentExpression(bool accept_IN, |
+ bool* ok) { |
+ return pre_parser_->ParseAssignmentExpression(accept_IN, ok); |
+} |
+ |
+ |
PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { |
return pre_parser_->ParseV8Intrinsic(ok); |
} |
@@ -142,17 +136,6 @@ PreParserExpression PreParserTraits::ParseFunctionLiteral( |
} |
-PreParserExpression PreParserTraits::ParseYieldExpression(bool* ok) { |
- return pre_parser_->ParseYieldExpression(ok); |
-} |
- |
- |
-PreParserExpression PreParserTraits::ParseConditionalExpression(bool accept_IN, |
- bool* ok) { |
- return pre_parser_->ParseConditionalExpression(accept_IN, ok); |
-} |
- |
- |
PreParser::PreParseResult PreParser::PreParseLazyFunction( |
StrictMode strict_mode, bool is_generator, ParserRecorder* log) { |
log_ = log; |
@@ -844,6 +827,47 @@ PreParser::Statement PreParser::ParseDebuggerStatement(bool* ok) { |
#undef DUMMY |
+// Precedence = 2 |
+PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, |
+ bool* ok) { |
+ // AssignmentExpression :: |
+ // ConditionalExpression |
+ // YieldExpression |
+ // LeftHandSideExpression AssignmentOperator AssignmentExpression |
+ |
+ if (function_state_->is_generator() && peek() == Token::YIELD) { |
+ return ParseYieldExpression(ok); |
+ } |
+ |
+ Scanner::Location before = scanner()->peek_location(); |
+ Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); |
+ |
+ if (!Token::IsAssignmentOp(peek())) { |
+ // Parsed conditional expression only (no assignment). |
+ return expression; |
+ } |
+ |
+ if (strict_mode() == STRICT && |
+ expression.IsIdentifier() && |
+ expression.AsIdentifier().IsEvalOrArguments()) { |
+ Scanner::Location after = scanner()->location(); |
+ PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, |
+ "strict_eval_arguments", NULL); |
+ *ok = false; |
+ return Expression::Default(); |
+ } |
+ |
+ Token::Value op = Next(); // Get assignment operator. |
+ ParseAssignmentExpression(accept_IN, CHECK_OK); |
+ |
+ if ((op == Token::ASSIGN) && expression.IsThisProperty()) { |
+ function_state_->AddProperty(); |
+ } |
+ |
+ return Expression::Default(); |
+} |
+ |
+ |
// Precedence = 3 |
PreParser::Expression PreParser::ParseYieldExpression(bool* ok) { |
// YieldExpression :: |
@@ -915,9 +939,15 @@ PreParser::Expression PreParser::ParseUnaryExpression(bool* ok) { |
return Expression::Default(); |
} else if (Token::IsCountOp(op)) { |
op = Next(); |
+ Scanner::Location before = scanner()->peek_location(); |
Expression expression = ParseUnaryExpression(CHECK_OK); |
- if (strict_mode() == STRICT) { |
- CheckStrictModeLValue(expression, CHECK_OK); |
+ if (strict_mode() == STRICT && |
+ expression.IsIdentifier() && |
+ expression.AsIdentifier().IsEvalOrArguments()) { |
+ Scanner::Location after = scanner()->location(); |
+ PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, |
+ "strict_eval_arguments", NULL); |
+ *ok = false; |
} |
return Expression::Default(); |
} else { |
@@ -930,11 +960,18 @@ PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) { |
// PostfixExpression :: |
// LeftHandSideExpression ('++' | '--')? |
+ Scanner::Location before = scanner()->peek_location(); |
Expression expression = ParseLeftHandSideExpression(CHECK_OK); |
if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
Token::IsCountOp(peek())) { |
- if (strict_mode() == STRICT) { |
- CheckStrictModeLValue(expression, CHECK_OK); |
+ if (strict_mode() == STRICT && |
+ expression.IsIdentifier() && |
+ expression.AsIdentifier().IsEvalOrArguments()) { |
+ Scanner::Location after = scanner()->location(); |
+ PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, |
+ "strict_eval_arguments", NULL); |
+ *ok = false; |
+ return Expression::Default(); |
} |
Next(); |
return Expression::Default(); |