GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/options_manager.cpp Lines: 47 61 77.0 %
Date: 2021-05-21 Branches: 80 212 37.7 %

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
9588
OptionsManager::OptionsManager(Options* opts) : d_options(opts)
32
{
33
  // set options that must take effect immediately
34
73226
  if (opts->wasSetByUser(options::defaultExprDepth))
35
  {
36
    notifySetOption(options::expr::defaultExprDepth__name);
37
  }
38
30572
  if (opts->wasSetByUser(options::defaultDagThresh))
39
  {
40
12
    notifySetOption(options::expr::defaultDagThresh__name);
41
  }
42
19180
  if (opts->wasSetByUser(options::dumpModeString))
43
  {
44
4
    notifySetOption(options::smt::dumpModeString__name);
45
  }
46
19233
  if (opts->wasSetByUser(options::printSuccess))
47
  {
48
7
    notifySetOption(options::base::printSuccess__name);
49
  }
50
9586
  if (opts->wasSetByUser(options::diagnosticChannelName))
51
  {
52
    notifySetOption(options::smt::diagnosticChannelName__name);
53
  }
54
9586
  if (opts->wasSetByUser(options::regularChannelName))
55
  {
56
    notifySetOption(options::smt::regularChannelName__name);
57
  }
58
9586
  if (opts->wasSetByUser(options::dumpToFileName))
59
  {
60
    notifySetOption(options::smt::dumpToFileName__name);
61
  }
62
  // set this as a listener to be notified of options changes from now on
63
9586
  opts->setListener(this);
64
9586
}
65
66
19172
OptionsManager::~OptionsManager() {}
67
68
9243
void OptionsManager::notifySetOption(const std::string& key)
69
{
70
18486
  Trace("smt") << "SmtEnginePrivate::notifySetOption(" << key << ")"
71
9243
               << std::endl;
72
9243
  if (key == options::expr::defaultExprDepth__name)
73
  {
74
    int depth = (*d_options)[options::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
9243
  else if (key == options::expr::defaultDagThresh__name)
84
  {
85
13
    int dag = (*d_options)[options::defaultDagThresh];
86
13
    Debug.getStream() << expr::ExprDag(dag);
87
13
    Trace.getStream() << expr::ExprDag(dag);
88
13
    Notice.getStream() << expr::ExprDag(dag);
89
13
    Chat.getStream() << expr::ExprDag(dag);
90
13
    CVC5Message.getStream() << expr::ExprDag(dag);
91
13
    Warning.getStream() << expr::ExprDag(dag);
92
13
    Dump.getStream() << expr::ExprDag(dag);
93
  }
94
9230
  else if (key == options::smt::dumpModeString__name)
95
  {
96
3
    const std::string& value = (*d_options)[options::dumpModeString];
97
3
    Dump.setDumpFromString(value);
98
  }
99
9227
  else if (key == options::base::printSuccess__name)
100
  {
101
33
    bool value = (*d_options)[options::printSuccess];
102
33
    Debug.getStream() << Command::printsuccess(value);
103
33
    Trace.getStream() << Command::printsuccess(value);
104
33
    Notice.getStream() << Command::printsuccess(value);
105
33
    Chat.getStream() << Command::printsuccess(value);
106
33
    CVC5Message.getStream() << Command::printsuccess(value);
107
33
    Warning.getStream() << Command::printsuccess(value);
108
313054
    *options::out() << Command::printsuccess(value);
109
  }
110
9194
  else if (key == options::smt::regularChannelName__name)
111
  {
112
    d_managedRegularChannel.set(options::regularChannelName());
113
  }
114
9194
  else if (key == options::smt::diagnosticChannelName__name)
115
  {
116
    d_managedDiagnosticChannel.set(options::diagnosticChannelName());
117
  }
118
9194
  else if (key == options::smt::dumpToFileName__name)
119
  {
120
    d_managedDumpChannel.set(options::dumpToFileName());
121
  }
122
  // otherwise, no action is necessary
123
9242
}
124
125
8954
void OptionsManager::finishInit(LogicInfo& logic, bool isInternalSubsolver)
126
{
127
  // ensure that our heuristics are properly set up
128
8954
  setDefaults(logic, isInternalSubsolver);
129
8954
}
130
131
}  // namespace smt
132
444620
}  // namespace cvc5