GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/listeners.cpp Lines: 36 43 83.7 %
Date: 2021-09-29 Branches: 38 120 31.7 %

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
9514
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
9514
SmtNodeManagerListener::SmtNodeManagerListener(DumpManager& dm,
42
9514
                                               OutputManager& outMgr)
43
9514
    : d_dm(dm), d_outMgr(outMgr)
44
{
45
9514
}
46
47
5341
void SmtNodeManagerListener::nmNotifyNewSort(TypeNode tn, uint32_t flags)
48
{
49
10682
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()), 0, tn);
50
5341
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
51
  {
52
3536
    d_dm.addToDump(c);
53
  }
54
5341
}
55
56
77
void SmtNodeManagerListener::nmNotifyNewSortConstructor(TypeNode tn,
57
                                                        uint32_t flags)
58
{
59
154
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()),
60
77
                           tn.getAttribute(expr::SortArityAttr()),
61
308
                           tn);
62
77
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
63
  {
64
77
    d_dm.addToDump(c);
65
  }
66
77
}
67
68
3530
void SmtNodeManagerListener::nmNotifyNewDatatypes(
69
    const std::vector<TypeNode>& dtts, uint32_t flags)
70
{
71
3530
  if ((flags & NodeManager::DATATYPE_FLAG_PLACEHOLDER) == 0)
72
  {
73
2559
    if (Configuration::isAssertionBuild())
74
    {
75
5337
      for (CVC5_UNUSED const TypeNode& dt : dtts)
76
      {
77
2778
        Assert(dt.isDatatype());
78
      }
79
    }
80
5118
    DeclareDatatypeNodeCommand c(dtts);
81
2559
    d_dm.addToDump(c);
82
  }
83
3530
}
84
85
138578
void SmtNodeManagerListener::nmNotifyNewVar(TNode n)
86
{
87
  DeclareFunctionNodeCommand c(
88
277156
      n.getAttribute(expr::VarNameAttr()), n, n.getType());
89
138578
  d_dm.addToDump(c);
90
138578
}
91
92
63228
void SmtNodeManagerListener::nmNotifyNewSkolem(TNode n,
93
                                               const std::string& comment,
94
                                               uint32_t flags)
95
{
96
126456
  std::string id = n.getAttribute(expr::VarNameAttr());
97
126456
  DeclareFunctionNodeCommand c(id, n, n.getType());
98
63228
  if (Dump.isOn("skolems") && comment != "")
99
  {
100
    d_outMgr.getPrinter().toStreamCmdSetInfo(
101
        d_outMgr.getDumpOut(), "notes", id + " is " + comment);
102
  }
103
63228
  d_dm.addToDump(c, "skolems");
104
63228
}
105
106
}  // namespace smt
107
22746
}  // namespace cvc5