1 /********************* */
3 ** Original author: mdeters
4 ** Major contributors: dejan
5 ** Minor contributors (to current version): none
6 ** This file is part of the CVC4 prototype.
7 ** Copyright (c) 2009, 2010 The Analysis of Computer Systems Group (ACSys)
8 ** Courant Institute of Mathematical Sciences
10 ** See the file COPYING in the top-level source directory for licensing
13 ** Expression manager implementation.
16 #include "node_builder.h"
17 #include "node_manager.h"
18 #include "expr/node.h"
19 #include "expr/attribute.h"
20 #include "util/output.h"
23 using namespace CVC4::expr
;
27 __thread NodeManager
* NodeManager::s_current
= 0;
29 NodeValue
* NodeManager::poolLookup(NodeValue
* nv
) const {
30 NodeValueSet::const_iterator find
= d_nodeValueSet
.find(nv
);
31 if (find
== d_nodeValueSet
.end()) {
38 void NodeManager::poolInsert(NodeValue
* nv
) {
39 Assert(d_nodeValueSet
.find(nv
) == d_nodeValueSet
.end(), "NodeValue already in"
41 d_nodeValueSet
.insert(nv
);
44 // general expression-builders
46 Node
NodeManager::mkNode(Kind kind
) {
47 return NodeBuilder
<>(this, kind
);
50 Node
NodeManager::mkNode(Kind kind
, const Node
& child1
) {
51 return NodeBuilder
<>(this, kind
) << child1
;
54 Node
NodeManager::mkNode(Kind kind
, const Node
& child1
, const Node
& child2
) {
55 return NodeBuilder
<>(this, kind
) << child1
<< child2
;
58 Node
NodeManager::mkNode(Kind kind
, const Node
& child1
, const Node
& child2
, const Node
& child3
) {
59 return NodeBuilder
<>(this, kind
) << child1
<< child2
<< child3
;
62 Node
NodeManager::mkNode(Kind kind
, const Node
& child1
, const Node
& child2
, const Node
& child3
, const Node
& child4
) {
63 return NodeBuilder
<>(this, kind
) << child1
<< child2
<< child3
<< child4
;
66 Node
NodeManager::mkNode(Kind kind
, const Node
& child1
, const Node
& child2
, const Node
& child3
, const Node
& child4
, const Node
& child5
) {
67 return NodeBuilder
<>(this, kind
) << child1
<< child2
<< child3
<< child4
<< child5
;
71 Node
NodeManager::mkNode(Kind kind
, const vector
<Node
>& children
) {
72 return NodeBuilder
<>(this, kind
).append(children
);
75 Node
NodeManager::mkVar(const Type
* type
, string name
) {
77 n
.setAttribute(VarNameAttr(), name
);
81 Node
NodeManager::mkVar(const Type
* type
) {
82 Node n
= NodeBuilder
<>(this, VARIABLE
);
83 n
.setAttribute(TypeAttr(), type
);
87 Node
NodeManager::mkVar() {
88 return NodeBuilder
<>(this, VARIABLE
);