| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 } | 384 } |
| 385 | 385 |
| 386 inline Vector<T> operator+(int offset) { | 386 inline Vector<T> operator+(int offset) { |
| 387 ASSERT(offset < length_); | 387 ASSERT(offset < length_); |
| 388 return Vector<T>(start_ + offset, length_ - offset); | 388 return Vector<T>(start_ + offset, length_ - offset); |
| 389 } | 389 } |
| 390 | 390 |
| 391 // Factory method for creating empty vectors. | 391 // Factory method for creating empty vectors. |
| 392 static Vector<T> empty() { return Vector<T>(NULL, 0); } | 392 static Vector<T> empty() { return Vector<T>(NULL, 0); } |
| 393 | 393 |
| 394 template<typename S> |
| 395 static Vector<T> cast(Vector<S> input) { |
| 396 return Vector<T>(reinterpret_cast<T*>(input.start()), |
| 397 input.length() * sizeof(S) / sizeof(T)); |
| 398 } |
| 399 |
| 394 protected: | 400 protected: |
| 395 void set_start(T* start) { start_ = start; } | 401 void set_start(T* start) { start_ = start; } |
| 396 | 402 |
| 397 private: | 403 private: |
| 398 T* start_; | 404 T* start_; |
| 399 int length_; | 405 int length_; |
| 400 }; | 406 }; |
| 401 | 407 |
| 402 | 408 |
| 403 // A temporary assignment sets a (non-local) variable to a value on | 409 // A temporary assignment sets a (non-local) variable to a value on |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 } | 953 } |
| 948 | 954 |
| 949 template <class Dest, class Source> | 955 template <class Dest, class Source> |
| 950 inline Dest BitCast(Source* source) { | 956 inline Dest BitCast(Source* source) { |
| 951 return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); | 957 return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); |
| 952 } | 958 } |
| 953 | 959 |
| 954 } } // namespace v8::internal | 960 } } // namespace v8::internal |
| 955 | 961 |
| 956 #endif // V8_UTILS_H_ | 962 #endif // V8_UTILS_H_ |
| OLD | NEW |