#include <iostream>
-using namespace std;
-
namespace cvc5 {
/* Definitions of the declared globals from output.h... */
null_streambuf null_sb;
-ostream null_os(&null_sb);
+std::ostream null_os(&null_sb);
NullC nullStream;
const std::string Cvc5ostream::s_tab = " ";
-const int Cvc5ostream::s_indentIosIndex = ios_base::xalloc();
+const int Cvc5ostream::s_indentIosIndex = std::ios_base::xalloc();
-DebugC DebugChannel(&cout);
-WarningC WarningChannel(&cerr);
-MessageC MessageChannel(&cout);
+DebugC DebugChannel(&std::cout);
+WarningC WarningChannel(&std::cerr);
+MessageC MessageChannel(&std::cout);
NoticeC NoticeChannel(&null_os);
ChatC ChatChannel(&null_os);
-TraceC TraceChannel(&cout);
-std::ostream DumpOutC::dump_cout(cout.rdbuf());// copy cout stream buffer
+TraceC TraceChannel(&std::cout);
+std::ostream DumpOutC::dump_cout(std::cout.rdbuf()); // copy cout stream buffer
DumpOutC DumpOutChannel(&DumpOutC::dump_cout);
} // namespace cvc5
options_listener.h
options_public.cpp
options_public.h
+ outputc.cpp
+ outputc.h
printer_modes.cpp
printer_modes.h
set_language.cpp
name = "resourceWeightHolder"
category = "undocumented"
type = "std::vector<std::string>"
+
+[[option]]
+ name = "outputTag"
+ short = "o"
+ long = "output=TAG"
+ type = "OutputTag"
+ handler = "enableOutputTag"
+ category = "regular"
+ help = "Enable output tag."
+ help_mode = "Output tags."
+[[option.mode.INST]]
+ name = "inst"
+ help = "print instantiations during solving"
+[[option.mode.SYGUS]]
+ name = "sygus"
+ help = "print enumerated terms and candidates generated by the sygus solver"
+
+# Stores then enabled output tags.
+[[option]]
+ name = "outputTagHolder"
+ category = "undocumented"
+ includes = ["<bitset>"]
+ type = "std::bitset<OutputTag__numValues>"
enum class {type}
{{
{values}
-}};"""
+}};
+
+static constexpr size_t {type}__numValues = {nvalues};
+"""
TPL_DECL_MODE_FUNC = \
"""
wrapper = textwrap.TextWrapper(width=78, break_on_hyphens=False)
text = ['{}'.format(x) for x in wrapper.wrap(option.help_mode)]
- text.append('Available modes for --{} are:'.format(option.long.split('=')[0]))
+
+ optname, optvalue = option.long.split('=')
+ text.append('Available {}s for --{} are:'.format(
+ optvalue.lower(), optname))
for value, attrib in option.mode.items():
assert len(attrib) == 1
mode_decl.append(
TPL_DECL_MODE_ENUM.format(
type=option.type,
- values=',\n '.join(values)))
+ values=',\n '.join(values),
+ nvalues=len(values)))
mode_decl.append(TPL_DECL_MODE_FUNC.format(type=option.type))
cases = [TPL_IMPL_MODE_CASE.format(
type=option.type, enum=x) for x in values]
sorted(module.options, key=lambda x: x.long if x.long else x.name):
assert option.type != 'void' or option.name is None
assert option.name or option.short or option.long
+ mode_handler = option.handler and option.mode
argument_req = option.type not in ['bool', 'void']
docgen_option(option, help_common, help_others)
name=option.name,
option='option',
value='true'))
- elif option.type != 'void' and option.name:
+ elif option.type != 'void' and option.name and not mode_handler:
cases.append(
TPL_CALL_ASSIGN.format(
module=module.id,
name=option.name,
option='key',
value='optionarg == "true"'))
- elif argument_req and option.name:
+ elif argument_req and option.name and not mode_handler:
setoption_handlers.append(
TPL_CALL_ASSIGN.format(
module=module.id,
# Define handler assign/assignBool
- if option.type == 'bool':
- custom_handlers.append(TPL_ASSIGN_BOOL.format(
- module=module.id,
- name=option.name,
- handler=handler,
- predicates='\n'.join(predicates)
- ))
- elif option.short or option.long:
- custom_handlers.append(TPL_ASSIGN.format(
- module=module.id,
- name=option.name,
- handler=handler,
- predicates='\n'.join(predicates)
- ))
+ if not mode_handler:
+ if option.type == 'bool':
+ custom_handlers.append(TPL_ASSIGN_BOOL.format(
+ module=module.id,
+ name=option.name,
+ handler=handler,
+ predicates='\n'.join(predicates)
+ ))
+ elif option.short or option.long:
+ custom_handlers.append(TPL_ASSIGN.format(
+ module=module.id,
+ name=option.name,
+ handler=handler,
+ predicates='\n'.join(predicates)
+ ))
# Default option values
default = option.default if option.default else ''
option = Option(attribs)
if option.mode and not option.help_mode:
perr(filename, 'defines modes but no help_mode', option)
- if option.mode and option.handler:
- perr(filename, 'defines modes and a handler', option)
if option.mode and option.default and \
option.default not in option.mode.keys():
perr(filename,
Trace.on(optarg);
}
+void OptionsHandler::enableOutputTag(const std::string& option,
+ const std::string& flag,
+ const std::string& optarg)
+{
+ d_options->base.outputTagHolder.set(
+ static_cast<size_t>(stringToOutputTag(optarg)));
+}
+
OutputLanguage OptionsHandler::stringToOutputLanguage(const std::string& option,
const std::string& flag,
const std::string& optarg)
const std::string& flag,
const std::string& optarg);
+ void enableOutputTag(const std::string& option,
+ const std::string& flag,
+ const std::string& optarg);
+
private:
/** Pointer to the containing Options object.*/
--- /dev/null
+#include "options/outputc.h"
+
+#include <iostream>
+
+namespace cvc5 {
+
+OutputC OutputChannel(&std::cout);
+
+Cvc5ostream OutputC::operator()(const options::OutputTag tag) const
+{
+ if (options::outputTagHolder()[static_cast<size_t>(tag)])
+ {
+ return Cvc5ostream(d_os);
+ }
+ else
+ {
+ return Cvc5ostream();
+ }
+}
+
+bool OutputC::isOn(const options::OutputTag tag) const
+{
+ return options::outputTagHolder()[static_cast<size_t>(tag)];
+}
+
+} // namespace cvc5
--- /dev/null
+#include "cvc5_private_library.h"
+
+#ifndef CVC5__OPTIONS__OUTPUTC_H
+#define CVC5__OPTIONS__OUTPUTC_H
+
+#include <iostream>
+
+#include "cvc5_export.h"
+#include "base/output.h"
+#include "options/base_options.h"
+
+namespace cvc5 {
+
+class OutputC
+{
+ public:
+ explicit OutputC(std::ostream* os) : d_os(os) {}
+
+ Cvc5ostream operator()(const options::OutputTag tag) const;
+
+ bool isOn(const options::OutputTag tag) const;
+
+ private:
+ std::ostream* d_os;
+
+}; /* class OutputC */
+
+extern OutputC OutputChannel CVC5_EXPORT;
+
+#ifdef CVC5_MUZZLE
+#define Output ::cvc5::__cvc5_true() ? ::cvc5::nullStream : ::cvc5::OutputChannel
+#else /* CVC5_MUZZLE */
+#define Output ::cvc5::OutputChannel
+#endif /* CVC5_MUZZLE */
+
+}
+
+#endif /* CVC5__OPTIONS__OUTPUTC_H */
default = "false"
help = "compute backwards filtering to compute whether previous solutions are filtered based on later ones"
-[[option]]
- name = "debugSygus"
- category = "regular"
- long = "debug-sygus"
- type = "bool"
- default = "false"
- help = "print enumerated terms and candidates generated by the sygus solver (for debugging)"
-
# CEGQI applied to general quantified formulas
[[option]]
default = "true"
help = "use store axiom during ho-elim"
-### Output options
-
-[[option]]
- name = "debugInst"
- category = "regular"
- long = "debug-inst"
- type = "bool"
- default = "false"
- help = "print instantiations during solving (for debugging)"
-
### SyGuS instantiation options
[[option]]
#include "expr/node_algorithm.h"
#include "options/base_options.h"
+#include "options/outputc.h"
#include "options/printer_options.h"
#include "options/quantifiers_options.h"
#include "options/smt_options.h"
void Instantiate::notifyEndRound()
{
- bool debugInstTrace = Trace.isOn("inst-per-quant-round");
- if (options::debugInst() || debugInstTrace)
+ // debug information
+ if (Trace.isOn("inst-per-quant-round"))
{
- Options& sopts = smt::currentSmtEngine()->getOptions();
- std::ostream& out = *sopts.base.out;
- // debug information
- if (debugInstTrace)
+ for (std::pair<const Node, uint32_t>& i : d_instDebugTemp)
{
- for (std::pair<const Node, uint32_t>& i : d_instDebugTemp)
- {
- Trace("inst-per-quant-round")
- << " * " << i.second << " for " << i.first << std::endl;
- }
+ Trace("inst-per-quant-round")
+ << " * " << i.second << " for " << i.first << std::endl;
}
- if (options::debugInst())
+ }
+ if (Output.isOn(options::OutputTag::INST))
+ {
+ bool req = !options::printInstFull();
+ for (std::pair<const Node, uint32_t>& i : d_instDebugTemp)
{
- bool req = !options::printInstFull();
- for (std::pair<const Node, uint32_t>& i : d_instDebugTemp)
+ Node name;
+ if (!d_qreg.getNameForQuant(i.first, name, req))
{
- Node name;
- if (!d_qreg.getNameForQuant(i.first, name, req))
- {
- continue;
- }
- out << "(num-instantiations " << name << " " << i.second << ")"
- << std::endl;
+ continue;
}
+ Output(options::OutputTag::INST) << "(num-instantiations " << name << " "
+ << i.second << ")" << std::endl;
}
}
}
#include "expr/skolem_manager.h"
#include "options/base_options.h"
#include "options/datatypes_options.h"
+#include "options/outputc.h"
#include "options/quantifiers_options.h"
#include "printer/printer.h"
#include "smt/logic_exception.h"
}
}
- bool printDebug = options::debugSygus();
+ bool printDebug = Output.isOn(options::OutputTag::SYGUS);
if (!constructed_cand)
{
// get the model value of the relevant terms from the master module
}
}
Trace("sygus-engine") << std::endl;
- if (printDebug)
- {
- Options& sopts = smt::currentSmtEngine()->getOptions();
- std::ostream& out = *sopts.base.out;
- out << "(sygus-enum" << sygusEnumOut.str() << ")" << std::endl;
- }
+ Output(options::OutputTag::SYGUS)
+ << "(sygus-enum" << sygusEnumOut.str() << ")" << std::endl;
}
Assert(candidate_values.empty());
constructed_cand = d_master->constructCandidates(
-; COMMAND-LINE: --debug-sygus
+; COMMAND-LINE: -o sygus
; EXPECT: (sygus-enum 0)
; EXPECT: (sygus-candidate (f 0))
; EXPECT: (sygus-enum 1)
-; COMMAND-LINE: --debug-inst --no-check-unsat-cores
+; COMMAND-LINE: -o inst --no-check-unsat-cores
; EXPECT: (num-instantiations myQuant1 1)
; EXPECT: (num-instantiations myQuant2 1)
; EXPECT: unsat