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

Side by Side Diff: src/preparser.h

Issue 197103002: Move most scanner buffer accesses into scanner. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 } 1107 }
1108 1108
1109 1109
1110 template <class Traits> 1110 template <class Traits>
1111 typename Traits::Type::Identifier 1111 typename Traits::Type::Identifier
1112 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, 1112 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get,
1113 bool* is_set, 1113 bool* is_set,
1114 bool* ok) { 1114 bool* ok) {
1115 typename Traits::Type::Identifier result = ParseIdentifierName(ok); 1115 typename Traits::Type::Identifier result = ParseIdentifierName(ok);
1116 if (!*ok) return Traits::EmptyIdentifier(); 1116 if (!*ok) return Traits::EmptyIdentifier();
1117 if (scanner()->is_literal_ascii() && 1117 scanner()->IsGetOrSet(is_get, is_set);
1118 scanner()->literal_length() == 3) {
1119 const char* token = scanner()->literal_ascii_string().start();
1120 *is_get = strncmp(token, "get", 3) == 0;
1121 *is_set = !*is_get && strncmp(token, "set", 3) == 0;
1122 }
1123 return result; 1118 return result;
1124 } 1119 }
1125 1120
1126 1121
1127 template <class Traits> 1122 template <class Traits>
1128 typename Traits::Type::Expression 1123 typename Traits::Type::Expression
1129 ParserBase<Traits>::ParseRegExpLiteral(bool seen_equal, bool* ok) { 1124 ParserBase<Traits>::ParseRegExpLiteral(bool seen_equal, bool* ok) {
1130 int pos = peek_position(); 1125 int pos = peek_position();
1131 if (!scanner()->ScanRegExpPattern(seen_equal)) { 1126 if (!scanner()->ScanRegExpPattern(seen_equal)) {
1132 Next(); 1127 Next();
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 #undef CHECK_OK_CUSTOM 1505 #undef CHECK_OK_CUSTOM
1511 1506
1512 1507
1513 template <typename Traits> 1508 template <typename Traits>
1514 void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty( 1509 void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty(
1515 Token::Value property, 1510 Token::Value property,
1516 PropertyKind type, 1511 PropertyKind type,
1517 bool* ok) { 1512 bool* ok) {
1518 int old; 1513 int old;
1519 if (property == Token::NUMBER) { 1514 if (property == Token::NUMBER) {
1520 old = finder_.AddNumber(scanner()->literal_ascii_string(), type); 1515 old = finder_.AddNumber(scanner()->literal_one_byte_string(), type);
1521 } else if (scanner()->is_literal_ascii()) { 1516 } else if (scanner()->is_literal_one_byte()) {
1522 old = finder_.AddAsciiSymbol(scanner()->literal_ascii_string(), type); 1517 old = finder_.AddAsciiSymbol(scanner()->literal_one_byte_string(), type);
1523 } else { 1518 } else {
1524 old = finder_.AddUtf16Symbol(scanner()->literal_utf16_string(), type); 1519 old = finder_.AddUtf16Symbol(scanner()->literal_utf16_string(), type);
1525 } 1520 }
1526 PropertyKind old_type = static_cast<PropertyKind>(old); 1521 PropertyKind old_type = static_cast<PropertyKind>(old);
1527 if (HasConflict(old_type, type)) { 1522 if (HasConflict(old_type, type)) {
1528 if (IsDataDataConflict(old_type, type)) { 1523 if (IsDataDataConflict(old_type, type)) {
1529 // Both are data properties. 1524 // Both are data properties.
1530 if (strict_mode_ == SLOPPY) return; 1525 if (strict_mode_ == SLOPPY) return;
1531 parser()->ReportMessageAt(scanner()->location(), 1526 parser()->ReportMessageAt(scanner()->location(),
1532 "strict_duplicate_property"); 1527 "strict_duplicate_property");
1533 } else if (IsDataAccessorConflict(old_type, type)) { 1528 } else if (IsDataAccessorConflict(old_type, type)) {
1534 // Both a data and an accessor property with the same name. 1529 // Both a data and an accessor property with the same name.
1535 parser()->ReportMessageAt(scanner()->location(), 1530 parser()->ReportMessageAt(scanner()->location(),
1536 "accessor_data_property"); 1531 "accessor_data_property");
1537 } else { 1532 } else {
1538 ASSERT(IsAccessorAccessorConflict(old_type, type)); 1533 ASSERT(IsAccessorAccessorConflict(old_type, type));
1539 // Both accessors of the same type. 1534 // Both accessors of the same type.
1540 parser()->ReportMessageAt(scanner()->location(), 1535 parser()->ReportMessageAt(scanner()->location(),
1541 "accessor_get_set"); 1536 "accessor_get_set");
1542 } 1537 }
1543 *ok = false; 1538 *ok = false;
1544 } 1539 }
1545 } 1540 }
1546 1541
1547 1542
1548 } } // v8::internal 1543 } } // v8::internal
1549 1544
1550 #endif // V8_PREPARSER_H 1545 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698