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_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 | 1700 |
1701 T value() { return value_; } | 1701 T value() { return value_; } |
1702 ThreadedListZoneEntry<T>** next() { return &next_; } | 1702 ThreadedListZoneEntry<T>** next() { return &next_; } |
1703 | 1703 |
1704 private: | 1704 private: |
1705 T value_; | 1705 T value_; |
1706 ThreadedListZoneEntry<T>* next_; | 1706 ThreadedListZoneEntry<T>* next_; |
1707 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); | 1707 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); |
1708 }; | 1708 }; |
1709 | 1709 |
| 1710 template <typename T> |
| 1711 class ScopedAssignment { |
| 1712 public: |
| 1713 V8_INLINE ScopedAssignment(T& previous, T&& value) |
| 1714 : location_(&previous), prev_(previous) { |
| 1715 *location_ = value; |
| 1716 } |
| 1717 V8_INLINE ScopedAssignment(T& previous, const T& value) |
| 1718 : location_(&previous), prev_(previous) { |
| 1719 *location_ = value; |
| 1720 } |
| 1721 |
| 1722 V8_INLINE ~ScopedAssignment() { *location_ = prev_; } |
| 1723 |
| 1724 private: |
| 1725 T* location_; |
| 1726 T prev_; |
| 1727 }; |
| 1728 |
1710 } // namespace internal | 1729 } // namespace internal |
1711 } // namespace v8 | 1730 } // namespace v8 |
1712 | 1731 |
1713 #endif // V8_UTILS_H_ | 1732 #endif // V8_UTILS_H_ |
OLD | NEW |