GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/listeners.cpp Lines: 36 43 83.7 %
Date: 2021-08-20 Branches: 41 118 34.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
10501
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
10501
SmtNodeManagerListener::SmtNodeManagerListener(DumpManager& dm,
42
10501
                                               OutputManager& outMgr)
43
10501
    : d_dm(dm), d_outMgr(outMgr)
44
{
45
10501
}
46
47
8355
void SmtNodeManagerListener::nmNotifyNewSort(TypeNode tn, uint32_t flags)
48
{
49
16710
  DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()), 0, tn);
50
8355
  if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0)
51
  {
52
6380
    d_dm.addToDump(c);
53
  }
54
8355
}
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
4392
void SmtNodeManagerListener::nmNotifyNewDatatypes(
69
    const std::vector<TypeNode>& dtts, uint32_t flags)
70
{
71
4392
  if ((flags & NodeManager::DATATYPE_FLAG_PLACEHOLDER) == 0)
72
  {
73
3331
    if (Configuration::isAssertionBuild())
74
    {
75
7018
      for (CVC5_UNUSED const TypeNode& dt : dtts)
76
      {
77
3687
        Assert(dt.isDatatype());
78
      }
79
    }
80
6662
    DeclareDatatypeNodeCommand c(dtts);
81
3331
    d_dm.addToDump(c);
82
  }
83
4392
}
84
85
178531
void SmtNodeManagerListener::nmNotifyNewVar(TNode n)
86
{
87
  DeclareFunctionNodeCommand c(
88
357062
      n.getAttribute(expr::VarNameAttr()), n, n.getType());
89
178531
  d_dm.addToDump(c);
90
178531
}
91
92
98625
void SmtNodeManagerListener::nmNotifyNewSkolem(TNode n,
93
                                               const std::string& comment,
94
                                               uint32_t flags)
95
{
96
197250
  std::string id = n.getAttribute(expr::VarNameAttr());
97
197250
  DeclareFunctionNodeCommand c(id, n, n.getType());
98
98625
  if (Dump.isOn("skolems") && comment != "")
99
  {
100
    d_outMgr.getPrinter().toStreamCmdComment(d_outMgr.getDumpOut(),
101
                                             id + " is " + comment);
102
  }
103
98625
  d_dm.addToDump(c, "skolems");
104
98625
}
105
106
}  // namespace smt
107
29358
}  // namespace cvc5