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

Side by Side Diff: src/scanner.cc

Issue 6246004: Fix bug when the scanner does a pushback at the end of input. (Closed)
Patch Set: Created 9 years, 11 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 30 matching lines...) Expand all
41 BufferedUC16CharacterStream::BufferedUC16CharacterStream() 41 BufferedUC16CharacterStream::BufferedUC16CharacterStream()
42 : UC16CharacterStream(), 42 : UC16CharacterStream(),
43 pushback_limit_(NULL) { 43 pushback_limit_(NULL) {
44 // Initialize buffer as being empty. First read will fill the buffer. 44 // Initialize buffer as being empty. First read will fill the buffer.
45 buffer_cursor_ = buffer_; 45 buffer_cursor_ = buffer_;
46 buffer_end_ = buffer_; 46 buffer_end_ = buffer_;
47 } 47 }
48 48
49 BufferedUC16CharacterStream::~BufferedUC16CharacterStream() { } 49 BufferedUC16CharacterStream::~BufferedUC16CharacterStream() { }
50 50
51 void BufferedUC16CharacterStream::PushBack(uc16 character) { 51 void BufferedUC16CharacterStream::PushBack(uc32 character) {
52 if (pushback_limit_ == NULL && buffer_cursor_ > buffer_) { 52 if (character == kEndOfInput) {
53 // buffer_ is writable, buffer_cursor_ is const pointer.
54 buffer_[--buffer_cursor_ - buffer_] = character;
55 pos_--; 53 pos_--;
56 return; 54 return;
57 } 55 }
58 SlowPushBack(character); 56 if (pushback_limit_ == NULL && buffer_cursor_ > buffer_) {
57 // buffer_ is writable, buffer_cursor_ is const pointer.
58 buffer_[--buffer_cursor_ - buffer_] = static_cast<uc16>(character);
59 pos_--;
60 return;
61 }
62 SlowPushBack(static_cast<uc16>(character));
59 } 63 }
60 64
61 65
62 void BufferedUC16CharacterStream::SlowPushBack(uc16 character) { 66 void BufferedUC16CharacterStream::SlowPushBack(uc16 character) {
63 // In pushback mode, the end of the buffer contains pushback, 67 // In pushback mode, the end of the buffer contains pushback,
64 // and the start of the buffer (from buffer start to pushback_limit_) 68 // and the start of the buffer (from buffer start to pushback_limit_)
65 // contains valid data that comes just after the pushback. 69 // contains valid data that comes just after the pushback.
66 // We NULL the pushback_limit_ if pushing all the way back to the 70 // We NULL the pushback_limit_ if pushing all the way back to the
67 // start of the buffer. 71 // start of the buffer.
68 72
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 text++; 557 text++;
554 } 558 }
555 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL; 559 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL;
556 literal.Complete(); 560 literal.Complete();
557 return token; 561 return token;
558 } 562 }
559 563
560 564
561 565
562 } } // namespace v8::internal 566 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | src/scanner-base.h » ('j') | src/scanner-base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698