2015-11-18 20:59:53 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
2015-11-19 22:58:25 +00:00
|
|
|
#include "library/io_state_stream.h"
|
2015-11-18 20:59:53 +00:00
|
|
|
#include "library/blast/blast.h"
|
|
|
|
#include "library/blast/choice_point.h"
|
|
|
|
#include "library/blast/trace.h"
|
|
|
|
#include "library/blast/options.h"
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
namespace blast {
|
|
|
|
LEAN_THREAD_VALUE(bool, g_trace, false);
|
|
|
|
|
|
|
|
bool is_trace_enabled() {
|
|
|
|
return g_trace;
|
|
|
|
}
|
|
|
|
|
2015-11-19 03:12:29 +00:00
|
|
|
void trace_curr_state() {
|
2015-11-18 20:59:53 +00:00
|
|
|
if (g_trace) {
|
|
|
|
auto out = diagnostic(env(), ios());
|
|
|
|
out << "state [" << curr_state().get_proof_depth() << "], #choice: " << get_num_choice_points() << "\n";
|
|
|
|
display_curr_state();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void trace(char const * msg) {
|
|
|
|
if (g_trace) {
|
|
|
|
ios().get_diagnostic_channel() << msg << "\n\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void trace_action(char const * a) {
|
|
|
|
if (g_trace) {
|
|
|
|
ios().get_diagnostic_channel() << "== action: " << a << " ==>\n\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-19 03:12:29 +00:00
|
|
|
void trace_curr_state_if(action_result r) {
|
2015-11-18 20:59:53 +00:00
|
|
|
if (g_trace && !failed(r))
|
2015-11-19 03:12:29 +00:00
|
|
|
trace_curr_state();
|
2015-11-18 20:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
scope_trace::scope_trace(bool enable):
|
|
|
|
m_old(g_trace) {
|
|
|
|
g_trace = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
scope_trace::scope_trace(options const & o):
|
|
|
|
scope_trace(get_blast_trace(o)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
scope_trace::~scope_trace() {
|
|
|
|
g_trace = m_old;
|
|
|
|
}
|
2015-11-19 22:58:25 +00:00
|
|
|
|
|
|
|
io_state_stream & operator<<(io_state_stream & out, ppb const & e) {
|
|
|
|
expr tmp = curr_state().to_kernel_expr(e.m_expr);
|
|
|
|
out << tmp;
|
|
|
|
return out;
|
|
|
|
}
|
2015-11-18 20:59:53 +00:00
|
|
|
}}
|