Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 // Spidermonkey. | 238 // Spidermonkey. |
| 239 return c == 0xFFFE; | 239 return c == 0xFFFE; |
| 240 } | 240 } |
| 241 | 241 |
| 242 | 242 |
| 243 bool Scanner::SkipWhiteSpace() { | 243 bool Scanner::SkipWhiteSpace() { |
| 244 int start_position = source_pos(); | 244 int start_position = source_pos(); |
| 245 | 245 |
| 246 while (true) { | 246 while (true) { |
| 247 while (true) { | 247 while (true) { |
| 248 // The unicode cache accepts unsigned inputs. | |
| 249 if (c0_ < 0) break; | |
|
Sven Panne
2014/11/05 09:11:49
How is this related to the bitfield fiddling?
Jakob Kummerow
2014/11/05 12:13:46
As the comment says, the unicode_cache_ only accep
| |
| 248 // Advance as long as character is a WhiteSpace or LineTerminator. | 250 // Advance as long as character is a WhiteSpace or LineTerminator. |
| 249 // Remember if the latter is the case. | 251 // Remember if the latter is the case. |
| 250 if (unicode_cache_->IsLineTerminator(c0_)) { | 252 if (unicode_cache_->IsLineTerminator(c0_)) { |
| 251 has_line_terminator_before_next_ = true; | 253 has_line_terminator_before_next_ = true; |
| 252 } else if (!unicode_cache_->IsWhiteSpace(c0_) && | 254 } else if (!unicode_cache_->IsWhiteSpace(c0_) && |
| 253 !IsLittleEndianByteOrderMark(c0_)) { | 255 !IsLittleEndianByteOrderMark(c0_)) { |
| 254 break; | 256 break; |
| 255 } | 257 } |
| 256 Advance(); | 258 Advance(); |
| 257 } | 259 } |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 | 620 |
| 619 case '?': | 621 case '?': |
| 620 token = Select(Token::CONDITIONAL); | 622 token = Select(Token::CONDITIONAL); |
| 621 break; | 623 break; |
| 622 | 624 |
| 623 case '~': | 625 case '~': |
| 624 token = Select(Token::BIT_NOT); | 626 token = Select(Token::BIT_NOT); |
| 625 break; | 627 break; |
| 626 | 628 |
| 627 default: | 629 default: |
| 628 if (unicode_cache_->IsIdentifierStart(c0_)) { | 630 if (c0_ < 0) { |
| 631 token = Token::EOS; | |
|
Sven Panne
2014/11/05 09:11:49
Same here...
| |
| 632 } else if (unicode_cache_->IsIdentifierStart(c0_)) { | |
| 629 token = ScanIdentifierOrKeyword(); | 633 token = ScanIdentifierOrKeyword(); |
| 630 } else if (IsDecimalDigit(c0_)) { | 634 } else if (IsDecimalDigit(c0_)) { |
| 631 token = ScanNumber(false); | 635 token = ScanNumber(false); |
| 632 } else if (SkipWhiteSpace()) { | 636 } else if (SkipWhiteSpace()) { |
| 633 token = Token::WHITESPACE; | 637 token = Token::WHITESPACE; |
| 634 } else if (c0_ < 0) { | |
| 635 token = Token::EOS; | |
| 636 } else { | 638 } else { |
| 637 token = Select(Token::ILLEGAL); | 639 token = Select(Token::ILLEGAL); |
| 638 } | 640 } |
| 639 break; | 641 break; |
| 640 } | 642 } |
| 641 | 643 |
| 642 // Continue scanning for tokens as long as we're just skipping | 644 // Continue scanning for tokens as long as we're just skipping |
| 643 // whitespace. | 645 // whitespace. |
| 644 } while (token == Token::WHITESPACE); | 646 } while (token == Token::WHITESPACE); |
| 645 | 647 |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1344 } | 1346 } |
| 1345 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1347 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
| 1346 } | 1348 } |
| 1347 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1349 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
| 1348 | 1350 |
| 1349 backing_store_.AddBlock(bytes); | 1351 backing_store_.AddBlock(bytes); |
| 1350 return backing_store_.EndSequence().start(); | 1352 return backing_store_.EndSequence().start(); |
| 1351 } | 1353 } |
| 1352 | 1354 |
| 1353 } } // namespace v8::internal | 1355 } } // namespace v8::internal |
| OLD | NEW |