GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/theory_options.cpp Lines: 11 75 14.7 %
Date: 2021-08-06 Branches: 8 76 10.5 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Mathias Preiner, 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
 * Option template for option modules.
14
 *
15
 * For each <module>_options.toml configuration file, mkoptions.py
16
 * expands this template and generates a <module>_options.cpp file.
17
 */
18
#include "options/theory_options.h"
19
20
#include <iostream>
21
22
#include "base/check.h"
23
#include "options/option_exception.h"
24
25
// clang-format off
26
namespace cvc5 {
27
28
29
30
namespace options {
31
32
thread_local struct assignFunctionValues__option_t assignFunctionValues;
33
thread_local struct condenseFunctionValues__option_t condenseFunctionValues;
34
thread_local struct eeMode__option_t eeMode;
35
thread_local struct relevanceFilter__option_t relevanceFilter;
36
thread_local struct tcMode__option_t tcMode;
37
thread_local struct theoryOfMode__option_t theoryOfMode;
38
39
40
std::ostream& operator<<(std::ostream& os, EqEngineMode mode)
41
{
42
  switch(mode) {
43
    case EqEngineMode::DISTRIBUTED:
44
      return os << "EqEngineMode::DISTRIBUTED";
45
    case EqEngineMode::CENTRAL:
46
      return os << "EqEngineMode::CENTRAL";
47
    default:
48
      Unreachable();
49
  }
50
  return os;
51
}
52
53
56
EqEngineMode stringToEqEngineMode(const std::string& optarg)
54
{
55
56
  if (optarg == "distributed")
56
  {
57
28
    return EqEngineMode::DISTRIBUTED;
58
  }
59
28
  else if (optarg == "central")
60
  {
61
28
    return EqEngineMode::CENTRAL;
62
  }
63
  else if (optarg == "help")
64
  {
65
    std::cerr << "Defines mode for managing equalities across theory solvers.\n"
66
         "Available modes for --ee-mode are:\n"
67
         "+ distributed (default)\n"
68
         "  Each theory maintains its own equality engine.\n"
69
         "+ central\n"
70
         "  All applicable theories use the central equality engine.\n";
71
    std::exit(1);
72
  }
73
  throw OptionException(std::string("unknown option for --ee-mode: `") +
74
                        optarg + "'.  Try --ee-mode=help.");
75
}
76
77
std::ostream& operator<<(std::ostream& os, TcMode mode)
78
{
79
  switch(mode) {
80
    case TcMode::CARE_GRAPH:
81
      return os << "TcMode::CARE_GRAPH";
82
    default:
83
      Unreachable();
84
  }
85
  return os;
86
}
87
88
TcMode stringToTcMode(const std::string& optarg)
89
{
90
  if (optarg == "care-graph")
91
  {
92
    return TcMode::CARE_GRAPH;
93
  }
94
  else if (optarg == "help")
95
  {
96
    std::cerr << "Defines mode for theory combination.\n"
97
         "Available modes for --tc-mode are:\n"
98
         "+ care-graph (default)\n"
99
         "  Use care graphs for theory combination.\n";
100
    std::exit(1);
101
  }
102
  throw OptionException(std::string("unknown option for --tc-mode: `") +
103
                        optarg + "'.  Try --tc-mode=help.");
104
}
105
106
std::ostream& operator<<(std::ostream& os, TheoryOfMode mode)
107
{
108
  switch(mode) {
109
    case TheoryOfMode::THEORY_OF_TERM_BASED:
110
      return os << "TheoryOfMode::THEORY_OF_TERM_BASED";
111
    case TheoryOfMode::THEORY_OF_TYPE_BASED:
112
      return os << "TheoryOfMode::THEORY_OF_TYPE_BASED";
113
    default:
114
      Unreachable();
115
  }
116
  return os;
117
}
118
119
5
TheoryOfMode stringToTheoryOfMode(const std::string& optarg)
120
{
121
5
  if (optarg == "term")
122
  {
123
2
    return TheoryOfMode::THEORY_OF_TERM_BASED;
124
  }
125
3
  else if (optarg == "type")
126
  {
127
3
    return TheoryOfMode::THEORY_OF_TYPE_BASED;
128
  }
129
  else if (optarg == "help")
130
  {
131
    std::cerr << "Defines how we associate theories with terms.\n"
132
         "Available modes for --theoryof-mode are:\n"
133
         "+ term\n"
134
         "  Type variables as uninterpreted, type constants by theory, equalities by the\n"
135
         "  parametric theory.\n"
136
         "+ type (default)\n"
137
         "  Type variables, constants and equalities by type.\n";
138
    std::exit(1);
139
  }
140
  throw OptionException(std::string("unknown option for --theoryof-mode: `") +
141
                        optarg + "'.  Try --theoryof-mode=help.");
142
}
143
144
145
146
namespace theory
147
{
148
// clang-format off
149
void setDefaultAssignFunctionValues(Options& opts, bool value)
150
{
151
    if (!opts.theory.assignFunctionValuesWasSetByUser) {
152
        opts.theory.assignFunctionValues = value;
153
    }
154
}
155
void setDefaultCondenseFunctionValues(Options& opts, bool value)
156
{
157
    if (!opts.theory.condenseFunctionValuesWasSetByUser) {
158
        opts.theory.condenseFunctionValues = value;
159
    }
160
}
161
void setDefaultEeMode(Options& opts, EqEngineMode value)
162
{
163
    if (!opts.theory.eeModeWasSetByUser) {
164
        opts.theory.eeMode = value;
165
    }
166
}
167
void setDefaultRelevanceFilter(Options& opts, bool value)
168
{
169
    if (!opts.theory.relevanceFilterWasSetByUser) {
170
        opts.theory.relevanceFilter = value;
171
    }
172
}
173
void setDefaultTcMode(Options& opts, TcMode value)
174
{
175
    if (!opts.theory.tcModeWasSetByUser) {
176
        opts.theory.tcMode = value;
177
    }
178
}
179
void setDefaultTheoryOfMode(Options& opts, TheoryOfMode value)
180
{
181
    if (!opts.theory.theoryOfModeWasSetByUser) {
182
        opts.theory.theoryOfMode = value;
183
    }
184
}
185
// clang-format on
186
}
187
188
}  // namespace options
189
29322
}  // namespace cvc5
190
// clang-format on