OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 return (bits_ & set.bits_) != 0; | 1012 return (bits_ & set.bits_) != 0; |
1013 } | 1013 } |
1014 void Add(E element) { bits_ |= Mask(element); } | 1014 void Add(E element) { bits_ |= Mask(element); } |
1015 void Add(const EnumSet& set) { bits_ |= set.bits_; } | 1015 void Add(const EnumSet& set) { bits_ |= set.bits_; } |
1016 void Remove(E element) { bits_ &= ~Mask(element); } | 1016 void Remove(E element) { bits_ &= ~Mask(element); } |
1017 void Remove(const EnumSet& set) { bits_ &= ~set.bits_; } | 1017 void Remove(const EnumSet& set) { bits_ &= ~set.bits_; } |
1018 void RemoveAll() { bits_ = 0; } | 1018 void RemoveAll() { bits_ = 0; } |
1019 void Intersect(const EnumSet& set) { bits_ &= set.bits_; } | 1019 void Intersect(const EnumSet& set) { bits_ &= set.bits_; } |
1020 T ToIntegral() const { return bits_; } | 1020 T ToIntegral() const { return bits_; } |
1021 bool operator==(const EnumSet& set) { return bits_ == set.bits_; } | 1021 bool operator==(const EnumSet& set) { return bits_ == set.bits_; } |
| 1022 EnumSet<E, T> operator|(const EnumSet& set) const { |
| 1023 return EnumSet<E, T>(bits_ | set.bits_); |
| 1024 } |
1022 | 1025 |
1023 private: | 1026 private: |
1024 T Mask(E element) const { | 1027 T Mask(E element) const { |
1025 // The strange typing in ASSERT is necessary to avoid stupid warnings, see: | 1028 // The strange typing in ASSERT is necessary to avoid stupid warnings, see: |
1026 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43680 | 1029 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43680 |
1027 ASSERT(static_cast<int>(element) < static_cast<int>(sizeof(T) * CHAR_BIT)); | 1030 ASSERT(static_cast<int>(element) < static_cast<int>(sizeof(T) * CHAR_BIT)); |
1028 return 1 << element; | 1031 return 1 << element; |
1029 } | 1032 } |
1030 | 1033 |
1031 T bits_; | 1034 T bits_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 | 1080 |
1078 // Every compiled stub starts with this id. | 1081 // Every compiled stub starts with this id. |
1079 static const int kStubEntryId = 5; | 1082 static const int kStubEntryId = 5; |
1080 | 1083 |
1081 int id_; | 1084 int id_; |
1082 }; | 1085 }; |
1083 | 1086 |
1084 } } // namespace v8::internal | 1087 } } // namespace v8::internal |
1085 | 1088 |
1086 #endif // V8_UTILS_H_ | 1089 #endif // V8_UTILS_H_ |
OLD | NEW |