1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Tim King, 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 |
|
* Interface for custom handlers and predicates options. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__OPTIONS__OPTIONS_HANDLER_H |
19 |
|
#define CVC5__OPTIONS__OPTIONS_HANDLER_H |
20 |
|
|
21 |
|
#include <ostream> |
22 |
|
#include <sstream> |
23 |
|
#include <string> |
24 |
|
|
25 |
|
#include "options/bv_options.h" |
26 |
|
#include "options/decision_options.h" |
27 |
|
#include "options/language.h" |
28 |
|
#include "options/managed_streams.h" |
29 |
|
#include "options/option_exception.h" |
30 |
|
#include "options/quantifiers_options.h" |
31 |
|
|
32 |
|
namespace cvc5 { |
33 |
|
|
34 |
|
class Options; |
35 |
|
|
36 |
|
namespace options { |
37 |
|
|
38 |
|
/** |
39 |
|
* Class that responds to command line options being set. |
40 |
|
* |
41 |
|
* Most functions can throw an OptionException on failure. |
42 |
|
*/ |
43 |
|
class OptionsHandler { |
44 |
|
public: |
45 |
|
OptionsHandler(Options* options); |
46 |
|
|
47 |
|
template <typename T> |
48 |
2 |
void checkMinimum(const std::string& option, |
49 |
|
const std::string& flag, |
50 |
|
T value, |
51 |
|
T minimum) const |
52 |
|
{ |
53 |
2 |
if (value < minimum) |
54 |
|
{ |
55 |
|
std::stringstream ss; |
56 |
|
ss << flag << " = " << value |
57 |
|
<< " is not a legal setting, value should be at least " << minimum |
58 |
|
<< "."; |
59 |
|
throw OptionException(ss.str()); |
60 |
|
} |
61 |
2 |
} |
62 |
|
template <typename T> |
63 |
|
void checkMaximum(const std::string& option, |
64 |
|
const std::string& flag, |
65 |
|
T value, |
66 |
|
T maximum) const |
67 |
|
{ |
68 |
|
if (value > maximum) |
69 |
|
{ |
70 |
|
std::stringstream ss; |
71 |
|
ss << flag << " = " << value |
72 |
|
<< " is not a legal setting, value should be at most " << maximum |
73 |
|
<< "."; |
74 |
|
throw OptionException(ss.str()); |
75 |
|
} |
76 |
|
} |
77 |
|
|
78 |
|
// theory/quantifiers/options_handlers.h |
79 |
|
void checkInstWhenMode(const std::string& option, |
80 |
|
const std::string& flag, |
81 |
|
InstWhenMode mode); |
82 |
|
|
83 |
|
// theory/bv/options_handlers.h |
84 |
|
void abcEnabledBuild(const std::string& option, |
85 |
|
const std::string& flag, |
86 |
|
bool value); |
87 |
|
void abcEnabledBuild(const std::string& option, |
88 |
|
const std::string& flag, |
89 |
|
const std::string& value); |
90 |
|
|
91 |
|
void checkBvSatSolver(const std::string& option, |
92 |
|
const std::string& flag, |
93 |
|
SatSolverMode m); |
94 |
|
void checkBitblastMode(const std::string& option, |
95 |
|
const std::string& flag, |
96 |
|
BitblastMode m); |
97 |
|
|
98 |
|
void setBitblastAig(const std::string& option, |
99 |
|
const std::string& flag, |
100 |
|
bool arg); |
101 |
|
|
102 |
|
/** |
103 |
|
* Throws a ModalException if this option is being set after final |
104 |
|
* initialization. |
105 |
|
*/ |
106 |
|
void setProduceAssertions(const std::string& option, |
107 |
|
const std::string& flag, |
108 |
|
bool value); |
109 |
|
|
110 |
|
void setStats(const std::string& option, const std::string& flag, bool value); |
111 |
|
|
112 |
|
uint64_t limitHandler(const std::string& option, |
113 |
|
const std::string& flag, |
114 |
|
const std::string& optarg); |
115 |
|
void setResourceWeight(const std::string& option, |
116 |
|
const std::string& flag, |
117 |
|
const std::string& optarg); |
118 |
|
|
119 |
|
/* expr/options_handlers.h */ |
120 |
|
void setDefaultExprDepth(const std::string& option, |
121 |
|
const std::string& flag, |
122 |
|
int depth); |
123 |
|
void setDefaultDagThresh(const std::string& option, |
124 |
|
const std::string& flag, |
125 |
|
int dag); |
126 |
|
|
127 |
|
/* main/options_handlers.h */ |
128 |
|
void copyright(const std::string& option, const std::string& flag); |
129 |
|
void showConfiguration(const std::string& option, const std::string& flag); |
130 |
|
void showDebugTags(const std::string& option, const std::string& flag); |
131 |
|
void showTraceTags(const std::string& option, const std::string& flag); |
132 |
|
void threadN(const std::string& option, const std::string& flag); |
133 |
|
|
134 |
|
/* options/base_options_handlers.h */ |
135 |
|
void setDumpStream(const std::string& option, |
136 |
|
const std::string& flag, |
137 |
|
const ManagedOut& mo); |
138 |
|
void setErrStream(const std::string& option, |
139 |
|
const std::string& flag, |
140 |
|
const ManagedErr& me); |
141 |
|
void setInStream(const std::string& option, |
142 |
|
const std::string& flag, |
143 |
|
const ManagedIn& mi); |
144 |
|
void setOutStream(const std::string& option, |
145 |
|
const std::string& flag, |
146 |
|
const ManagedOut& mo); |
147 |
|
void setVerbosity(const std::string& option, |
148 |
|
const std::string& flag, |
149 |
|
int value); |
150 |
|
void increaseVerbosity(const std::string& option, const std::string& flag); |
151 |
|
void decreaseVerbosity(const std::string& option, const std::string& flag); |
152 |
|
/** Convert optarg to Language enum */ |
153 |
|
Language stringToLanguage(const std::string& option, |
154 |
|
const std::string& flag, |
155 |
|
const std::string& optarg); |
156 |
|
/** Apply the output language to the default output stream */ |
157 |
|
void applyOutputLanguage(const std::string& option, |
158 |
|
const std::string& flag, |
159 |
|
Language lang); |
160 |
|
/** Check that lang is not LANG_AST (which is not allowed as input language). */ |
161 |
|
void languageIsNotAST(const std::string& option, |
162 |
|
const std::string& flag, |
163 |
|
Language lang); |
164 |
|
void enableTraceTag(const std::string& option, |
165 |
|
const std::string& flag, |
166 |
|
const std::string& optarg); |
167 |
|
void enableDebugTag(const std::string& option, |
168 |
|
const std::string& flag, |
169 |
|
const std::string& optarg); |
170 |
|
|
171 |
|
void enableOutputTag(const std::string& option, |
172 |
|
const std::string& flag, |
173 |
|
const std::string& optarg); |
174 |
|
|
175 |
|
void setDumpMode(const std::string& option, |
176 |
|
const std::string& flag, |
177 |
|
const std::string& optarg); |
178 |
|
void setPrintSuccess(const std::string& option, |
179 |
|
const std::string& flag, |
180 |
|
bool value); |
181 |
|
|
182 |
|
private: |
183 |
|
|
184 |
|
/** Pointer to the containing Options object.*/ |
185 |
|
Options* d_options; |
186 |
|
}; /* class OptionHandler */ |
187 |
|
|
188 |
|
} // namespace options |
189 |
|
} // namespace cvc5 |
190 |
|
|
191 |
|
#endif /* CVC5__OPTIONS__OPTIONS_HANDLER_H */ |