1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Gereon Kremer, Mathias Preiner, Dejan Jovanovic |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* A bitmap of Kinds. |
14 |
|
* |
15 |
|
* This is a class representation for a bitmap of Kinds that is iterable, |
16 |
|
* manipulable, and packed. |
17 |
|
*/ |
18 |
|
|
19 |
|
#include "cvc5_private.h" |
20 |
|
|
21 |
|
#ifndef CVC5__KIND_MAP_H |
22 |
|
#define CVC5__KIND_MAP_H |
23 |
|
|
24 |
|
#include <bitset> |
25 |
|
|
26 |
|
#include "base/check.h" |
27 |
|
#include "expr/kind.h" |
28 |
|
|
29 |
|
namespace cvc5 { |
30 |
|
|
31 |
|
/** A very simple bitmap for Kinds */ |
32 |
435882 |
class KindMap |
33 |
|
{ |
34 |
|
public: |
35 |
|
/** Set the bit for k */ |
36 |
1310876 |
void set(Kind k) { d_bits.set(fromKind(k)); } |
37 |
|
/** Reset the bit for k */ |
38 |
2 |
void reset(Kind k) { d_bits.reset(fromKind(k)); } |
39 |
|
/** Check whether the bit for k is set */ |
40 |
5617509 |
bool test(Kind k) const { return d_bits.test(fromKind(k)); } |
41 |
|
/** Check whether the bit for k is set */ |
42 |
4036443 |
bool operator[](Kind k) const { return test(k); } |
43 |
|
|
44 |
|
private: |
45 |
|
/** Convert kind to std::size_t and check bounds */ |
46 |
6928387 |
static std::size_t fromKind(Kind k) |
47 |
|
{ |
48 |
6928387 |
AssertArgument(k >= Kind(0) && k < kind::LAST_KIND, k, "invalid kind"); |
49 |
6928385 |
return static_cast<std::size_t>(k); |
50 |
|
} |
51 |
|
/** The bitmap */ |
52 |
|
std::bitset<kind::LAST_KIND> d_bits; |
53 |
|
}; |
54 |
|
|
55 |
|
} // namespace cvc5 |
56 |
|
|
57 |
|
#endif /* CVC5__KIND_MAP_H */ |