GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/listeners.cpp Lines: 38 43 88.4 %
Date: 2021-03-23 Branches: 48 120 40.0 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file listeners.cpp
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Andrew Reynolds, Abdalrhman Mohamed
6
 ** This file is part of the CVC4 project.
7
 ** Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 ** in the top-level source directory and their institutional affiliations.
9
 ** All rights reserved.  See the file COPYING in the top-level source
10
 ** directory for licensing information.\endverbatim
11
 **
12
 ** \brief Implements listener classes for SMT engine.
13
 **/
14
15
#include "smt/listeners.h"
16
17
#include "base/configuration.h"
18
#include "expr/attribute.h"
19
#include "expr/node_manager_attributes.h"
20
#include "options/smt_options.h"
21
#include "printer/printer.h"
22
#include "smt/dump.h"
23
#include "smt/dump_manager.h"
24
#include "smt/node_command.h"
25
#include "smt/smt_engine.h"
26
#include "smt/smt_engine_scope.h"
27
28
namespace CVC4 {
29
namespace smt {
30
31
9622
ResourceOutListener::ResourceOutListener(SmtEngine& smt) : d_smt(smt) {}
32
33
void ResourceOutListener::notify()
34
{
35
  SmtScope scope(&d_smt);
36
  Assert(smt::smtEngineInScope());
37
  d_smt.interrupt();
38
}
39
40
9622
SmtNodeManagerListener::SmtNodeManagerListener(DumpManager& dm,
41
9622
                                               OutputManager& outMgr)
42
9622
    : d_dm(dm), d_outMgr(outMgr)
43
{
44
9622
}
45
46
9076
void SmtNodeManagerListener::nmNotifyNewSort(TypeNode tn, uint32_t flags)
47
{
48
18152
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()), 0, tn);
49
9076
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
50
  {
51
6447
    d_dm.addToDump(c);
52
  }
53
9076
}
54
55
94
void SmtNodeManagerListener::nmNotifyNewSortConstructor(TypeNode tn,
56
                                                        uint32_t flags)
57
{
58
188
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()),
59
94
                           tn.getAttribute(expr::SortArityAttr()),
60
376
                           tn);
61
94
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
62
  {
63
94
    d_dm.addToDump(c);
64
  }
65
94
}
66
67
4345
void SmtNodeManagerListener::nmNotifyNewDatatypes(
68
    const std::vector<TypeNode>& dtts, uint32_t flags)
69
{
70
4345
  if ((flags & NodeManager::DATATYPE_FLAG_PLACEHOLDER) == 0)
71
  {
72
2856
    if (Configuration::isAssertionBuild())
73
    {
74
6000
      for (CVC4_UNUSED const TypeNode& dt : dtts)
75
      {
76
3144
        Assert(dt.isDatatype());
77
      }
78
    }
79
5712
    DeclareDatatypeNodeCommand c(dtts);
80
2856
    d_dm.addToDump(c);
81
  }
82
4345
}
83
84
172153
void SmtNodeManagerListener::nmNotifyNewVar(TNode n)
85
{
86
  DeclareFunctionNodeCommand c(
87
344306
      n.getAttribute(expr::VarNameAttr()), n, n.getType());
88
172153
  d_dm.addToDump(c);
89
172153
}
90
91
96472
void SmtNodeManagerListener::nmNotifyNewSkolem(TNode n,
92
                                               const std::string& comment,
93
                                               uint32_t flags)
94
{
95
192944
  std::string id = n.getAttribute(expr::VarNameAttr());
96
192944
  DeclareFunctionNodeCommand c(id, n, n.getType());
97
96472
  if (Dump.isOn("skolems") && comment != "")
98
  {
99
4
    d_outMgr.getPrinter().toStreamCmdComment(d_outMgr.getDumpOut(),
100
4
                                             id + " is " + comment);
101
  }
102
96472
  d_dm.addToDump(c, "skolems");
103
96472
}
104
105
}  // namespace smt
106
26685
}  // namespace CVC4