about summary refs log tree commit diff stats
path: root/040brace.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-02-25 00:17:46 -0800
committerKartik Agaram <vc@akkartik.com>2019-02-25 01:50:53 -0800
commitc442a5ad806b6cccbb3ec4c5744b14b0c1f31a01 (patch)
tree318fb1d56e7ee3c750635d3326ad0739dfdacefe /040brace.cc
parente5998f74ac29bb4bf2aedfdd6fbea801ffdb08f6 (diff)
downloadmu-c442a5ad806b6cccbb3ec4c5744b14b0c1f31a01.tar.gz
4987 - support `browse_trace` tool in SubX
I've extracted it into a separate binary, independent of my Mu prototype.

I also cleaned up my tracing layer to be a little nicer. Major improvements:

- Realized that incremental tracing really ought to be the default.
  And to minimize printing traces to screen.

- Finally figured out how to combine layers and call stack frames in a
  single dimension of depth. The answer: optimize for the experience of
  `browse_trace`. Instructions occupy a range of depths based on their call
  stack frame, and minor details of an instruction lie one level deeper
  in each case.

Other than that, I spent some time adjusting levels everywhere to make
`browse_trace` useful.
Diffstat (limited to '040brace.cc')
-rw-r--r--040brace.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/040brace.cc b/040brace.cc
index b3006456..8eead4ab 100644
--- a/040brace.cc
+++ b/040brace.cc
@@ -39,15 +39,15 @@ void transform_braces(const recipe_ordinal r) {
   const bool OPEN = false, CLOSE = true;
   // use signed integer for step index because we'll be doing arithmetic on it
   list<pair<bool/*OPEN/CLOSE*/, /*step*/int> > braces;
-  trace(9991, "transform") << "--- transform braces for recipe " << get(Recipe, r).name << end();
+  trace(101, "transform") << "--- transform braces for recipe " << get(Recipe, r).name << end();
   for (int index = 0;  index < SIZE(get(Recipe, r).steps);  ++index) {
     const instruction& inst = get(Recipe, r).steps.at(index);
     if (inst.label == "{") {
-      trace(9993, "transform") << maybe(get(Recipe, r).name) << "push (open, " << index << ")" << end();
+      trace(103, "transform") << maybe(get(Recipe, r).name) << "push (open, " << index << ")" << end();
       braces.push_back(pair<bool,int>(OPEN, index));
     }
     if (inst.label == "}") {
-      trace(9993, "transform") << "push (close, " << index << ")" << end();
+      trace(103, "transform") << "push (close, " << index << ")" << end();
       braces.push_back(pair<bool,int>(CLOSE, index));
     }
   }
@@ -73,7 +73,7 @@ void transform_braces(const recipe_ordinal r) {
          && inst.name != "break"
          && inst.name != "break-if"
          && inst.name != "break-unless") {
-      trace(9992, "transform") << inst.name << " ..." << end();
+      trace(102, "transform") << inst.name << " ..." << end();
       continue;
     }
     // check for errors
@@ -101,14 +101,14 @@ void transform_braces(const recipe_ordinal r) {
     if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) {
       // conditional branches check arg 1
       if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) {
-        trace(9992, "transform") << inst.name << ' ' << inst.ingredients.at(1).name << ":offset" << end();
+        trace(102, "transform") << inst.name << ' ' << inst.ingredients.at(1).name << ":offset" << end();
         continue;
       }
     }
     else {
       // unconditional branches check arg 0
       if (!inst.ingredients.empty() && is_literal(inst.ingredients.at(0))) {
-        trace(9992, "transform") << "jump " << inst.ingredients.at(0).name << ":offset" << end();
+        trace(102, "transform") << "jump " << inst.ingredients.at(0).name << ":offset" << end();
         continue;
       }
     }
@@ -124,9 +124,9 @@ void transform_braces(const recipe_ordinal r) {
     inst.ingredients.push_back(target);
     // log computed target
     if (inst.name == "jump")
-      trace(9992, "transform") << "jump " << no_scientific(target.value) << ":offset" << end();
+      trace(102, "transform") << "jump " << no_scientific(target.value) << ":offset" << end();
     else
-      trace(9992, "transform") << inst.name << ' ' << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end();
+      trace(102, "transform") << inst.name << ' ' << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end();
   }
 }