GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/listeners.cpp Lines: 36 43 83.7 %
Date: 2021-05-22 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
10093
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
10093
SmtNodeManagerListener::SmtNodeManagerListener(DumpManager& dm,
42
10093
                                               OutputManager& outMgr)
43
10093
    : d_dm(dm), d_outMgr(outMgr)
44
{
45
10093
}
46
47
8340
void SmtNodeManagerListener::nmNotifyNewSort(TypeNode tn, uint32_t flags)
48
{
49
16680
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()), 0, tn);
50
8340
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
51
  {
52
6394
    d_dm.addToDump(c);
53
  }
54
8340
}
55
56
95
void SmtNodeManagerListener::nmNotifyNewSortConstructor(TypeNode tn,
57
                                                        uint32_t flags)
58
{
59
190
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()),
60
95
                           tn.getAttribute(expr::SortArityAttr()),
61
380
                           tn);
62
95
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
63
  {
64
95
    d_dm.addToDump(c);
65
  }
66
95
}
67
68
4118
void SmtNodeManagerListener::nmNotifyNewDatatypes(
69
    const std::vector<TypeNode>& dtts, uint32_t flags)
70
{
71
4118
  if ((flags & NodeManager::DATATYPE_FLAG_PLACEHOLDER) == 0)
72
  {
73
3065
    if (Configuration::isAssertionBuild())
74
    {
75
6472
      for (CVC5_UNUSED const TypeNode& dt : dtts)
76
      {
77
3407
        Assert(dt.isDatatype());
78
      }
79
    }
80
6130
    DeclareDatatypeNodeCommand c(dtts);
81
3065
    d_dm.addToDump(c);
82
  }
83
4118
}
84
85
181206
void SmtNodeManagerListener::nmNotifyNewVar(TNode n)
86
{
87
  DeclareFunctionNodeCommand c(
88
362412
      n.getAttribute(expr::VarNameAttr()), n, n.getType());
89
181206
  d_dm.addToDump(c);
90
181206
}
91
92
93679
void SmtNodeManagerListener::nmNotifyNewSkolem(TNode n,
93
                                               const std::string& comment,
94
                                               uint32_t flags)
95
{
96
187358
  std::string id = n.getAttribute(expr::VarNameAttr());
97
187358
  DeclareFunctionNodeCommand c(id, n, n.getType());
98
93679
  if (Dump.isOn("skolems") && comment != "")
99
  {
100
    d_outMgr.getPrinter().toStreamCmdComment(d_outMgr.getDumpOut(),
101
                                             id + " is " + comment);
102
  }
103
93679
  d_dm.addToDump(c, "skolems");
104
93679
}
105
106
}  // namespace smt
107
28191
}  // namespace cvc5