GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/expr/attribute.cpp Lines: 23 61 37.7 %
Date: 2021-03-23 Branches: 4 88 4.5 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file attribute.cpp
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Tim King, Dejan Jovanovic, Morgan Deters
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 AttributeManager implementation.
13
 **
14
 ** AttributeManager implementation.
15
 **/
16
#include "expr/attribute.h"
17
18
#include <utility>
19
20
#include "base/output.h"
21
#include "expr/node_value.h"
22
23
using namespace std;
24
25
namespace CVC4 {
26
namespace expr {
27
namespace attr {
28
29
7167
AttributeManager::AttributeManager() :
30
7167
  d_inGarbageCollection(false)
31
7167
{}
32
33
60413635
bool AttributeManager::inGarbageCollection() const {
34
60413635
  return d_inGarbageCollection;
35
}
36
37
void AttributeManager::debugHook(int debugFlag) {
38
  /* DO NOT CHECK IN ANY CODE INTO THE DEBUG HOOKS!
39
   * debugHook() is an empty function for the purpose of debugging
40
   * the AttributeManager without recompiling all of CVC4.
41
   * Formally this is a nop.
42
   */
43
}
44
45
29459522
void AttributeManager::deleteAllAttributes(NodeValue* nv) {
46
29459522
  Assert(!inGarbageCollection());
47
29459522
  d_bools.erase(nv);
48
29459522
  deleteFromTable(d_ints, nv);
49
29459522
  deleteFromTable(d_tnodes, nv);
50
29459522
  deleteFromTable(d_nodes, nv);
51
29459522
  deleteFromTable(d_types, nv);
52
29459522
  deleteFromTable(d_strings, nv);
53
29459522
}
54
55
7146
void AttributeManager::deleteAllAttributes() {
56
7146
  d_bools.clear();
57
7146
  deleteAllFromTable(d_ints);
58
7146
  deleteAllFromTable(d_tnodes);
59
7146
  deleteAllFromTable(d_nodes);
60
7146
  deleteAllFromTable(d_types);
61
7146
  deleteAllFromTable(d_strings);
62
7146
}
63
64
void AttributeManager::deleteAttributes(const AttrIdVec& atids) {
65
  typedef std::map<uint64_t, std::vector< uint64_t> > AttrToVecMap;
66
  AttrToVecMap perTableIds;
67
68
  for(AttrIdVec::const_iterator it = atids.begin(), it_end = atids.end(); it != it_end; ++it) {
69
    const AttributeUniqueId& pair = *(*it);
70
    std::vector< uint64_t>& inTable = perTableIds[pair.getTableId()];
71
    inTable.push_back(pair.getWithinTypeId());
72
  }
73
  AttrToVecMap::iterator it = perTableIds.begin(), it_end = perTableIds.end();
74
  for(; it != it_end; ++it) {
75
    Assert(((*it).first) <= LastAttrTable);
76
    AttrTableId tableId = (AttrTableId) ((*it).first);
77
    std::vector< uint64_t>& ids = (*it).second;
78
    std::sort(ids.begin(), ids.end());
79
80
    switch(tableId) {
81
    case AttrTableBool:
82
      Unimplemented() << "delete attributes is unimplemented for bools";
83
      break;
84
    case AttrTableUInt64:
85
      deleteAttributesFromTable(d_ints, ids);
86
      break;
87
    case AttrTableTNode:
88
      deleteAttributesFromTable(d_tnodes, ids);
89
      break;
90
    case AttrTableNode:
91
      deleteAttributesFromTable(d_nodes, ids);
92
      break;
93
    case AttrTableTypeNode:
94
      deleteAttributesFromTable(d_types, ids);
95
      break;
96
    case AttrTableString:
97
      deleteAttributesFromTable(d_strings, ids);
98
      break;
99
100
    case AttrTableCDBool:
101
    case AttrTableCDUInt64:
102
    case AttrTableCDTNode:
103
    case AttrTableCDNode:
104
    case AttrTableCDString:
105
    case AttrTableCDPointer:
106
      Unimplemented() << "CDAttributes cannot be deleted. Contact Tim/Morgan "
107
                         "if this behavior is desired.";
108
      break;
109
110
    case LastAttrTable:
111
    default:
112
      Unreachable();
113
    }
114
  }
115
}
116
117
}/* CVC4::expr::attr namespace */
118
}/* CVC4::expr namespace */
119
26685
}/* CVC4 namespace */