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

Side by Side Diff: src/scanner.h

Issue 888613002: Initial switch to Chromium-style CHECK_* and DCHECK_* macros. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix slow dchecks. Created 5 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
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 #ifndef V8_SCANNER_H_ 7 #ifndef V8_SCANNER_H_
8 #define V8_SCANNER_H_ 8 #define V8_SCANNER_H_
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 bool literal_contains_escapes() const { 383 bool literal_contains_escapes() const {
384 Location location = current_.location; 384 Location location = current_.location;
385 int source_length = (location.end_pos - location.beg_pos); 385 int source_length = (location.end_pos - location.beg_pos);
386 if (current_.token == Token::STRING) { 386 if (current_.token == Token::STRING) {
387 // Subtract delimiters. 387 // Subtract delimiters.
388 source_length -= 2; 388 source_length -= 2;
389 } 389 }
390 return current_.literal_chars->length() != source_length; 390 return current_.literal_chars->length() != source_length;
391 } 391 }
392 bool is_literal_contextual_keyword(Vector<const char> keyword) { 392 bool is_literal_contextual_keyword(Vector<const char> keyword) {
393 DCHECK_NOT_NULL(current_.literal_chars); 393 DCHECK(current_.literal_chars);
394 return current_.literal_chars->is_contextual_keyword(keyword); 394 return current_.literal_chars->is_contextual_keyword(keyword);
395 } 395 }
396 bool is_next_contextual_keyword(Vector<const char> keyword) { 396 bool is_next_contextual_keyword(Vector<const char> keyword) {
397 DCHECK_NOT_NULL(next_.literal_chars); 397 DCHECK(next_.literal_chars);
398 return next_.literal_chars->is_contextual_keyword(keyword); 398 return next_.literal_chars->is_contextual_keyword(keyword);
399 } 399 }
400 400
401 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory); 401 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory);
402 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory); 402 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory);
403 const AstRawString* CurrentRawSymbol(AstValueFactory* ast_value_factory); 403 const AstRawString* CurrentRawSymbol(AstValueFactory* ast_value_factory);
404 404
405 double DoubleValue(); 405 double DoubleValue();
406 bool LiteralMatches(const char* data, int length, bool allow_escapes = true) { 406 bool LiteralMatches(const char* data, int length, bool allow_escapes = true) {
407 if (is_literal_one_byte() && 407 if (is_literal_one_byte() &&
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 free_buffer->Reset(); 529 free_buffer->Reset();
530 next_.literal_chars = free_buffer; 530 next_.literal_chars = free_buffer;
531 } 531 }
532 532
533 inline void StartRawLiteral() { 533 inline void StartRawLiteral() {
534 raw_literal_buffer_.Reset(); 534 raw_literal_buffer_.Reset();
535 next_.raw_literal_chars = &raw_literal_buffer_; 535 next_.raw_literal_chars = &raw_literal_buffer_;
536 } 536 }
537 537
538 INLINE(void AddLiteralChar(uc32 c)) { 538 INLINE(void AddLiteralChar(uc32 c)) {
539 DCHECK_NOT_NULL(next_.literal_chars); 539 DCHECK(next_.literal_chars);
540 next_.literal_chars->AddChar(c); 540 next_.literal_chars->AddChar(c);
541 } 541 }
542 542
543 INLINE(void AddRawLiteralChar(uc32 c)) { 543 INLINE(void AddRawLiteralChar(uc32 c)) {
544 DCHECK_NOT_NULL(next_.raw_literal_chars); 544 DCHECK(next_.raw_literal_chars);
545 next_.raw_literal_chars->AddChar(c); 545 next_.raw_literal_chars->AddChar(c);
546 } 546 }
547 547
548 INLINE(void ReduceRawLiteralLength(int delta)) { 548 INLINE(void ReduceRawLiteralLength(int delta)) {
549 DCHECK_NOT_NULL(next_.raw_literal_chars); 549 DCHECK(next_.raw_literal_chars);
550 next_.raw_literal_chars->ReduceLength(delta); 550 next_.raw_literal_chars->ReduceLength(delta);
551 } 551 }
552 552
553 // Stops scanning of a literal and drop the collected characters, 553 // Stops scanning of a literal and drop the collected characters,
554 // e.g., due to an encountered error. 554 // e.g., due to an encountered error.
555 inline void DropLiteral() { 555 inline void DropLiteral() {
556 next_.literal_chars = NULL; 556 next_.literal_chars = NULL;
557 next_.raw_literal_chars = NULL; 557 next_.raw_literal_chars = NULL;
558 } 558 }
559 559
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 } 605 }
606 606
607 // Returns the literal string, if any, for the current token (the 607 // Returns the literal string, if any, for the current token (the
608 // token last returned by Next()). The string is 0-terminated. 608 // token last returned by Next()). The string is 0-terminated.
609 // Literal strings are collected for identifiers, strings, numbers as well 609 // Literal strings are collected for identifiers, strings, numbers as well
610 // as for template literals. For template literals we also collect the raw 610 // as for template literals. For template literals we also collect the raw
611 // form. 611 // form.
612 // These functions only give the correct result if the literal was scanned 612 // These functions only give the correct result if the literal was scanned
613 // when a LiteralScope object is alive. 613 // when a LiteralScope object is alive.
614 Vector<const uint8_t> literal_one_byte_string() { 614 Vector<const uint8_t> literal_one_byte_string() {
615 DCHECK_NOT_NULL(current_.literal_chars); 615 DCHECK(current_.literal_chars);
616 return current_.literal_chars->one_byte_literal(); 616 return current_.literal_chars->one_byte_literal();
617 } 617 }
618 Vector<const uint16_t> literal_two_byte_string() { 618 Vector<const uint16_t> literal_two_byte_string() {
619 DCHECK_NOT_NULL(current_.literal_chars); 619 DCHECK(current_.literal_chars);
620 return current_.literal_chars->two_byte_literal(); 620 return current_.literal_chars->two_byte_literal();
621 } 621 }
622 bool is_literal_one_byte() { 622 bool is_literal_one_byte() {
623 DCHECK_NOT_NULL(current_.literal_chars); 623 DCHECK(current_.literal_chars);
624 return current_.literal_chars->is_one_byte(); 624 return current_.literal_chars->is_one_byte();
625 } 625 }
626 int literal_length() const { 626 int literal_length() const {
627 DCHECK_NOT_NULL(current_.literal_chars); 627 DCHECK(current_.literal_chars);
628 return current_.literal_chars->length(); 628 return current_.literal_chars->length();
629 } 629 }
630 // Returns the literal string for the next token (the token that 630 // Returns the literal string for the next token (the token that
631 // would be returned if Next() were called). 631 // would be returned if Next() were called).
632 Vector<const uint8_t> next_literal_one_byte_string() { 632 Vector<const uint8_t> next_literal_one_byte_string() {
633 DCHECK_NOT_NULL(next_.literal_chars); 633 DCHECK(next_.literal_chars);
634 return next_.literal_chars->one_byte_literal(); 634 return next_.literal_chars->one_byte_literal();
635 } 635 }
636 Vector<const uint16_t> next_literal_two_byte_string() { 636 Vector<const uint16_t> next_literal_two_byte_string() {
637 DCHECK_NOT_NULL(next_.literal_chars); 637 DCHECK(next_.literal_chars);
638 return next_.literal_chars->two_byte_literal(); 638 return next_.literal_chars->two_byte_literal();
639 } 639 }
640 bool is_next_literal_one_byte() { 640 bool is_next_literal_one_byte() {
641 DCHECK_NOT_NULL(next_.literal_chars); 641 DCHECK(next_.literal_chars);
642 return next_.literal_chars->is_one_byte(); 642 return next_.literal_chars->is_one_byte();
643 } 643 }
644 Vector<const uint8_t> raw_literal_one_byte_string() { 644 Vector<const uint8_t> raw_literal_one_byte_string() {
645 DCHECK_NOT_NULL(current_.raw_literal_chars); 645 DCHECK(current_.raw_literal_chars);
646 return current_.raw_literal_chars->one_byte_literal(); 646 return current_.raw_literal_chars->one_byte_literal();
647 } 647 }
648 Vector<const uint16_t> raw_literal_two_byte_string() { 648 Vector<const uint16_t> raw_literal_two_byte_string() {
649 DCHECK_NOT_NULL(current_.raw_literal_chars); 649 DCHECK(current_.raw_literal_chars);
650 return current_.raw_literal_chars->two_byte_literal(); 650 return current_.raw_literal_chars->two_byte_literal();
651 } 651 }
652 bool is_raw_literal_one_byte() { 652 bool is_raw_literal_one_byte() {
653 DCHECK_NOT_NULL(current_.raw_literal_chars); 653 DCHECK(current_.raw_literal_chars);
654 return current_.raw_literal_chars->is_one_byte(); 654 return current_.raw_literal_chars->is_one_byte();
655 } 655 }
656 656
657 template <bool capture_raw> 657 template <bool capture_raw>
658 uc32 ScanHexNumber(int expected_length); 658 uc32 ScanHexNumber(int expected_length);
659 // Scan a number of any length but not bigger than max_value. For example, the 659 // Scan a number of any length but not bigger than max_value. For example, the
660 // number can be 000000001, so it's very long in characters but its value is 660 // number can be 000000001, so it's very long in characters but its value is
661 // small. 661 // small.
662 template <bool capture_raw> 662 template <bool capture_raw>
663 uc32 ScanUnlimitedLengthHexNumber(int max_value); 663 uc32 ScanUnlimitedLengthHexNumber(int max_value);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 bool harmony_classes_; 743 bool harmony_classes_;
744 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL 744 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL
745 bool harmony_templates_; 745 bool harmony_templates_;
746 // Whether we allow \u{xxxxx}. 746 // Whether we allow \u{xxxxx}.
747 bool harmony_unicode_; 747 bool harmony_unicode_;
748 }; 748 };
749 749
750 } } // namespace v8::internal 750 } } // namespace v8::internal
751 751
752 #endif // V8_SCANNER_H_ 752 #endif // V8_SCANNER_H_
OLDNEW
« src/jsregexp.cc ('K') | « src/runtime/runtime-array.cc ('k') | src/serialize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698