OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 304 } |
305 #endif | 305 #endif |
306 | 306 |
307 | 307 |
308 bool StringStream::Put(String* str) { | 308 bool StringStream::Put(String* str) { |
309 return Put(str, 0, str->length()); | 309 return Put(str, 0, str->length()); |
310 } | 310 } |
311 | 311 |
312 | 312 |
313 bool StringStream::Put(String* str, int start, int end) { | 313 bool StringStream::Put(String* str, int start, int end) { |
314 ConsStringIteratorOp op; | 314 StringInputBuffer name_buffer(str); |
315 StringCharacterStream stream(str, &op, start); | 315 name_buffer.Seek(start); |
316 for (int i = start; i < end && stream.HasMore(); i++) { | 316 for (int i = start; i < end && name_buffer.has_more(); i++) { |
317 uint16_t c = stream.GetNext(); | 317 int c = name_buffer.GetNext(); |
318 if (c >= 127 || c < 32) { | 318 if (c >= 127 || c < 32) { |
319 c = '?'; | 319 c = '?'; |
320 } | 320 } |
321 if (!Put(static_cast<char>(c))) { | 321 if (!Put(c)) { |
322 return false; // Output was truncated. | 322 return false; // Output was truncated. |
323 } | 323 } |
324 } | 324 } |
325 return true; | 325 return true; |
326 } | 326 } |
327 | 327 |
328 | 328 |
329 void StringStream::PrintName(Object* name) { | 329 void StringStream::PrintName(Object* name) { |
330 if (name->IsString()) { | 330 if (name->IsString()) { |
331 String* str = String::cast(name); | 331 String* str = String::cast(name); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 583 |
584 // Only grow once to the maximum allowable size. | 584 // Only grow once to the maximum allowable size. |
585 char* NoAllocationStringAllocator::grow(unsigned* bytes) { | 585 char* NoAllocationStringAllocator::grow(unsigned* bytes) { |
586 ASSERT(size_ >= *bytes); | 586 ASSERT(size_ >= *bytes); |
587 *bytes = size_; | 587 *bytes = size_; |
588 return space_; | 588 return space_; |
589 } | 589 } |
590 | 590 |
591 | 591 |
592 } } // namespace v8::internal | 592 } } // namespace v8::internal |
OLD | NEW |