GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/booleans/type_enumerator.h Lines: 19 19 100.0 %
Date: 2021-05-22 Branches: 14 35 40.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Morgan Deters, Tim King, Mathias Preiner
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 Booleans.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__BOOLEANS__TYPE_ENUMERATOR_H
19
#define CVC5__THEORY__BOOLEANS__TYPE_ENUMERATOR_H
20
21
#include "theory/type_enumerator.h"
22
#include "expr/type_node.h"
23
#include "expr/kind.h"
24
25
namespace cvc5 {
26
namespace theory {
27
namespace booleans {
28
29
1819
class BooleanEnumerator : public TypeEnumeratorBase<BooleanEnumerator> {
30
  enum { FALSE, TRUE, DONE } d_value;
31
32
 public:
33
545
  BooleanEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr)
34
545
      : TypeEnumeratorBase<BooleanEnumerator>(type), d_value(FALSE)
35
  {
36
545
    Assert(type.getKind() == kind::TYPE_CONSTANT
37
           && type.getConst<TypeConstant>() == BOOLEAN_TYPE);
38
545
  }
39
40
1575
  Node operator*() override {
41
1575
    switch(d_value) {
42
1324
    case FALSE:
43
1324
      return NodeManager::currentNM()->mkConst(false);
44
187
    case TRUE:
45
187
      return NodeManager::currentNM()->mkConst(true);
46
64
    default:
47
64
      throw NoMoreValuesException(getType());
48
    }
49
  }
50
51
233
  BooleanEnumerator& operator++() override
52
  {
53
    // sequence is FALSE, TRUE
54
233
    if(d_value == FALSE) {
55
178
      d_value = TRUE;
56
    } else {
57
55
      d_value = DONE;
58
    }
59
233
    return *this;
60
  }
61
62
1846
  bool isFinished() override { return d_value == DONE; }
63
};/* class BooleanEnumerator */
64
65
}  // namespace booleans
66
}  // namespace theory
67
}  // namespace cvc5
68
69
#endif /* CVC5__THEORY__BOOLEANS__TYPE_ENUMERATOR_H */