| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_BOOLFIELD_H_ | 5 #ifndef VM_BOOLFIELD_H_ |
| 6 #define VM_BOOLFIELD_H_ | 6 #define VM_BOOLFIELD_H_ |
| 7 | 7 |
| 8 #include "vm/globals.h" |
| 9 |
| 8 namespace dart { | 10 namespace dart { |
| 9 | 11 |
| 10 // BoolField is a template for encoding and decoding a bit inside an | 12 // BoolField is a template for encoding and decoding a bit inside an |
| 11 // unsigned machine word. | 13 // unsigned machine word. |
| 12 template<int position> | 14 template<int position> |
| 13 class BoolField { | 15 class BoolField { |
| 14 public: | 16 public: |
| 15 // Returns a uword with the bool value encoded. | 17 // Returns a uword with the bool value encoded. |
| 16 static uword encode(bool value) { | 18 static uword encode(bool value) { |
| 17 ASSERT(position < sizeof(uword)); | 19 ASSERT(position < sizeof(uword)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 static uword update(bool value, uword original) { | 32 static uword update(bool value, uword original) { |
| 31 ASSERT(position < sizeof(uword)); | 33 ASSERT(position < sizeof(uword)); |
| 32 const uword mask = 1U << position; | 34 const uword mask = 1U << position; |
| 33 return value ? original | mask : original & ~mask; | 35 return value ? original | mask : original & ~mask; |
| 34 } | 36 } |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 } // namespace dart | 39 } // namespace dart |
| 38 | 40 |
| 39 #endif // VM_BOOLFIELD_H_ | 41 #endif // VM_BOOLFIELD_H_ |
| OLD | NEW |