2013-12-30 19:20:23 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include "kernel/kernel_exception.h"
|
2014-08-22 17:32:01 +00:00
|
|
|
#include "library/print.h"
|
2014-04-26 01:30:40 +00:00
|
|
|
#include "library/io_state.h"
|
2013-12-30 19:20:23 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2014-09-23 17:45:14 +00:00
|
|
|
static io_state * g_dummy_ios = nullptr;
|
|
|
|
|
|
|
|
void initialize_io_state() {
|
|
|
|
g_dummy_ios = new io_state(mk_print_formatter_factory());
|
|
|
|
}
|
|
|
|
|
|
|
|
void finalize_io_state() {
|
|
|
|
delete g_dummy_ios;
|
|
|
|
}
|
|
|
|
|
2014-06-15 05:13:25 +00:00
|
|
|
io_state const & get_dummy_ios() {
|
2014-09-23 17:45:14 +00:00
|
|
|
return *g_dummy_ios;
|
2014-06-15 05:13:25 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 20:18:22 +00:00
|
|
|
io_state::io_state():io_state(mk_print_formatter_factory()) {}
|
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
io_state::io_state(formatter_factory const & fmtf):
|
|
|
|
m_formatter_factory(fmtf),
|
2013-12-30 19:20:23 +00:00
|
|
|
m_regular_channel(std::make_shared<stdout_channel>()),
|
|
|
|
m_diagnostic_channel(std::make_shared<stderr_channel>()) {
|
|
|
|
}
|
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
io_state::io_state(options const & opts, formatter_factory const & fmtf):
|
2013-12-30 19:20:23 +00:00
|
|
|
m_options(opts),
|
2014-07-10 17:32:00 +00:00
|
|
|
m_formatter_factory(fmtf),
|
2013-12-30 19:20:23 +00:00
|
|
|
m_regular_channel(std::make_shared<stdout_channel>()),
|
|
|
|
m_diagnostic_channel(std::make_shared<stderr_channel>()) {
|
|
|
|
}
|
2014-05-24 20:18:28 +00:00
|
|
|
io_state::io_state(io_state const & ios, std::shared_ptr<output_channel> const & r, std::shared_ptr<output_channel> const d):
|
|
|
|
m_options(ios.m_options),
|
2014-07-10 17:32:00 +00:00
|
|
|
m_formatter_factory(ios.m_formatter_factory),
|
2014-05-24 20:18:28 +00:00
|
|
|
m_regular_channel(r),
|
|
|
|
m_diagnostic_channel(d) {
|
|
|
|
}
|
2014-08-27 17:46:49 +00:00
|
|
|
io_state::io_state(io_state const & ios, options const & o):
|
|
|
|
m_options(o),
|
|
|
|
m_formatter_factory(ios.m_formatter_factory),
|
|
|
|
m_regular_channel(ios.m_regular_channel),
|
|
|
|
m_diagnostic_channel(ios.m_diagnostic_channel) {
|
|
|
|
}
|
2013-12-30 19:20:23 +00:00
|
|
|
|
|
|
|
io_state::~io_state() {}
|
|
|
|
|
|
|
|
void io_state::set_regular_channel(std::shared_ptr<output_channel> const & out) {
|
|
|
|
if (out)
|
|
|
|
m_regular_channel = out;
|
|
|
|
}
|
|
|
|
|
|
|
|
void io_state::set_diagnostic_channel(std::shared_ptr<output_channel> const & out) {
|
|
|
|
if (out)
|
|
|
|
m_diagnostic_channel = out;
|
|
|
|
}
|
|
|
|
|
|
|
|
void io_state::set_options(options const & opts) {
|
|
|
|
m_options = opts;
|
|
|
|
}
|
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
void io_state::set_formatter_factory(formatter_factory const & f) {
|
|
|
|
m_formatter_factory = f;
|
2013-12-30 19:20:23 +00:00
|
|
|
}
|
|
|
|
}
|