diff options
Diffstat (limited to 'src/printer')
-rw-r--r-- | src/printer/printer.cpp | 26 | ||||
-rw-r--r-- | src/printer/printer.h | 24 |
2 files changed, 27 insertions, 23 deletions
diff --git a/src/printer/printer.cpp b/src/printer/printer.cpp index 75d625edc..d4b99536e 100644 --- a/src/printer/printer.cpp +++ b/src/printer/printer.cpp @@ -17,6 +17,7 @@ #include <string> +#include "options/base_options.h" #include "options/language.h" #include "printer/ast/ast_printer.h" #include "printer/cvc/cvc_printer.h" @@ -87,4 +88,29 @@ void Printer::toStream(std::ostream& out, const UnsatCore& core, const std::map< } }/* Printer::toStream(UnsatCore, std::map<Expr, std::string>) */ +Printer* Printer::getPrinter(OutputLanguage lang) throw() { + if(lang == language::output::LANG_AUTO) { + // 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(not Options::isCurrentNull()) { + 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); + } + return d_printers[lang]; +} + + }/* CVC4 namespace */ diff --git a/src/printer/printer.h b/src/printer/printer.h index 30d33d46b..48787f70a 100644 --- a/src/printer/printer.h +++ b/src/printer/printer.h @@ -56,29 +56,7 @@ protected: public: /** Get the Printer for a given OutputLanguage */ - static Printer* getPrinter(OutputLanguage lang) throw() { - if(lang == language::output::LANG_AUTO) { - // 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(not Options::isCurrentNull()) { - 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); - } - return d_printers[lang]; - } + static Printer* getPrinter(OutputLanguage lang) throw(); /** Write a Node out to a stream with this Printer. */ virtual void toStream(std::ostream& out, TNode n, |