blob: fb0ee808e517dac51e247d37b99d4225624e8966 (
plain)
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
|
/********************* */
/*! \file model_postprocessor.cpp
** \verbatim
** Original author: mdeters
** Major contributors: none
** Minor contributors (to current version): none
** This file is part of the CVC4 prototype.
** Copyright (c) 2009-2012 New York University and The University of Iowa
** See the file COPYING in the top-level source directory for licensing
** information.\endverbatim
**
** \brief
**
**
**/
#include "smt/model_postprocessor.h"
#include "smt/boolean_terms.h"
using namespace CVC4;
using namespace CVC4::smt;
void ModelPostprocessor::visit(TNode current, TNode parent) {
Debug("tuprec") << "visiting " << current << std::endl;
Assert(!alreadyVisited(current, TNode::null()));
if(current.getType().hasAttribute(expr::DatatypeTupleAttr())) {
Assert(current.getKind() == kind::APPLY_CONSTRUCTOR);
NodeBuilder<> b(kind::TUPLE);
for(TNode::iterator i = current.begin(); i != current.end(); ++i) {
Assert(alreadyVisited(*i, TNode::null()));
TNode n = d_nodes[*i];
b << (n.isNull() ? *i : n);
}
d_nodes[current] = b;
Debug("tuprec") << "returning " << d_nodes[current] << std::endl;
} else if(current.getType().hasAttribute(expr::DatatypeRecordAttr())) {
Assert(current.getKind() == kind::APPLY_CONSTRUCTOR);
NodeBuilder<> b(kind::RECORD);
b << current.getType().getAttribute(expr::DatatypeRecordAttr());
for(TNode::iterator i = current.begin(); i != current.end(); ++i) {
Assert(alreadyVisited(*i, TNode::null()));
TNode n = d_nodes[*i];
b << (n.isNull() ? *i : n);
}
d_nodes[current] = b;
Debug("tuprec") << "returning " << d_nodes[current] << std::endl;
} else if(current.hasAttribute(smt::BooleanTermAttr())) {
Debug("boolean-terms") << "found bool-term attr on: " << current << std::endl;
} else {
Debug("tuprec") << "returning self" << std::endl;
// rewrite to self
d_nodes[current] = Node::null();
}
}/* ModelPostprocessor::visit() */
|