lean2/src/library/io_state_stream.cpp
Leonardo de Moura ecc5d1bc3a refactor(kernel): move printer to library, cleanup io_state interface
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-02 13:37:50 -08:00

39 lines
1.3 KiB
C++

/*
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 "library/io_state_stream.h"
#include "kernel/kernel_exception.h"
#include "library/printer.h"
namespace lean {
io_state_stream const & operator<<(io_state_stream const & out, endl_class) {
out.get_stream() << std::endl;
return out;
}
io_state_stream const & operator<<(io_state_stream const & out, expr const & e) {
options const & opts = out.get_options();
out.get_stream() << mk_pair(out.get_formatter()(e, opts), opts);
return out;
}
io_state_stream const & operator<<(io_state_stream const & out, object const & obj) {
options const & opts = out.get_options();
out.get_stream() << mk_pair(out.get_formatter()(obj, opts), opts);
return out;
}
io_state_stream const & operator<<(io_state_stream const & out, environment const & env) {
options const & opts = out.get_options();
out.get_stream() << mk_pair(out.get_formatter()(env, opts), opts);
return out;
}
io_state_stream const & operator<<(io_state_stream const & out, kernel_exception const & ex) {
options const & opts = out.get_options();
out.get_stream() << mk_pair(ex.pp(out.get_formatter(), opts), opts);
return out;
}
}