| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 9323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9334 inline uc32 Get(int index); | 9334 inline uc32 Get(int index); |
| 9335 int length() { return length_; } | 9335 int length() { return length_; } |
| 9336 private: | 9336 private: |
| 9337 String** str_; | 9337 String** str_; |
| 9338 bool is_one_byte_; | 9338 bool is_one_byte_; |
| 9339 int length_; | 9339 int length_; |
| 9340 const void* start_; | 9340 const void* start_; |
| 9341 }; | 9341 }; |
| 9342 | 9342 |
| 9343 | 9343 |
| 9344 // A ConsStringOp that returns null. | |
| 9345 // Useful when the operation to apply on a ConsString | |
| 9346 // requires an expensive data structure. | |
| 9347 class ConsStringNullOp { | |
| 9348 public: | |
| 9349 inline ConsStringNullOp() {} | |
| 9350 static inline String* Operate(String*, unsigned*, int32_t*, unsigned*); | |
| 9351 private: | |
| 9352 DISALLOW_COPY_AND_ASSIGN(ConsStringNullOp); | |
| 9353 }; | |
| 9354 | |
| 9355 | |
| 9356 // This maintains an off-stack representation of the stack frames required | 9344 // This maintains an off-stack representation of the stack frames required |
| 9357 // to traverse a ConsString, allowing an entirely iterative and restartable | 9345 // to traverse a ConsString, allowing an entirely iterative and restartable |
| 9358 // traversal of the entire string | 9346 // traversal of the entire string |
| 9359 class ConsStringIteratorOp { | 9347 class ConsStringIterator { |
| 9360 public: | 9348 public: |
| 9361 inline ConsStringIteratorOp() {} | 9349 inline ConsStringIterator() {} |
| 9362 inline explicit ConsStringIteratorOp(ConsString* cons_string, | 9350 inline explicit ConsStringIterator(ConsString* cons_string, int offset = 0) { |
| 9363 int offset = 0) { | |
| 9364 Reset(cons_string, offset); | 9351 Reset(cons_string, offset); |
| 9365 } | 9352 } |
| 9366 inline void Reset(ConsString* cons_string, int offset = 0) { | 9353 inline void Reset(ConsString* cons_string, int offset = 0) { |
| 9367 depth_ = 0; | 9354 depth_ = 0; |
| 9368 // Next will always return NULL. | 9355 // Next will always return NULL. |
| 9369 if (cons_string == NULL) return; | 9356 if (cons_string == NULL) return; |
| 9370 Initialize(cons_string, offset); | 9357 Initialize(cons_string, offset); |
| 9371 } | 9358 } |
| 9372 // Returns NULL when complete. | 9359 // Returns NULL when complete. |
| 9373 inline String* Next(int* offset_out) { | 9360 inline String* Next(int* offset_out) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 9393 String* NextLeaf(bool* blew_stack); | 9380 String* NextLeaf(bool* blew_stack); |
| 9394 String* Search(int* offset_out); | 9381 String* Search(int* offset_out); |
| 9395 | 9382 |
| 9396 // Stack must always contain only frames for which right traversal | 9383 // Stack must always contain only frames for which right traversal |
| 9397 // has not yet been performed. | 9384 // has not yet been performed. |
| 9398 ConsString* frames_[kStackSize]; | 9385 ConsString* frames_[kStackSize]; |
| 9399 ConsString* root_; | 9386 ConsString* root_; |
| 9400 int depth_; | 9387 int depth_; |
| 9401 int maximum_depth_; | 9388 int maximum_depth_; |
| 9402 int consumed_; | 9389 int consumed_; |
| 9403 DISALLOW_COPY_AND_ASSIGN(ConsStringIteratorOp); | 9390 DISALLOW_COPY_AND_ASSIGN(ConsStringIterator); |
| 9404 }; | 9391 }; |
| 9405 | 9392 |
| 9406 | 9393 |
| 9407 class StringCharacterStream { | 9394 class StringCharacterStream { |
| 9408 public: | 9395 public: |
| 9409 inline StringCharacterStream(String* string, | 9396 inline StringCharacterStream(String* string, |
| 9410 ConsStringIteratorOp* op, | |
| 9411 int offset = 0); | 9397 int offset = 0); |
| 9412 inline uint16_t GetNext(); | 9398 inline uint16_t GetNext(); |
| 9413 inline bool HasMore(); | 9399 inline bool HasMore(); |
| 9414 inline void Reset(String* string, int offset = 0); | 9400 inline void Reset(String* string, int offset = 0); |
| 9415 inline void VisitOneByteString(const uint8_t* chars, int length); | 9401 inline void VisitOneByteString(const uint8_t* chars, int length); |
| 9416 inline void VisitTwoByteString(const uint16_t* chars, int length); | 9402 inline void VisitTwoByteString(const uint16_t* chars, int length); |
| 9417 | 9403 |
| 9418 private: | 9404 private: |
| 9405 ConsStringIterator iter_; |
| 9419 bool is_one_byte_; | 9406 bool is_one_byte_; |
| 9420 union { | 9407 union { |
| 9421 const uint8_t* buffer8_; | 9408 const uint8_t* buffer8_; |
| 9422 const uint16_t* buffer16_; | 9409 const uint16_t* buffer16_; |
| 9423 }; | 9410 }; |
| 9424 const uint8_t* end_; | 9411 const uint8_t* end_; |
| 9425 ConsStringIteratorOp* op_; | |
| 9426 DISALLOW_COPY_AND_ASSIGN(StringCharacterStream); | 9412 DISALLOW_COPY_AND_ASSIGN(StringCharacterStream); |
| 9427 }; | 9413 }; |
| 9428 | 9414 |
| 9429 | 9415 |
| 9430 template <typename T> | 9416 template <typename T> |
| 9431 class VectorIterator { | 9417 class VectorIterator { |
| 9432 public: | 9418 public: |
| 9433 VectorIterator(T* d, int l) : data_(Vector<const T>(d, l)), index_(0) { } | 9419 VectorIterator(T* d, int l) : data_(Vector<const T>(d, l)), index_(0) { } |
| 9434 explicit VectorIterator(Vector<const T> data) : data_(data), index_(0) { } | 9420 explicit VectorIterator(Vector<const T> data) : data_(data), index_(0) { } |
| 9435 T GetNext() { return data_[index_++]; } | 9421 T GetNext() { return data_[index_++]; } |
| (...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10910 } else { | 10896 } else { |
| 10911 value &= ~(1 << bit_position); | 10897 value &= ~(1 << bit_position); |
| 10912 } | 10898 } |
| 10913 return value; | 10899 return value; |
| 10914 } | 10900 } |
| 10915 }; | 10901 }; |
| 10916 | 10902 |
| 10917 } } // namespace v8::internal | 10903 } } // namespace v8::internal |
| 10918 | 10904 |
| 10919 #endif // V8_OBJECTS_H_ | 10905 #endif // V8_OBJECTS_H_ |
| OLD | NEW |