GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/options_manager.cpp Lines: 47 61 77.0 %
Date: 2021-08-01 Branches: 62 176 35.2 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Aina Niemetz
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
 * Module for managing options of an SmtEngine.
14
 */
15
16
#include "smt/options_manager.h"
17
18
#include "base/output.h"
19
#include "expr/expr_iomanip.h"
20
#include "options/base_options.h"
21
#include "options/expr_options.h"
22
#include "options/smt_options.h"
23
#include "smt/command.h"
24
#include "smt/dump.h"
25
#include "smt/set_defaults.h"
26
#include "util/resource_manager.h"
27
28
namespace cvc5 {
29
namespace smt {
30
31
10482
OptionsManager::OptionsManager(Options* opts) : d_options(opts)
32
{
33
  // set options that must take effect immediately
34
10481
  if (opts->expr.defaultExprDepthWasSetByUser)
35
  {
36
    notifySetOption(options::expr::defaultExprDepth__name);
37
  }
38
10481
  if (opts->expr.defaultDagThreshWasSetByUser)
39
  {
40
17
    notifySetOption(options::expr::defaultDagThresh__name);
41
  }
42
10481
  if (opts->smt.dumpModeStringWasSetByUser)
43
  {
44
4
    notifySetOption(options::smt::dumpModeString__name);
45
  }
46
10480
  if (opts->base.printSuccessWasSetByUser)
47
  {
48
9
    notifySetOption(options::base::printSuccess__name);
49
  }
50
10480
  if (opts->smt.diagnosticChannelNameWasSetByUser)
51
  {
52
    notifySetOption(options::smt::diagnosticChannelName__name);
53
  }
54
10480
  if (opts->smt.regularChannelNameWasSetByUser)
55
  {
56
    notifySetOption(options::smt::regularChannelName__name);
57
  }
58
10480
  if (opts->smt.dumpToFileNameWasSetByUser)
59
  {
60
    notifySetOption(options::smt::dumpToFileName__name);
61
  }
62
  // set this as a listener to be notified of options changes from now on
63
10480
  opts->setListener(this);
64
10480
}
65
66
20960
OptionsManager::~OptionsManager() {}
67
68
9553
void OptionsManager::notifySetOption(const std::string& key)
69
{
70
19106
  Trace("smt") << "SmtEnginePrivate::notifySetOption(" << key << ")"
71
9553
               << std::endl;
72
9553
  if (key == options::expr::defaultExprDepth__name)
73
  {
74
    int depth = d_options->expr.defaultExprDepth;
75
    Debug.getStream() << expr::ExprSetDepth(depth);
76
    Trace.getStream() << expr::ExprSetDepth(depth);
77
    Notice.getStream() << expr::ExprSetDepth(depth);
78
    Chat.getStream() << expr::ExprSetDepth(depth);
79
    CVC5Message.getStream() << expr::ExprSetDepth(depth);
80
    Warning.getStream() << expr::ExprSetDepth(depth);
81
    // intentionally exclude Dump stream from this list
82
  }
83
9553
  else if (key == options::expr::defaultDagThresh__name)
84
  {
85
18
    int dag = d_options->expr.defaultDagThresh;
86
18
    Debug.getStream() << expr::ExprDag(dag);
87
18
    Trace.getStream() << expr::ExprDag(dag);
88
18
    Notice.getStream() << expr::ExprDag(dag);
89
18
    Chat.getStream() << expr::ExprDag(dag);
90
18
    CVC5Message.getStream() << expr::ExprDag(dag);
91
18
    Warning.getStream() << expr::ExprDag(dag);
92
18
    Dump.getStream() << expr::ExprDag(dag);
93
  }
94
9535
  else if (key == options::smt::dumpModeString__name)
95
  {
96
3
    const std::string& value = d_options->smt.dumpModeString;
97
3
    Dump.setDumpFromString(value);
98
  }
99
9532
  else if (key == options::base::printSuccess__name)
100
  {
101
37
    bool value = d_options->base.printSuccess;
102
37
    Debug.getStream() << Command::printsuccess(value);
103
37
    Trace.getStream() << Command::printsuccess(value);
104
37
    Notice.getStream() << Command::printsuccess(value);
105
37
    Chat.getStream() << Command::printsuccess(value);
106
37
    CVC5Message.getStream() << Command::printsuccess(value);
107
37
    Warning.getStream() << Command::printsuccess(value);
108
74
    *options::out() << Command::printsuccess(value);
109
  }
110
9495
  else if (key == options::smt::regularChannelName__name)
111
  {
112
    d_managedRegularChannel.set(options::regularChannelName());
113
  }
114
9495
  else if (key == options::smt::diagnosticChannelName__name)
115
  {
116
    d_managedDiagnosticChannel.set(options::diagnosticChannelName());
117
  }
118
9495
  else if (key == options::smt::dumpToFileName__name)
119
  {
120
    d_managedDumpChannel.set(options::dumpToFileName());
121
  }
122
  // otherwise, no action is necessary
123
9552
}
124
125
9839
void OptionsManager::finishInit(LogicInfo& logic, bool isInternalSubsolver)
126
{
127
  // ensure that our heuristics are properly set up
128
9839
  setDefaults(logic, isInternalSubsolver);
129
9838
}
130
131
}  // namespace smt
132
29317
}  // namespace cvc5