1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Morgan Deters, Mathias Preiner, Tim King |
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 |
|
* An enumerator for bitvectors. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__BV__TYPE_ENUMERATOR_H |
19 |
|
#define CVC5__THEORY__BV__TYPE_ENUMERATOR_H |
20 |
|
|
21 |
|
#include "expr/kind.h" |
22 |
|
#include "expr/type_node.h" |
23 |
|
#include "theory/type_enumerator.h" |
24 |
|
#include "theory/bv/theory_bv_utils.h" |
25 |
|
#include "util/bitvector.h" |
26 |
|
#include "util/integer.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace theory { |
30 |
|
namespace bv { |
31 |
|
|
32 |
8735 |
class BitVectorEnumerator : public TypeEnumeratorBase<BitVectorEnumerator> { |
33 |
|
size_t d_size; |
34 |
|
Integer d_bits; |
35 |
|
|
36 |
|
public: |
37 |
|
|
38 |
3661 |
BitVectorEnumerator(TypeNode type, TypeEnumeratorProperties * tep = NULL) : |
39 |
|
TypeEnumeratorBase<BitVectorEnumerator>(type), |
40 |
3661 |
d_size(type.getBitVectorSize()), |
41 |
7322 |
d_bits(0) { |
42 |
3661 |
} |
43 |
|
|
44 |
8538 |
Node operator*() override |
45 |
|
{ |
46 |
8538 |
if(d_bits != d_bits.modByPow2(d_size)) { |
47 |
49 |
throw NoMoreValuesException(getType()); |
48 |
|
} |
49 |
8489 |
return utils::mkConst(d_size, d_bits); |
50 |
|
} |
51 |
|
|
52 |
439 |
BitVectorEnumerator& operator++() override |
53 |
|
{ |
54 |
439 |
d_bits += 1; |
55 |
439 |
return *this; |
56 |
|
} |
57 |
|
|
58 |
9000 |
bool isFinished() override { return d_bits != d_bits.modByPow2(d_size); } |
59 |
|
};/* BitVectorEnumerator */ |
60 |
|
|
61 |
|
} // namespace bv |
62 |
|
} // namespace theory |
63 |
|
} // namespace cvc5 |
64 |
|
|
65 |
|
#endif /* CVC5__THEORY__BV__TYPE_ENUMERATOR_H */ |