GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/listeners.cpp Lines: 36 43 83.7 %
Date: 2021-08-01 Branches: 41 120 34.2 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Abdalrhman Mohamed
4
 *
5
 * This file is part of the cvc5 project.
6
 *
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.
11
 * ****************************************************************************
12
 *
13
 * Implements listener classes for SMT engine.
14
 */
15
16
#include "smt/listeners.h"
17
18
#include "base/configuration.h"
19
#include "expr/attribute.h"
20
#include "expr/node_manager_attributes.h"
21
#include "options/smt_options.h"
22
#include "printer/printer.h"
23
#include "smt/dump.h"
24
#include "smt/dump_manager.h"
25
#include "smt/node_command.h"
26
#include "smt/smt_engine.h"
27
#include "smt/smt_engine_scope.h"
28
29
namespace cvc5 {
30
namespace smt {
31
32
10481
ResourceOutListener::ResourceOutListener(SmtEngine& smt) : d_smt(smt) {}
33
34
void ResourceOutListener::notify()
35
{
36
  SmtScope scope(&d_smt);
37
  Assert(smt::smtEngineInScope());
38
  d_smt.interrupt();
39
}
40
41
10481
SmtNodeManagerListener::SmtNodeManagerListener(DumpManager& dm,
42
10481
                                               OutputManager& outMgr)
43
10481
    : d_dm(dm), d_outMgr(outMgr)
44
{
45
10481
}
46
47
8359
void SmtNodeManagerListener::nmNotifyNewSort(TypeNode tn, uint32_t flags)
48
{
49
16718
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()), 0, tn);
50
8359
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
51
  {
52
6378
    d_dm.addToDump(c);
53
  }
54
8359
}
55
56
94
void SmtNodeManagerListener::nmNotifyNewSortConstructor(TypeNode tn,
57
                                                        uint32_t flags)
58
{
59
188
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()),
60
94
                           tn.getAttribute(expr::SortArityAttr()),
61
376
                           tn);
62
94
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
63
  {
64
94
    d_dm.addToDump(c);
65
  }
66
94
}
67
68
4379
void SmtNodeManagerListener::nmNotifyNewDatatypes(
69
    const std::vector<TypeNode>& dtts, uint32_t flags)
70
{
71
4379
  if ((flags & NodeManager::DATATYPE_FLAG_PLACEHOLDER) == 0)
72
  {
73
3315
    if (Configuration::isAssertionBuild())
74
    {
75
6986
      for (CVC5_UNUSED const TypeNode& dt : dtts)
76
      {
77
3671
        Assert(dt.isDatatype());
78
      }
79
    }
80
6630
    DeclareDatatypeNodeCommand c(dtts);
81
3315
    d_dm.addToDump(c);
82
  }
83
4379
}
84
85
180564
void SmtNodeManagerListener::nmNotifyNewVar(TNode n)
86
{
87
  DeclareFunctionNodeCommand c(
88
361128
      n.getAttribute(expr::VarNameAttr()), n, n.getType());
89
180564
  d_dm.addToDump(c);
90
180564
}
91
92
98234
void SmtNodeManagerListener::nmNotifyNewSkolem(TNode n,
93
                                               const std::string& comment,
94
                                               uint32_t flags)
95
{
96
196468
  std::string id = n.getAttribute(expr::VarNameAttr());
97
196468
  DeclareFunctionNodeCommand c(id, n, n.getType());
98
98234
  if (Dump.isOn("skolems") && comment != "")
99
  {
100
    d_outMgr.getPrinter().toStreamCmdComment(d_outMgr.getDumpOut(),
101
                                             id + " is " + comment);
102
  }
103
98234
  d_dm.addToDump(c, "skolems");
104
98234
}
105
106
}  // namespace smt
107
29280
}  // namespace cvc5