about summary refs log tree commit diff stats
path: root/081run_interactive.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-21 23:38:21 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-21 23:38:21 -0700
commit4efc0ff3168f9ff6e80b2fa4b3302baac4035abb (patch)
tree83843682dfa136f08f7a3603902d39f8b76c10b5 /081run_interactive.cc
parentefc5c081304f7da0d8ffcc863f14922845d04295 (diff)
downloadmu-4efc0ff3168f9ff6e80b2fa4b3302baac4035abb.tar.gz
1826 - edit: start carefully showing all errors
Eventually we might be able to get rid of die entirely.

This is just a preliminary stab at a random error. In the process I ran
into two issues that have impeded debugging before:

a) Naming conflicts within scenarios are a real no-no. I need to warn on
them, but the rules are getting complicated:
  Always print warnings on redefine
  But not in interactive mode
  Or in scenarios checking warning behavior
  Unless the scenario recipe itself is overridden

b) Now that we've added collect_layers and a long time can go between
traces, debugging is a minefield because trace lines don't print to
screen immediately after they're created. Need to do something about
that. Maybe explicitly trigger collection by tracing '\n' or something.

These are the next two items on my todo list.
Diffstat (limited to '081run_interactive.cc')
-rw-r--r--081run_interactive.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/081run_interactive.cc b/081run_interactive.cc
index 5258b2c0..f7d049ff 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -188,6 +188,7 @@ if (must_clean_up_interactive) clean_up_interactive();
 if (must_clean_up_interactive) clean_up_interactive();
 :(code)
 void clean_up_interactive() {
+  Trace_stream->newline();  // flush trace
   Hide_warnings = false;
   Running_interactive = false;
   // hack: assume collect_layer isn't set anywhere else
@@ -267,13 +268,23 @@ Recipe_ordinal["reload"] = RELOAD;
 :(before "End Primitive Recipe Implementations")
 case RELOAD: {
   assert(scalar(ingredients.at(0)));
+  if (!Trace_stream) {
+    Trace_file = "";  // if there wasn't already a stream we don't want to save it
+    Trace_stream = new trace_stream;
+    Trace_stream->collect_layer = "warn";
+  }
   Loading_interactive = true;
   Hide_warnings = true;
   load(read_mu_string(ingredients.at(0).at(0)));
   transform_all();
+  Trace_stream->newline();  // flush trace
   Hide_warnings = false;
   Loading_interactive = false;
   products.resize(1);
   products.at(0).push_back(warnings_from_trace());
+  if (Trace_stream->collect_layer == "warn") {
+    delete Trace_stream;
+    Trace_stream = NULL;
+  }
   break;
 }