1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/********************* */
/** node_manager.cpp
** Original author: mdeters
** Major contributors: dejan
** Minor contributors (to current version): none
** This file is part of the CVC4 prototype.
** Copyright (c) 2009, 2010 The Analysis of Computer Systems Group (ACSys)
** Courant Institute of Mathematical Sciences
** New York University
** See the file COPYING in the top-level source directory for licensing
** information.
**
** Expression manager implementation.
**/
#include "node_builder.h"
#include "node_manager.h"
#include "expr/node.h"
#include "expr/attribute.h"
#include "util/output.h"
using namespace std;
using namespace CVC4::expr;
namespace CVC4 {
__thread NodeManager* NodeManager::s_current = 0;
NodeValue* NodeManager::poolLookup(NodeValue* nv) const {
NodeValueSet::const_iterator find = d_nodeValueSet.find(nv);
if (find == d_nodeValueSet.end()) {
return NULL;
} else {
return *find;
}
}
void NodeManager::poolInsert(NodeValue* nv) {
Assert(d_nodeValueSet.find(nv) == d_nodeValueSet.end(), "NodeValue already in"
"the pool!");
d_nodeValueSet.insert(nv);
}
// general expression-builders
Node NodeManager::mkNode(Kind kind) {
return NodeBuilder<>(this, kind);
}
Node NodeManager::mkNode(Kind kind, const Node& child1) {
return NodeBuilder<>(this, kind) << child1;
}
Node NodeManager::mkNode(Kind kind, const Node& child1, const Node& child2) {
return NodeBuilder<>(this, kind) << child1 << child2;
}
Node NodeManager::mkNode(Kind kind, const Node& child1, const Node& child2, const Node& child3) {
return NodeBuilder<>(this, kind) << child1 << child2 << child3;
}
Node NodeManager::mkNode(Kind kind, const Node& child1, const Node& child2, const Node& child3, const Node& child4) {
return NodeBuilder<>(this, kind) << child1 << child2 << child3 << child4;
}
Node NodeManager::mkNode(Kind kind, const Node& child1, const Node& child2, const Node& child3, const Node& child4, const Node& child5) {
return NodeBuilder<>(this, kind) << child1 << child2 << child3 << child4 << child5;
}
// N-ary version
Node NodeManager::mkNode(Kind kind, const vector<Node>& children) {
return NodeBuilder<>(this, kind).append(children);
}
Node NodeManager::mkVar(const Type* type, const std::string& name) {
Node n = mkVar(type);
n.setAttribute(VarNameAttr(), name);
return n;
}
Node NodeManager::mkVar(const Type* type) {
Node n = NodeBuilder<>(this, VARIABLE);
n.setAttribute(TypeAttr(), type);
return n;
}
Node NodeManager::mkVar() {
return NodeBuilder<>(this, VARIABLE);
}
}/* CVC4 namespace */
|