diff options
author | Morgan Deters <mdeters@cs.nyu.edu> | 2013-12-24 13:24:56 -0500 |
---|---|---|
committer | Morgan Deters <mdeters@cs.nyu.edu> | 2013-12-24 13:24:56 -0500 |
commit | e23a40c0d121209afecff21ce5c6ed6e644bfb0e (patch) | |
tree | 03752744a3388bd716c83c1dd3a4ba29556bb062 /src/printer/printer.h | |
parent | f42dcea977ed9180481cc842531e2c5372acbbe1 (diff) |
Better automatic handling of output language setting.
Diffstat (limited to 'src/printer/printer.h')
-rw-r--r-- | src/printer/printer.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/printer/printer.h b/src/printer/printer.h index a7ae8c447..9ddac096d 100644 --- a/src/printer/printer.h +++ b/src/printer/printer.h @@ -54,7 +54,21 @@ public: /** 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); |