diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-12-07 13:56:11 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-12-07 13:56:11 -0800 |
commit | c30f1137121315b0d3641af6dc61e3b047f940e1 (patch) | |
tree | f118eaf670505e6a63f28bc8df845520f67adc55 /deps/v8/src/utils.h | |
parent | 5b8c62f7d12c1c5a553e765ba05bbd8a7e17ee47 (diff) | |
download | node-new-c30f1137121315b0d3641af6dc61e3b047f940e1.tar.gz |
Upgrade V8 to 3.0.0
Diffstat (limited to 'deps/v8/src/utils.h')
-rw-r--r-- | deps/v8/src/utils.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/deps/v8/src/utils.h b/deps/v8/src/utils.h index 12b7a18e80..5e65a4b9dd 100644 --- a/deps/v8/src/utils.h +++ b/deps/v8/src/utils.h @@ -226,6 +226,11 @@ class BitField { static T decode(uint32_t value) { return static_cast<T>((value & mask()) >> shift); } + + // Value for the field with all bits set. + static T max() { + return decode(mask()); + } }; @@ -326,7 +331,7 @@ class Vector { return start_[index]; } - T& at(int i) const { return operator[](i); } + const T& at(int index) const { return operator[](index); } T& first() { return start_[0]; } @@ -387,11 +392,40 @@ class Vector { }; +// A pointer that can only be set once and doesn't allow NULL values. +template<typename T> +class SetOncePointer { + public: + SetOncePointer() : pointer_(NULL) { } + + bool is_set() const { return pointer_ != NULL; } + + T* get() const { + ASSERT(pointer_ != NULL); + return pointer_; + } + + void set(T* value) { + ASSERT(pointer_ == NULL && value != NULL); + pointer_ = value; + } + + private: + T* pointer_; +}; + + template <typename T, int kSize> class EmbeddedVector : public Vector<T> { public: EmbeddedVector() : Vector<T>(buffer_, kSize) { } + explicit EmbeddedVector(T initial_value) : Vector<T>(buffer_, kSize) { + for (int i = 0; i < kSize; ++i) { + buffer_[i] = initial_value; + } + } + // When copying, make underlying Vector to reference our buffer. EmbeddedVector(const EmbeddedVector& rhs) : Vector<T>(rhs) { |