about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-02 12:58:24 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-02 12:58:24 -0700
commit16ecf053f05fdc9d9f18720a0836bf725586a421 (patch)
tree010e3a8390ebaa98241c01d00efebb8a0bc15b13
parent7820b45308e1b363244e131d5c57c3cef3ee1506 (diff)
downloadmu-16ecf053f05fdc9d9f18720a0836bf725586a421.tar.gz
1919
Generalize a little layer as a first step to providing traces for other
layers.
-rw-r--r--081run_interactive.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/081run_interactive.cc b/081run_interactive.cc
index 3b0cf32e..e8032100 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -38,7 +38,7 @@ case RUN_INTERACTIVE: {
   bool new_code_pushed_to_stack = run_interactive(ingredients.at(0).at(0));
   if (!new_code_pushed_to_stack) {
     products.at(0).push_back(0);
-    products.at(1).push_back(warnings_from_trace());
+    products.at(1).push_back(trace_contents("warn"));
     products.at(2).push_back(0);
     clean_up_interactive();
     break;  // done with this instruction
@@ -172,7 +172,7 @@ if (current_instruction().operation == RUN_INTERACTIVE && !current_instruction()
   write_memory(current_instruction().products.at(0), result);
   if (SIZE(current_instruction().products) >= 2) {
     vector<double> warnings;
-    warnings.push_back(warnings_from_trace());
+    warnings.push_back(trace_contents("warn"));
     write_memory(current_instruction().products.at(1), warnings);
   }
   if (SIZE(current_instruction().products) >= 3) {
@@ -248,12 +248,12 @@ bool is_mu_string(const reagent& x) {
       && x.types.at(2) == Type_ordinal["character"];
 }
 
-long long int warnings_from_trace() {
+long long int trace_contents(const string& layer) {
   if (!Trace_stream) return 0;
-  if (trace_count("warn") <= 0) return 0;
+  if (trace_count(layer) <= 0) return 0;
   ostringstream out;
   for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
-    if (p->label != "warn") continue;
+    if (p->label != layer) continue;
     out << p->contents;
     if (*--p->contents.end() != '\n') out << '\n';
   }
@@ -290,7 +290,7 @@ case RELOAD: {
   Trace_stream->newline();  // flush trace
   Disable_redefine_warnings = false;
   Hide_warnings = false;
-  products.at(0).push_back(warnings_from_trace());
+  products.at(0).push_back(trace_contents("warn"));
   if (Trace_stream->collect_layer == "warn") {
     delete Trace_stream;
     Trace_stream = NULL;