version of CVC4. However, the new configure option "--bsd" disables
these GPL dependences and builds the best-performing BSD-licenced version
of CVC4.
+* Better automatic handling of output language setting when using CVC4
+ via API. Previously, the "automatic" language setting was sometimes
+ (though not always) defaulting to the internal "AST" language; it
+ should now (correctly) default to the same as the input language
+ (if the input language is supported as an output language), or the
+ "CVC4" native output language if no input language setting is applied.
Changes since 1.2
=================
public:
virtual ~CommandStatus() throw() {}
void toStream(std::ostream& out,
- OutputLanguage language = language::output::LANG_AST) const throw();
+ OutputLanguage language = language::output::LANG_AUTO) const throw();
virtual CommandStatus& clone() const = 0;
};/* class CommandStatus */
virtual void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
virtual void toStream(std::ostream& out, int toDepth = -1, bool types = false, size_t dag = 1,
- OutputLanguage language = language::output::LANG_AST) const throw();
+ OutputLanguage language = language::output::LANG_AUTO) const throw();
std::string toString() const throw();
* @param language the language in which to output
*/
void toStream(std::ostream& out, int toDepth = -1, bool types = false, size_t dag = 1,
- OutputLanguage language = language::output::LANG_AST) const;
+ OutputLanguage language = language::output::LANG_AUTO) const;
/**
* Check if this is a null expression.
* setlanguage() applied to them and where the current Options
* information isn't available.
*/
- static const int s_defaultOutputLanguage = language::output::LANG_AST;
+ static const int s_defaultOutputLanguage = language::output::LANG_AUTO;
/**
* When this manipulator is used, the setting is stored here.
* @param language the language in which to output
*/
inline void toStream(std::ostream& out, int toDepth = -1, bool types = false, size_t dag = 1,
- OutputLanguage language = language::output::LANG_AST) const {
+ OutputLanguage language = language::output::LANG_AUTO) const {
assertTNodeNotExpired();
d_nv->toStream(out, toDepth, types, dag, language);
}
string NodeValue::toString() const {
stringstream ss;
- OutputLanguage outlang = (this == &s_null) ? language::output::LANG_AST : options::outputLanguage();
- toStream(ss, -1, false, false,
- outlang == language::output::LANG_AUTO ?
- language::output::LANG_AST :
- outlang);
+ OutputLanguage outlang = (this == &s_null) ? language::output::LANG_AUTO : options::outputLanguage();
+ toStream(ss, -1, false, false, outlang);
return ss.str();
}
std::string toString() const;
void toStream(std::ostream& out, int toDepth = -1, bool types = false, size_t dag = 1,
- OutputLanguage = language::output::LANG_AST) const;
+ OutputLanguage = language::output::LANG_AUTO) const;
static inline unsigned kindToDKind(Kind k) {
return ((unsigned) k) & kindMask;
*/
inline std::string toString() const {
std::stringstream ss;
- OutputLanguage outlang = (this == &s_null) ? language::output::LANG_AST : options::outputLanguage();
- d_nv->toStream(ss, -1, false, 0,
- outlang == language::output::LANG_AUTO ?
- language::output::LANG_AST :
- outlang);
+ OutputLanguage outlang = (this == &s_null) ? language::output::LANG_AUTO : options::outputLanguage();
+ d_nv->toStream(ss, -1, false, 0, outlang);
return ss.str();
}
* @param out the stream to serialize this node to
* @param language the language in which to output
*/
- inline void toStream(std::ostream& out, OutputLanguage language = language::output::LANG_AST) const {
+ inline void toStream(std::ostream& out, OutputLanguage language = language::output::LANG_AUTO) const {
d_nv->toStream(out, -1, false, 0, language);
}
// null
if(n.getKind() == kind::NULL_EXPR) {
- out << "NULL";
+ out << "null";
return;
}
/** Get the Printer for a given OutputLanguage */
static Printer* getPrinter(OutputLanguage lang) throw() {
if(lang == language::output::LANG_AUTO) {
- lang = language::output::LANG_CVC4; // default
+ // Infer the language to use for output.
+ //
+ // Options can be null in certain circumstances (e.g., when printing
+ // the singleton "null" expr. So we guard against segfault
+ if(&Options::current() != NULL) {
+ if(options::outputLanguage.wasSetByUser()) {
+ lang = options::outputLanguage();
+ }
+ if(lang == language::output::LANG_AUTO && options::inputLanguage.wasSetByUser()) {
+ lang = language::toOutputLanguage(options::inputLanguage());
+ }
+ }
+ if(lang == language::output::LANG_AUTO) {
+ lang = language::output::LANG_CVC4; // default
+ }
}
if(d_printers[lang] == NULL) {
d_printers[lang] = makePrinter(lang);
class ExprPublic : public CxxTest::TestSuite {
private:
+ Options opts;
+
ExprManager* d_em;
Expr* a_bool;
void setUp() {
try {
- d_em = new ExprManager;
+ char *argv[2];
+ argv[0] = strdup("");
+ argv[1] = strdup("--output-language=ast");
+ opts.parseOptions(2, argv);
+ free(argv[0]);
+ free(argv[1]);
+
+ d_em = new ExprManager(opts);
a_bool = new Expr(d_em->mkVar("a",d_em->booleanType()));
b_bool = new Expr(d_em->mkVar("b", d_em->booleanType()));
fun_type = new Type(d_em->mkFunctionType(d_em->booleanType(), d_em->booleanType()));
fun_op = new Expr(d_em->mkVar("f", *fun_type));
d_apply_fun_bool = new Expr(d_em->mkExpr(APPLY_UF, *fun_op, *a_bool));
- null = new Expr;
+ null = new Expr();
i1 = new Expr(d_em->mkConst(Rational("0")));
i2 = new Expr(d_em->mkConst(Rational(23)));
class NodeBlack : public CxxTest::TestSuite {
private:
+ Options opts;
Context* d_ctxt;
NodeManager* d_nodeManager;
NodeManagerScope* d_scope;
public:
void setUp() {
- d_ctxt = new Context;
- d_nodeManager = new NodeManager(d_ctxt, NULL);
+ char *argv[2];
+ argv[0] = strdup("");
+ argv[1] = strdup("--output-language=ast");
+ opts.parseOptions(2, argv);
+ free(argv[0]);
+ free(argv[1]);
+
+ d_ctxt = new Context();
+ d_nodeManager = new NodeManager(d_ctxt, NULL, opts);
d_scope = new NodeManagerScope(d_nodeManager);
d_booleanType = new TypeNode(d_nodeManager->booleanType());
d_realType = new TypeNode(d_nodeManager->realType());