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

Side by Side Diff: src/preparser.cc

Issue 9600009: Fix input and output to handle UTF16 surrogate pairs. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 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
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 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 i::Token::Value property, 1207 i::Token::Value property,
1208 int type, 1208 int type,
1209 bool* ok) { 1209 bool* ok) {
1210 int old_type; 1210 int old_type;
1211 if (property == i::Token::NUMBER) { 1211 if (property == i::Token::NUMBER) {
1212 old_type = finder->AddNumber(scanner_->literal_ascii_string(), type); 1212 old_type = finder->AddNumber(scanner_->literal_ascii_string(), type);
1213 } else if (scanner_->is_literal_ascii()) { 1213 } else if (scanner_->is_literal_ascii()) {
1214 old_type = finder->AddAsciiSymbol(scanner_->literal_ascii_string(), 1214 old_type = finder->AddAsciiSymbol(scanner_->literal_ascii_string(),
1215 type); 1215 type);
1216 } else { 1216 } else {
1217 old_type = finder->AddUC16Symbol(scanner_->literal_uc16_string(), type); 1217 old_type = finder->AddUtf16Symbol(scanner_->literal_utf16_string(), type);
1218 } 1218 }
1219 if (HasConflict(old_type, type)) { 1219 if (HasConflict(old_type, type)) {
1220 if (IsDataDataConflict(old_type, type)) { 1220 if (IsDataDataConflict(old_type, type)) {
1221 // Both are data properties. 1221 // Both are data properties.
1222 if (is_classic_mode()) return; 1222 if (is_classic_mode()) return;
1223 ReportMessageAt(scanner_->location(), 1223 ReportMessageAt(scanner_->location(),
1224 "strict_duplicate_property", NULL); 1224 "strict_duplicate_property", NULL);
1225 } else if (IsDataAccessorConflict(old_type, type)) { 1225 } else if (IsDataAccessorConflict(old_type, type)) {
1226 // Both a data and an accessor property with the same name. 1226 // Both a data and an accessor property with the same name.
1227 ReportMessageAt(scanner_->location(), 1227 ReportMessageAt(scanner_->location(),
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 "strict_param_name", 1380 "strict_param_name",
1381 id, 1381 id,
1382 CHECK_OK); 1382 CHECK_OK);
1383 } 1383 }
1384 int prev_value; 1384 int prev_value;
1385 if (scanner_->is_literal_ascii()) { 1385 if (scanner_->is_literal_ascii()) {
1386 prev_value = 1386 prev_value =
1387 duplicate_finder.AddAsciiSymbol(scanner_->literal_ascii_string(), 1); 1387 duplicate_finder.AddAsciiSymbol(scanner_->literal_ascii_string(), 1);
1388 } else { 1388 } else {
1389 prev_value = 1389 prev_value =
1390 duplicate_finder.AddUC16Symbol(scanner_->literal_uc16_string(), 1); 1390 duplicate_finder.AddUtf16Symbol(scanner_->literal_utf16_string(), 1);
1391 } 1391 }
1392 1392
1393 if (prev_value != 0) { 1393 if (prev_value != 0) {
1394 SetStrictModeViolation(scanner_->location(), 1394 SetStrictModeViolation(scanner_->location(),
1395 "strict_param_dupe", 1395 "strict_param_dupe",
1396 CHECK_OK); 1396 CHECK_OK);
1397 } 1397 }
1398 done = (peek() == i::Token::RPAREN); 1398 done = (peek() == i::Token::RPAREN);
1399 if (!done) { 1399 if (!done) {
1400 Expect(i::Token::COMMA, CHECK_OK); 1400 Expect(i::Token::COMMA, CHECK_OK);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 } 1478 }
1479 Expect(i::Token::SEMICOLON, ok); 1479 Expect(i::Token::SEMICOLON, ok);
1480 } 1480 }
1481 1481
1482 1482
1483 void PreParser::LogSymbol() { 1483 void PreParser::LogSymbol() {
1484 int identifier_pos = scanner_->location().beg_pos; 1484 int identifier_pos = scanner_->location().beg_pos;
1485 if (scanner_->is_literal_ascii()) { 1485 if (scanner_->is_literal_ascii()) {
1486 log_->LogAsciiSymbol(identifier_pos, scanner_->literal_ascii_string()); 1486 log_->LogAsciiSymbol(identifier_pos, scanner_->literal_ascii_string());
1487 } else { 1487 } else {
1488 log_->LogUC16Symbol(identifier_pos, scanner_->literal_uc16_string()); 1488 log_->LogUtf16Symbol(identifier_pos, scanner_->literal_utf16_string());
1489 } 1489 }
1490 } 1490 }
1491 1491
1492 1492
1493 PreParser::Expression PreParser::GetStringSymbol() { 1493 PreParser::Expression PreParser::GetStringSymbol() {
1494 const int kUseStrictLength = 10; 1494 const int kUseStrictLength = 10;
1495 const char* kUseStrictChars = "use strict"; 1495 const char* kUseStrictChars = "use strict";
1496 LogSymbol(); 1496 LogSymbol();
1497 if (scanner_->is_literal_ascii() && 1497 if (scanner_->is_literal_ascii() &&
1498 scanner_->literal_length() == kUseStrictLength && 1498 scanner_->literal_length() == kUseStrictLength &&
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 return next == i::Token::IDENTIFIER || 1650 return next == i::Token::IDENTIFIER ||
1651 next == i::Token::FUTURE_RESERVED_WORD || 1651 next == i::Token::FUTURE_RESERVED_WORD ||
1652 next == i::Token::FUTURE_STRICT_RESERVED_WORD; 1652 next == i::Token::FUTURE_STRICT_RESERVED_WORD;
1653 } 1653 }
1654 1654
1655 1655
1656 int DuplicateFinder::AddAsciiSymbol(i::Vector<const char> key, int value) { 1656 int DuplicateFinder::AddAsciiSymbol(i::Vector<const char> key, int value) {
1657 return AddSymbol(i::Vector<const byte>::cast(key), true, value); 1657 return AddSymbol(i::Vector<const byte>::cast(key), true, value);
1658 } 1658 }
1659 1659
1660 int DuplicateFinder::AddUC16Symbol(i::Vector<const uint16_t> key, int value) { 1660 int DuplicateFinder::AddUtf16Symbol(i::Vector<const uint16_t> key, int value) {
1661 return AddSymbol(i::Vector<const byte>::cast(key), false, value); 1661 return AddSymbol(i::Vector<const byte>::cast(key), false, value);
1662 } 1662 }
1663 1663
1664 int DuplicateFinder::AddSymbol(i::Vector<const byte> key, 1664 int DuplicateFinder::AddSymbol(i::Vector<const byte> key,
1665 bool is_ascii, 1665 bool is_ascii,
1666 int value) { 1666 int value) {
1667 uint32_t hash = Hash(key, is_ascii); 1667 uint32_t hash = Hash(key, is_ascii);
1668 byte* encoding = BackupKey(key, is_ascii); 1668 byte* encoding = BackupKey(key, is_ascii);
1669 i::HashMap::Entry* entry = map_.Lookup(encoding, hash, true); 1669 i::HashMap::Entry* entry = map_.Lookup(encoding, hash, true);
1670 int old_value = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); 1670 int old_value = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u)); 1779 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u));
1780 } 1780 }
1781 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u)); 1781 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u));
1782 } 1782 }
1783 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f)); 1783 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f));
1784 1784
1785 backing_store_.AddBlock(bytes); 1785 backing_store_.AddBlock(bytes);
1786 return backing_store_.EndSequence().start(); 1786 return backing_store_.EndSequence().start();
1787 } 1787 }
1788 } } // v8::preparser 1788 } } // v8::preparser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698