This disables the temporarily available internals of Result.
It further changes the interface for getUnknownExplanation, which now
returns an enum value instead of a string.
return *d_result != *r.d_result;
}
-std::string Result::getUnknownExplanation(void) const
+Result::UnknownExplanation Result::getUnknownExplanation(void) const
{
- std::stringstream ss;
- ss << d_result->whyUnknown();
- return ss.str();
+ CVC4::Result::UnknownExplanation expl = d_result->whyUnknown();
+ switch (expl)
+ {
+ case CVC4::Result::REQUIRES_FULL_CHECK: return REQUIRES_FULL_CHECK;
+ case CVC4::Result::INCOMPLETE: return INCOMPLETE;
+ case CVC4::Result::TIMEOUT: return TIMEOUT;
+ case CVC4::Result::RESOURCEOUT: return RESOURCEOUT;
+ case CVC4::Result::MEMOUT: return MEMOUT;
+ case CVC4::Result::INTERRUPTED: return INTERRUPTED;
+ case CVC4::Result::NO_STATUS: return NO_STATUS;
+ case CVC4::Result::UNSUPPORTED: return UNSUPPORTED;
+ case CVC4::Result::OTHER: return OTHER;
+ default: return UNKNOWN_REASON;
+ }
+ return UNKNOWN_REASON;
}
std::string Result::toString(void) const { return d_result->toString(); }
-// !!! This is only temporarily available until the parser is fully migrated
-// to the new API. !!!
-CVC4::Result Result::getResult(void) const { return *d_result; }
-
std::ostream& operator<<(std::ostream& out, const Result& r)
{
out << r.toString();
return out;
}
+std::ostream& operator<<(std::ostream& out, enum Result::UnknownExplanation e)
+{
+ switch (e)
+ {
+ case Result::REQUIRES_FULL_CHECK: out << "REQUIRES_FULL_CHECK"; break;
+ case Result::INCOMPLETE: out << "INCOMPLETE"; break;
+ case Result::TIMEOUT: out << "TIMEOUT"; break;
+ case Result::RESOURCEOUT: out << "RESOURCEOUT"; break;
+ case Result::MEMOUT: out << "MEMOUT"; break;
+ case Result::INTERRUPTED: out << "INTERRUPTED"; break;
+ case Result::NO_STATUS: out << "NO_STATUS"; break;
+ case Result::UNSUPPORTED: out << "UNSUPPORTED"; break;
+ case Result::OTHER: out << "OTHER"; break;
+ case Result::UNKNOWN_REASON: out << "UNKNOWN_REASON"; break;
+ default: Unhandled() << e;
+ }
+ return out;
+}
+
/* -------------------------------------------------------------------------- */
/* Sort */
/* -------------------------------------------------------------------------- */
friend class Solver;
public:
- // !!! This constructor is only temporarily public until the parser is fully
- // migrated to the new API. !!!
- /**
- * Constructor.
- * @param r the internal result that is to be wrapped by this result
- * @return the Result
- */
- Result(const CVC4::Result& r);
+ enum UnknownExplanation
+ {
+ REQUIRES_FULL_CHECK,
+ INCOMPLETE,
+ TIMEOUT,
+ RESOURCEOUT,
+ MEMOUT,
+ INTERRUPTED,
+ NO_STATUS,
+ UNSUPPORTED,
+ OTHER,
+ UNKNOWN_REASON
+ };
/** Constructor. */
Result();
/**
* @return an explanation for an unknown query result.
*/
- std::string getUnknownExplanation() const;
+ UnknownExplanation getUnknownExplanation() const;
/**
* @return a string representation of this result.
*/
std::string toString() const;
- // !!! This is only temporarily available until the parser is fully migrated
- // to the new API. !!!
- CVC4::Result getResult(void) const;
-
private:
+ /**
+ * Constructor.
+ * @param r the internal result that is to be wrapped by this result
+ * @return the Result
+ */
+ Result(const CVC4::Result& r);
+
/**
* The interal result wrapped by this result.
* This is a shared_ptr rather than a unique_ptr since CVC4::Result is
};
/**
- * Serialize a result to given stream.
+ * Serialize a Result to given stream.
* @param out the output stream
* @param r the result to be serialized to the given output stream
* @return the output stream
*/
std::ostream& operator<<(std::ostream& out, const Result& r) CVC4_PUBLIC;
+/**
+ * Serialize an UnknownExplanation to given stream.
+ * @param out the output stream
+ * @param r the explanation to be serialized to the given output stream
+ * @return the output stream
+ */
+std::ostream& operator<<(std::ostream& out,
+ enum Result::UnknownExplanation e) CVC4_PUBLIC;
+
/* -------------------------------------------------------------------------- */
/* Sort */
/* -------------------------------------------------------------------------- */
if (d_options.getDumpModels()
&& (res.isSat()
|| (res.isSatUnknown()
- && res.getResult().whyUnknown() == Result::INCOMPLETE)))
+ && res.getUnknownExplanation() == api::Result::INCOMPLETE)))
{
getterCommands.emplace_back(new GetModelCommand());
}
&& ((d_options.getInstFormatMode() != options::InstFormatMode::SZS
&& (res.isSat()
|| (res.isSatUnknown()
- && res.getResult().whyUnknown() == Result::INCOMPLETE)))
+ && res.getUnknownExplanation()
+ == api::Result::INCOMPLETE)))
|| isResultUnsat))
{
getterCommands.emplace_back(new GetInstantiationsCommand());
#include <vector>
#include "api/cvc4cpp.h"
-#include "util/result.h"
#include "util/sexpr.h"
namespace CVC4 {
return out;
}
-ostream& operator<<(ostream& out, enum Result::UnknownExplanation e) {
- switch (e) {
- case Result::REQUIRES_FULL_CHECK:
- out << "REQUIRES_FULL_CHECK";
- break;
- case Result::INCOMPLETE:
- out << "INCOMPLETE";
- break;
- case Result::TIMEOUT:
- out << "TIMEOUT";
- break;
- case Result::RESOURCEOUT:
- out << "RESOURCEOUT";
- break;
- case Result::MEMOUT:
- out << "MEMOUT";
- break;
- case Result::INTERRUPTED:
- out << "INTERRUPTED";
- break;
- case Result::NO_STATUS:
- out << "NO_STATUS";
- break;
- case Result::UNSUPPORTED:
- out << "UNSUPPORTED";
- break;
- case Result::OTHER:
- out << "OTHER";
- break;
- case Result::UNKNOWN_REASON:
- out << "UNKNOWN_REASON";
- break;
+ostream& operator<<(ostream& out, enum Result::UnknownExplanation e)
+{
+ switch (e)
+ {
+ case Result::REQUIRES_FULL_CHECK: out << "REQUIRES_FULL_CHECK"; break;
+ case Result::INCOMPLETE: out << "INCOMPLETE"; break;
+ case Result::TIMEOUT: out << "TIMEOUT"; break;
+ case Result::RESOURCEOUT: out << "RESOURCEOUT"; break;
+ case Result::MEMOUT: out << "MEMOUT"; break;
+ case Result::INTERRUPTED: out << "INTERRUPTED"; break;
+ case Result::NO_STATUS: out << "NO_STATUS"; break;
+ case Result::UNSUPPORTED: out << "UNSUPPORTED"; break;
+ case Result::OTHER: out << "OTHER"; break;
+ case Result::UNKNOWN_REASON: out << "UNKNOWN_REASON"; break;
default: Unhandled() << e;
}
return out;
TYPE_NONE
};
- enum UnknownExplanation {
+ enum UnknownExplanation
+ {
REQUIRES_FULL_CHECK,
INCOMPLETE,
TIMEOUT,
CVC4::api::Result res = d_solver.checkEntailed(x.eqTerm(x));
ASSERT_FALSE(res.isEntailed());
ASSERT_TRUE(res.isEntailmentUnknown());
- ASSERT_EQ(res.getUnknownExplanation(), "UNKNOWN_REASON");
+ ASSERT_EQ(res.getUnknownExplanation(), api::Result::UNKNOWN_REASON);
}
} // namespace test
} // namespace CVC4