Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: src/preparser.cc

Issue 139713005: Follow-up to r19112. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 Identifier identifier = Identifier::Default(); 1051 Identifier identifier = Identifier::Default();
1052 if (peek_any_identifier()) { 1052 if (peek_any_identifier()) {
1053 identifier = ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); 1053 identifier = ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK);
1054 } 1054 }
1055 result = ParseFunctionLiteral(is_generator, CHECK_OK); 1055 result = ParseFunctionLiteral(is_generator, CHECK_OK);
1056 // If we're in strict mode, ParseIdentifier will catch using eval, arguments 1056 // If we're in strict mode, ParseIdentifier will catch using eval, arguments
1057 // or a strict reserved word as function name. However, if only the function 1057 // or a strict reserved word as function name. However, if only the function
1058 // is strict, we need to do an extra check. 1058 // is strict, we need to do an extra check.
1059 if (result.IsStrictFunction() && !identifier.IsValidStrictVariable()) { 1059 if (result.IsStrictFunction() && !identifier.IsValidStrictVariable()) {
1060 StrictModeIdentifierViolation(scanner()->location(), 1060 StrictModeIdentifierViolation(scanner()->location(),
1061 "strict_eval_arguments",
1062 identifier, 1061 identifier,
1063 ok); 1062 ok);
1064 return Expression::Default(); 1063 return Expression::Default();
1065 } 1064 }
1066 } else { 1065 } else {
1067 result = ParsePrimaryExpression(CHECK_OK); 1066 result = ParsePrimaryExpression(CHECK_OK);
1068 } 1067 }
1069 1068
1070 while (true) { 1069 while (true) {
1071 switch (peek()) { 1070 switch (peek()) {
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 // "arguments" as identifier even in strict mode (this is needed in cases like 1488 // "arguments" as identifier even in strict mode (this is needed in cases like
1490 // "var foo = eval;"). 1489 // "var foo = eval;").
1491 PreParser::Identifier PreParser::ParseIdentifier( 1490 PreParser::Identifier PreParser::ParseIdentifier(
1492 AllowEvalOrArgumentsAsIdentifier allow_eval_or_arguments, 1491 AllowEvalOrArgumentsAsIdentifier allow_eval_or_arguments,
1493 bool* ok) { 1492 bool* ok) {
1494 Token::Value next = Next(); 1493 Token::Value next = Next();
1495 if (next == Token::IDENTIFIER) { 1494 if (next == Token::IDENTIFIER) {
1496 PreParser::Identifier name = GetIdentifierSymbol(); 1495 PreParser::Identifier name = GetIdentifierSymbol();
1497 if (allow_eval_or_arguments == kDontAllowEvalOrArguments && 1496 if (allow_eval_or_arguments == kDontAllowEvalOrArguments &&
1498 !is_classic_mode() && name.IsEvalOrArguments()) { 1497 !is_classic_mode() && name.IsEvalOrArguments()) {
1499 StrictModeIdentifierViolation( 1498 StrictModeIdentifierViolation(scanner()->location(), name, ok);
1500 scanner()->location(), "strict_eval_arguments", name, ok);
1501 } 1499 }
1502 return name; 1500 return name;
1503 } else if (is_classic_mode() && 1501 } else if (is_classic_mode() &&
1504 (next == Token::FUTURE_STRICT_RESERVED_WORD || 1502 (next == Token::FUTURE_STRICT_RESERVED_WORD ||
1505 (next == Token::YIELD && !scope_->is_generator()))) { 1503 (next == Token::YIELD && !scope_->is_generator()))) {
1506 return GetIdentifierSymbol(); 1504 return GetIdentifierSymbol();
1507 } else { 1505 } else {
1508 ReportUnexpectedToken(next); 1506 ReportUnexpectedToken(next);
1509 *ok = false; 1507 *ok = false;
1510 return Identifier::Default(); 1508 return Identifier::Default();
(...skipping 28 matching lines...) Expand all
1539 Scanner::Location location = strict_mode_violation_location_; 1537 Scanner::Location location = strict_mode_violation_location_;
1540 if (location.IsValid() && 1538 if (location.IsValid() &&
1541 location.beg_pos > beg_pos && location.end_pos < end_pos) { 1539 location.beg_pos > beg_pos && location.end_pos < end_pos) {
1542 ReportMessageAt(location, strict_mode_violation_type_, NULL); 1540 ReportMessageAt(location, strict_mode_violation_type_, NULL);
1543 *ok = false; 1541 *ok = false;
1544 } 1542 }
1545 } 1543 }
1546 1544
1547 1545
1548 void PreParser::StrictModeIdentifierViolation(Scanner::Location location, 1546 void PreParser::StrictModeIdentifierViolation(Scanner::Location location,
1549 const char* eval_args_type,
1550 Identifier identifier, 1547 Identifier identifier,
1551 bool* ok) { 1548 bool* ok) {
1552 const char* type = eval_args_type; 1549 const char* type = "strict_eval_arguments";
1553 if (identifier.IsFutureReserved()) { 1550 if (identifier.IsFutureReserved()) {
1554 type = "unexpected_reserved"; 1551 type = "unexpected_reserved";
1555 } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { 1552 } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) {
1556 type = "unexpected_strict_reserved"; 1553 type = "unexpected_strict_reserved";
1557 } 1554 }
1558 if (!is_classic_mode()) { 1555 if (!is_classic_mode()) {
1559 ReportMessageAt(location, type, NULL); 1556 ReportMessageAt(location, type, NULL);
1560 *ok = false; 1557 *ok = false;
1561 return; 1558 return;
1562 } 1559 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 ASSERT(IsAccessorAccessorConflict(old_type, type)); 1625 ASSERT(IsAccessorAccessorConflict(old_type, type));
1629 // Both accessors of the same type. 1626 // Both accessors of the same type.
1630 parser()->ReportMessageAt(scanner()->location(), 1627 parser()->ReportMessageAt(scanner()->location(),
1631 "accessor_get_set"); 1628 "accessor_get_set");
1632 } 1629 }
1633 *ok = false; 1630 *ok = false;
1634 } 1631 }
1635 } 1632 }
1636 1633
1637 } } // v8::internal 1634 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698