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
|
/*
* rewriter_attributes.h
*
* Created on: Dec 27, 2010
* Author: dejan
*/
#pragma once
namespace CVC4 {
namespace theory {
template <bool pre, theory::TheoryId theoryId>
struct RewriteCacheTag {};
template <theory::TheoryId theoryId>
struct RewriteAttibute {
typedef expr::Attribute< RewriteCacheTag<true, theoryId>, Node> pre_rewrite;
typedef expr::Attribute< RewriteCacheTag<false, theoryId>, Node> post_rewrite;
/**
* Get the value of the pre-rewrite cache.
*/
static Node getPreRewriteCache(TNode node) throw() {
Node cache;
if (node.hasAttribute(pre_rewrite())) {
node.getAttribute(pre_rewrite(), cache);
} else {
return Node::null();
}
if (cache.isNull()) {
return node;
} else {
return cache;
}
}
/**
* Set the value of the pre-rewrite cache.
*/
static void setPreRewriteCache(TNode node, TNode cache) throw() {
Debug("rewriter") << "setting pre-rewrite of " << node << " to " << cache << std::endl;
Assert(!cache.isNull());
if (node == cache) {
node.setAttribute(pre_rewrite(), Node::null());
} else {
node.setAttribute(pre_rewrite(), cache);
}
}
/**
* Get the value of the post-rewrite cache.
* none).
*/
static Node getPostRewriteCache(TNode node) throw() {
Node cache;
if (node.hasAttribute(post_rewrite())) {
node.getAttribute(post_rewrite(), cache);
} else {
return Node::null();
}
if (cache.isNull()) {
return node;
} else {
return cache;
}
}
/**
* Set the value of the post-rewrite cache. v cannot be a null Node.
*/
static void setPostRewriteCache(TNode node, TNode cache) throw() {
Assert(!cache.isNull());
Debug("rewriter") << "setting rewrite of " << node << " to " << cache << std::endl;
if (node == cache) {
node.setAttribute(post_rewrite(), Node::null());
} else {
node.setAttribute(post_rewrite(), cache);
}
}
};
} // Namespace CVC4
} // Namespace theory
|