GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/booleans/type_enumerator.h Lines: 19 19 100.0 %
Date: 2021-09-17 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
2167
class BooleanEnumerator : public TypeEnumeratorBase<BooleanEnumerator> {
30
  enum { FALSE, TRUE, DONE } d_value;
31
32
 public:
33
701
  BooleanEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr)
34
701
      : TypeEnumeratorBase<BooleanEnumerator>(type), d_value(FALSE)
35
  {
36
701
    Assert(type.getKind() == kind::TYPE_CONSTANT
37
           && type.getConst<TypeConstant>() == BOOLEAN_TYPE);
38
701
  }
39
40
1979
  Node operator*() override {
41
1979
    switch(d_value) {
42
1708
    case FALSE:
43
1708
      return NodeManager::currentNM()->mkConst(false);
44
204
    case TRUE:
45
204
      return NodeManager::currentNM()->mkConst(true);
46
67
    default:
47
67
      throw NoMoreValuesException(getType());
48
    }
49
  }
50
51
256
  BooleanEnumerator& operator++() override
52
  {
53
    // sequence is FALSE, TRUE
54
256
    if(d_value == FALSE) {
55
200
      d_value = TRUE;
56
    } else {
57
56
      d_value = DONE;
58
    }
59
256
    return *this;
60
  }
61
62
2278
  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 */