summaryrefslogtreecommitdiff
path: root/src/smt/model_postprocessor.cpp
blob: 38fd3ab8b89b18656e3c616f2565bf3f70207a13 (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
/*********************                                                        */
/*! \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"

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 {
    Debug("tuprec") << "returning self" << std::endl;
    // rewrite to self
    d_nodes[current] = Node::null();
  }
}/* ModelPostprocessor::visit() */

generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback