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

Side by Side Diff: src/scanner.cc

Issue 6459021: Fix incorrect asserts in scanner. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build-ia32
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1126.js » ('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 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // contains valid data that comes just after the pushback. 69 // contains valid data that comes just after the pushback.
70 // 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
71 // start of the buffer. 71 // start of the buffer.
72 72
73 if (pushback_limit_ == NULL) { 73 if (pushback_limit_ == NULL) {
74 // Enter pushback mode. 74 // Enter pushback mode.
75 pushback_limit_ = buffer_end_; 75 pushback_limit_ = buffer_end_;
76 buffer_end_ = buffer_ + kBufferSize; 76 buffer_end_ = buffer_ + kBufferSize;
77 buffer_cursor_ = buffer_end_; 77 buffer_cursor_ = buffer_end_;
78 } 78 }
79 ASSERT(pushback_limit_ > buffer_); 79 // Ensure that there is room for at least one pushback.
80 ASSERT(buffer_cursor_ > buffer_);
80 ASSERT(pos_ > 0); 81 ASSERT(pos_ > 0);
81 buffer_[--buffer_cursor_ - buffer_] = character; 82 buffer_[--buffer_cursor_ - buffer_] = character;
82 if (buffer_cursor_ == buffer_) { 83 if (buffer_cursor_ == buffer_) {
83 pushback_limit_ = NULL; 84 pushback_limit_ = NULL;
84 } else if (buffer_cursor_ < pushback_limit_) { 85 } else if (buffer_cursor_ < pushback_limit_) {
85 pushback_limit_ = buffer_cursor_; 86 pushback_limit_ = buffer_cursor_;
86 } 87 }
87 pos_--; 88 pos_--;
88 } 89 }
89 90
90 91
91 bool BufferedUC16CharacterStream::ReadBlock() { 92 bool BufferedUC16CharacterStream::ReadBlock() {
93 buffer_cursor_ = buffer_;
92 if (pushback_limit_ != NULL) { 94 if (pushback_limit_ != NULL) {
93 buffer_cursor_ = buffer_; 95 // Leave pushback mode.
94 buffer_end_ = pushback_limit_; 96 buffer_end_ = pushback_limit_;
95 pushback_limit_ = NULL; 97 pushback_limit_ = NULL;
96 ASSERT(buffer_cursor_ != buffer_end_); 98 // If there were any valid characters left at the
97 return true; 99 // start of the buffer, use those.
100 if (buffer_cursor_ < buffer_end_) return true;
101 // Otherwise read a new block.
98 } 102 }
99 unsigned length = FillBuffer(pos_, kBufferSize); 103 unsigned length = FillBuffer(pos_, kBufferSize);
100 buffer_cursor_ = buffer_;
101 buffer_end_ = buffer_ + length; 104 buffer_end_ = buffer_ + length;
102 return length > 0; 105 return length > 0;
103 } 106 }
104 107
105 108
106 unsigned BufferedUC16CharacterStream::SlowSeekForward(unsigned delta) { 109 unsigned BufferedUC16CharacterStream::SlowSeekForward(unsigned delta) {
107 // Leave pushback mode (i.e., ignore that there might be valid data 110 // Leave pushback mode (i.e., ignore that there might be valid data
108 // in the buffer before the pushback_limit_ point). 111 // in the buffer before the pushback_limit_ point).
109 pushback_limit_ = NULL; 112 pushback_limit_ = NULL;
110 return BufferSeekForward(delta); 113 return BufferSeekForward(delta);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 text++; 577 text++;
575 } 578 }
576 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL; 579 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL;
577 literal.Complete(); 580 literal.Complete();
578 return token; 581 return token;
579 } 582 }
580 583
581 584
582 585
583 } } // namespace v8::internal 586 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1126.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698