OLD | NEW |
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity)); | 207 Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity)); |
208 memcpy(new_store.start(), backing_store_.start(), position_); | 208 memcpy(new_store.start(), backing_store_.start(), position_); |
209 backing_store_.Dispose(); | 209 backing_store_.Dispose(); |
210 backing_store_ = new_store; | 210 backing_store_ = new_store; |
211 } | 211 } |
212 | 212 |
213 void ConvertToUC16() { | 213 void ConvertToUC16() { |
214 ASSERT(is_ascii_); | 214 ASSERT(is_ascii_); |
215 Vector<byte> new_store; | 215 Vector<byte> new_store; |
216 int new_content_size = position_ * kUC16Size; | 216 int new_content_size = position_ * kUC16Size; |
217 if (new_content_size > backing_store_.length()) { | 217 if (new_content_size >= backing_store_.length()) { |
| 218 // Ensure room for all currently read characters as UC16 as well |
| 219 // as the character about to be stored. |
218 new_store = Vector<byte>::New(NewCapacity(new_content_size)); | 220 new_store = Vector<byte>::New(NewCapacity(new_content_size)); |
219 } else { | 221 } else { |
220 new_store = backing_store_; | 222 new_store = backing_store_; |
221 } | 223 } |
222 char* src = reinterpret_cast<char*>(backing_store_.start()); | 224 char* src = reinterpret_cast<char*>(backing_store_.start()); |
223 uc16* dst = reinterpret_cast<uc16*>(new_store.start()); | 225 uc16* dst = reinterpret_cast<uc16*>(new_store.start()); |
224 for (int i = position_ - 1; i >= 0; i--) { | 226 for (int i = position_ - 1; i >= 0; i--) { |
225 dst[i] = src[i]; | 227 dst[i] = src[i]; |
226 } | 228 } |
227 if (new_store.start() != backing_store_.start()) { | 229 if (new_store.start() != backing_store_.start()) { |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 // keyword with the current prefix). | 616 // keyword with the current prefix). |
615 const char* keyword_; | 617 const char* keyword_; |
616 int counter_; | 618 int counter_; |
617 Token::Value keyword_token_; | 619 Token::Value keyword_token_; |
618 }; | 620 }; |
619 | 621 |
620 | 622 |
621 } } // namespace v8::internal | 623 } } // namespace v8::internal |
622 | 624 |
623 #endif // V8_SCANNER_BASE_H_ | 625 #endif // V8_SCANNER_BASE_H_ |
OLD | NEW |