about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-04-20 20:07:50 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-04-20 20:07:50 -0700
commit0ce24b26894eceb38e6b71337db34a542bfc6dd2 (patch)
tree69683bf3b7d51881899ee2e160ab26751a517795
parent2db8bed570552cdf363711d2f49b0adaae63c6b5 (diff)
downloadmu-0ce24b26894eceb38e6b71337db34a542bfc6dd2.tar.gz
2850
-rw-r--r--029tools.cc18
-rw-r--r--030address.cc12
2 files changed, 24 insertions, 6 deletions
diff --git a/029tools.cc b/029tools.cc
index 2a52cb2e..cb24fd85 100644
--- a/029tools.cc
+++ b/029tools.cc
@@ -325,3 +325,21 @@ case _LOG: {
   LOG << out.str() << '\n';
   break;
 }
+
+//: set a variable from within mu code
+//: useful for selectively tracing or printing after some point
+:(before "End Globals")
+bool Foo = false;
+:(before "End Primitive Recipe Declarations")
+_FOO,
+:(before "End Primitive Recipe Numbers")
+put(Recipe_ordinal, "$foo", _FOO);
+:(before "End Primitive Recipe Checks")
+case _FOO: {
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case _FOO: {
+  Foo = true;
+  break;
+}
diff --git a/030address.cc b/030address.cc
index dde4d79a..47431b63 100644
--- a/030address.cc
+++ b/030address.cc
@@ -152,21 +152,21 @@ case _DUMP: {
 //: grab an address, and then dump its value at intervals
 //: useful for tracking down memory corruption (writing to an out-of-bounds address)
 :(before "End Globals")
-int foo = -1;
+int Bar = -1;
 :(before "End Primitive Recipe Declarations")
-_FOO,
+_BAR,
 :(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "$foo", _FOO);
+put(Recipe_ordinal, "$bar", _BAR);
 :(before "End Primitive Recipe Implementations")
-case _FOO: {
+case _BAR: {
   if (current_instruction().ingredients.empty()) {
-    if (foo != -1) cerr << foo << ": " << no_scientific(get_or_insert(Memory, foo)) << '\n';
+    if (Bar != -1) cerr << Bar << ": " << no_scientific(get_or_insert(Memory, Bar)) << '\n';
     else cerr << '\n';
   }
   else {
     reagent tmp = current_instruction().ingredients.at(0);
     canonize(tmp);
-    foo = tmp.value;
+    Bar = tmp.value;
   }
   break;
 }