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

Side by Side Diff: src/scanner.cc

Issue 1201783003: Allow numeric literals to be checked for a decimal point. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/scanner.h ('k') | test/cctest/test-parsing.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Features shared by parsing and pre-parsing scanners. 5 // Features shared by parsing and pre-parsing scanners.
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 1426
1427 double Scanner::DoubleValue() { 1427 double Scanner::DoubleValue() {
1428 DCHECK(is_literal_one_byte()); 1428 DCHECK(is_literal_one_byte());
1429 return StringToDouble( 1429 return StringToDouble(
1430 unicode_cache_, 1430 unicode_cache_,
1431 literal_one_byte_string(), 1431 literal_one_byte_string(),
1432 ALLOW_HEX | ALLOW_OCTAL | ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY); 1432 ALLOW_HEX | ALLOW_OCTAL | ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY);
1433 } 1433 }
1434 1434
1435 1435
1436 bool Scanner::ContainsDot() {
Sven Panne 2015/06/22 07:53:43 Instead of using caveman-style loops, the right wa
bradn 2015/06/23 06:54:07 Turns out Vector<> provides begin/end, which allow
1437 DCHECK(is_literal_one_byte());
1438 Vector<const uint8_t> literal_string = literal_one_byte_string();
titzer 2015/06/22 07:08:16 Does this make a copy of the bytes underneath?
bradn 2015/06/23 06:54:07 No, it copies a reference to the underying buffer
1439 bool with_dot = false;
1440 for (int i = 0; !with_dot && i < literal_string.length(); ++i) {
1441 with_dot |= (literal_string[i] == '.');
titzer 2015/06/22 07:08:16 Early return?
bradn 2015/06/23 06:54:07 Replaced. FWIW was lifted wholesale from a prototy
1442 }
1443 return with_dot;
1444 }
1445
1446
1436 int Scanner::FindSymbol(DuplicateFinder* finder, int value) { 1447 int Scanner::FindSymbol(DuplicateFinder* finder, int value) {
1437 if (is_literal_one_byte()) { 1448 if (is_literal_one_byte()) {
1438 return finder->AddOneByteSymbol(literal_one_byte_string(), value); 1449 return finder->AddOneByteSymbol(literal_one_byte_string(), value);
1439 } 1450 }
1440 return finder->AddTwoByteSymbol(literal_two_byte_string(), value); 1451 return finder->AddTwoByteSymbol(literal_two_byte_string(), value);
1441 } 1452 }
1442 1453
1443 1454
1444 bool Scanner::SetBookmark() { 1455 bool Scanner::SetBookmark() {
1445 if (c0_ != kNoBookmark && bookmark_c0_ == kNoBookmark && 1456 if (c0_ != kNoBookmark && bookmark_c0_ == kNoBookmark &&
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); 1636 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u));
1626 } 1637 }
1627 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); 1638 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f));
1628 1639
1629 backing_store_.AddBlock(bytes); 1640 backing_store_.AddBlock(bytes);
1630 return backing_store_.EndSequence().start(); 1641 return backing_store_.EndSequence().start();
1631 } 1642 }
1632 1643
1633 } // namespace internal 1644 } // namespace internal
1634 } // namespace v8 1645 } // namespace v8
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698