Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: src/base/flags.h

Issue 668173002: Add Float64Round operator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add unittest. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler/arm/instruction-selector-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_BASE_FLAGS_H_ 5 #ifndef V8_BASE_FLAGS_H_
6 #define V8_BASE_FLAGS_H_ 6 #define V8_BASE_FLAGS_H_
7 7
8 #include "src/base/compiler-specific.h" 8 #include "src/base/compiler-specific.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace base { 11 namespace base {
12 12
13 // The Flags class provides a type-safe way of storing OR-combinations of enum 13 // The Flags class provides a type-safe way of storing OR-combinations of enum
14 // values. The Flags<T, S> class is a template class, where T is an enum type, 14 // values. The Flags<T, S> class is a template class, where T is an enum type,
15 // and S is the underlying storage type (usually int). 15 // and S is the underlying storage type (usually int).
16 // 16 //
17 // The traditional C++ approach for storing OR-combinations of enum values is to 17 // The traditional C++ approach for storing OR-combinations of enum values is to
18 // use an int or unsigned int variable. The inconvenience with this approach is 18 // use an int or unsigned int variable. The inconvenience with this approach is
19 // that there's no type checking at all; any enum value can be OR'd with any 19 // that there's no type checking at all; any enum value can be OR'd with any
20 // other enum value and passed on to a function that takes an int or unsigned 20 // other enum value and passed on to a function that takes an int or unsigned
21 // int. 21 // int.
22 template <typename T, typename S = int> 22 template <typename T, typename S = int>
23 class Flags FINAL { 23 class Flags FINAL {
24 public: 24 public:
25 typedef T flag_type; 25 typedef T flag_type;
26 typedef S mask_type; 26 typedef S mask_type;
27 27
28 Flags() : mask_(0) {} 28 Flags() : mask_(0) {}
29 Flags(flag_type flag) : mask_(flag) {} // NOLINT(runtime/explicit) 29 Flags(flag_type flag) // NOLINT(runtime/explicit)
30 explicit Flags(mask_type mask) : mask_(mask) {} 30 : mask_(static_cast<S>(flag)) {}
31 explicit Flags(mask_type mask) : mask_(static_cast<S>(mask)) {}
31 32
32 Flags& operator&=(const Flags& flags) { 33 Flags& operator&=(const Flags& flags) {
33 mask_ &= flags.mask_; 34 mask_ &= flags.mask_;
34 return *this; 35 return *this;
35 } 36 }
36 Flags& operator|=(const Flags& flags) { 37 Flags& operator|=(const Flags& flags) {
37 mask_ |= flags.mask_; 38 mask_ |= flags.mask_;
38 return *this; 39 return *this;
39 } 40 }
40 Flags& operator^=(const Flags& flags) { 41 Flags& operator^=(const Flags& flags) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 inline Type operator^(Type::flag_type lhs, const Type& rhs) { \ 102 inline Type operator^(Type::flag_type lhs, const Type& rhs) { \
102 return rhs ^ lhs; \ 103 return rhs ^ lhs; \
103 } inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \ 104 } inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \
104 ALLOW_UNUSED_TYPE; \ 105 ALLOW_UNUSED_TYPE; \
105 inline void operator^(Type::flag_type lhs, Type::mask_type rhs) {} 106 inline void operator^(Type::flag_type lhs, Type::mask_type rhs) {}
106 107
107 } // namespace base 108 } // namespace base
108 } // namespace v8 109 } // namespace v8
109 110
110 #endif // V8_BASE_FLAGS_H_ 111 #endif // V8_BASE_FLAGS_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/arm/instruction-selector-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698