GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/expr/kind_map.h Lines: 8 8 100.0 %
Date: 2021-03-23 Branches: 4 6 66.7 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file kind_map.h
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Gereon Kremer, Mathias Preiner, Dejan Jovanovic
6
 ** This file is part of the CVC4 project.
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.\endverbatim
11
 **
12
 ** \brief A bitmap of Kinds
13
 **
14
 ** This is a class representation for a bitmap of Kinds that is
15
 ** iterable, manipulable, and packed.
16
 **/
17
18
#include "cvc4_private.h"
19
20
#ifndef CVC4__KIND_MAP_H
21
#define CVC4__KIND_MAP_H
22
23
#include <bitset>
24
25
#include "base/check.h"
26
#include "expr/kind.h"
27
28
namespace CVC4 {
29
30
/** A very simple bitmap for Kinds */
31
395967
class KindMap
32
{
33
 public:
34
  /** Set the bit for k */
35
1252597
  void set(Kind k) { d_bits.set(fromKind(k)); }
36
  /** Reset the bit for k */
37
2
  void reset(Kind k) { d_bits.reset(fromKind(k)); }
38
  /** Check whether the bit for k is set */
39
5966767
  bool test(Kind k) const { return d_bits.test(fromKind(k)); }
40
  /** Check whether the bit for k is set */
41
3938241
  bool operator[](Kind k) const { return test(k); }
42
43
 private:
44
  /** Convert kind to std::size_t and check bounds */
45
7219366
  static std::size_t fromKind(Kind k)
46
  {
47
7219366
    AssertArgument(k >= Kind(0) && k < kind::LAST_KIND, k, "invalid kind");
48
7219364
    return static_cast<std::size_t>(k);
49
  }
50
  /** The bitmap */
51
  std::bitset<kind::LAST_KIND> d_bits;
52
};
53
54
}  // namespace CVC4
55
56
#endif /* CVC4__KIND_MAP_H */