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

Side by Side Diff: src/lexer/lexer.cc

Issue 200323005: Experimental parser: fix generated lexer build after merge (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
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/lexer/lexer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 #include "lexer.h" 29 #include "lexer.h"
30 #include "char-predicates-inl.h" 30 #include "char-predicates-inl.h"
31 #include "scanner-character-streams.h" 31 #include "scanner-character-streams.h"
32 #include "parser.h"
32 33
33 namespace v8 { 34 namespace v8 {
34 namespace internal { 35 namespace internal {
35 36
36 37
37 #ifdef V8_USE_GENERATED_LEXER 38 #ifdef V8_USE_GENERATED_LEXER
38 39
39 40
40 void Scanner::Initialize(Utf16CharacterStream* source) { 41 void Scanner::Initialize(Utf16CharacterStream* source) {
41 delete lexer_; 42 delete lexer_;
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 one_byte_string_.Dispose(); 520 one_byte_string_.Dispose();
520 } 521 }
521 is_one_byte_string_owned_ = false; 522 is_one_byte_string_owned_ = false;
522 one_byte_string_ = buffer.one_byte_literal(); 523 one_byte_string_ = buffer.one_byte_literal();
523 } else { 524 } else {
524 two_byte_string_ = buffer.two_byte_literal(); 525 two_byte_string_ = buffer.two_byte_literal();
525 } 526 }
526 } 527 }
527 528
528 529
530 Handle<String> LexerBase::AllocateNextLiteralString(Isolate* isolate,
531 PretenureFlag tenured) {
532 if (is_next_literal_one_byte()) {
533 return isolate->factory()->NewStringFromOneByte(
534 Vector<const uint8_t>::cast(next_literal_one_byte_string()), tenured);
535 } else {
536 return isolate->factory()->NewStringFromTwoByte(
537 next_literal_two_byte_string(), tenured);
538 }
539 }
540
541
542 Handle<String> LexerBase::AllocateInternalizedString(Isolate* isolate) {
543 if (is_literal_one_byte()) {
544 return isolate->factory()->InternalizeOneByteString(
545 literal_one_byte_string());
546 } else {
547 return isolate->factory()->InternalizeTwoByteString(
548 literal_two_byte_string());
549 }
550 }
551
552
553 double LexerBase::DoubleValue() {
554 ASSERT(is_literal_one_byte());
555 return StringToDouble(
556 unicode_cache_, Vector<const char>::cast(literal_one_byte_string()),
557 ALLOW_HEX | ALLOW_OCTAL | ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY);
558 }
559
560
561 int LexerBase::FindNumber(DuplicateFinder* finder, int value) {
562 return finder->AddNumber(literal_one_byte_string(), value);
563 }
564
565
566 int LexerBase::FindSymbol(DuplicateFinder* finder, int value) {
567 if (is_literal_one_byte()) {
568 return finder->AddOneByteSymbol(literal_one_byte_string(), value);
569 }
570 return finder->AddTwoByteSymbol(literal_two_byte_string(), value);
571 }
572
573
574 void LexerBase::LogSymbol(ParserRecorder* log, int position) {
575 if (is_literal_one_byte()) {
576 log->LogOneByteSymbol(position, literal_one_byte_string());
577 } else {
578 log->LogTwoByteSymbol(position, literal_two_byte_string());
579 }
580 }
581
582
529 static inline bool IsOneByte(const uint8_t* cursor, const uint8_t* end) { 583 static inline bool IsOneByte(const uint8_t* cursor, const uint8_t* end) {
530 return true; 584 return true;
531 } 585 }
532 586
533 587
534 static inline bool IsOneByte(const uint16_t* cursor, const uint16_t* end) { 588 static inline bool IsOneByte(const uint16_t* cursor, const uint16_t* end) {
535 uint16_t acc = 0; 589 uint16_t acc = 0;
536 while (cursor != end) { 590 while (cursor != end) {
537 acc |= *cursor++ >> 8; 591 acc |= *cursor++ >> 8;
538 } 592 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 CHECK(false); 783 CHECK(false);
730 return Handle<String>(); 784 return Handle<String>();
731 } 785 }
732 786
733 787
734 template class Lexer<uint8_t>; 788 template class Lexer<uint8_t>;
735 template class Lexer<uint16_t>; 789 template class Lexer<uint16_t>;
736 template class Lexer<int8_t>; 790 template class Lexer<int8_t>;
737 791
738 } } // v8::internal 792 } } // v8::internal
OLDNEW
« no previous file with comments | « src/lexer/lexer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698