about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--010vm.cc15
-rw-r--r--027trace.cc39
-rw-r--r--029debug.cc104
-rw-r--r--031address.cc73
-rw-r--r--999spaces.cc2
-rw-r--r--makefile8
6 files changed, 120 insertions, 121 deletions
diff --git a/010vm.cc b/010vm.cc
index 9e348492..827e673e 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -264,6 +264,21 @@ string slurp_until(istream& in, char delim) {
   return out.str();
 }
 
+bool has_property(reagent x, string name) {
+  for (long long int i = /*skip name:type*/1; i < SIZE(x.properties); ++i) {
+    if (x.properties.at(i).first == name) return true;
+  }
+  return false;
+}
+
+vector<string> property(const reagent& r, const string& name) {
+  for (long long int p = /*skip name:type*/1; p != SIZE(r.properties); ++p) {
+    if (r.properties.at(p).first == name)
+      return r.properties.at(p).second;
+  }
+  return vector<string>();
+}
+
 void dump_memory() {
   for (map<long long int, double>::iterator p = Memory.begin(); p != Memory.end(); ++p) {
     cout << p->first << ": " << p->second << '\n';
diff --git a/027trace.cc b/027trace.cc
index 8056b81b..89d6f2e2 100644
--- a/027trace.cc
+++ b/027trace.cc
@@ -39,3 +39,42 @@ case SHOW_WARNINGS: {
   Hide_warnings = false;
   break;
 }
+
+//: helpers for debugging
+
+:(before "End Primitive Recipe Declarations")
+_START_TRACING,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["$start-tracing"] = _START_TRACING;
+:(before "End Primitive Recipe Implementations")
+case _START_TRACING: {
+  if (current_instruction().ingredients.empty())
+    Trace_stream->dump_layer = "all";
+  else
+    Trace_stream->dump_layer = current_instruction().ingredients.at(0).name;
+//?   cout << Trace_stream << ": " << Trace_stream->dump_layer << '\n'; //? 1
+  break;
+}
+
+:(before "End Primitive Recipe Declarations")
+_STOP_TRACING,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["$stop-tracing"] = _STOP_TRACING;
+:(before "End Primitive Recipe Implementations")
+case _STOP_TRACING: {
+  Trace_stream->dump_layer = "";
+  break;
+}
+
+:(before "End Primitive Recipe Declarations")
+_CLOSE_TRACE,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["$close-trace"] = _CLOSE_TRACE;
+:(before "End Primitive Recipe Implementations")
+case _CLOSE_TRACE: {
+  if (Trace_stream) {
+    delete Trace_stream;
+    Trace_stream = NULL;
+  }
+  break;
+}
diff --git a/029debug.cc b/029debug.cc
index 753375cc..f6d77355 100644
--- a/029debug.cc
+++ b/029debug.cc
@@ -1,5 +1,3 @@
-//: Recipe to look at elements of containers.
-
 :(before "End Primitive Recipe Declarations")
 _PRINT,
 :(before "End Primitive Recipe Numbers")
@@ -26,43 +24,6 @@ case _PRINT: {
 }
 
 :(before "End Primitive Recipe Declarations")
-_START_TRACING,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["$start-tracing"] = _START_TRACING;
-:(before "End Primitive Recipe Implementations")
-case _START_TRACING: {
-  if (current_instruction().ingredients.empty())
-    Trace_stream->dump_layer = "all";
-  else
-    Trace_stream->dump_layer = current_instruction().ingredients.at(0).name;
-//?   cout << Trace_stream << ": " << Trace_stream->dump_layer << '\n'; //? 1
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_STOP_TRACING,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["$stop-tracing"] = _STOP_TRACING;
-:(before "End Primitive Recipe Implementations")
-case _STOP_TRACING: {
-  Trace_stream->dump_layer = "";
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_CLOSE_TRACE,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["$close-trace"] = _CLOSE_TRACE;
-:(before "End Primitive Recipe Implementations")
-case _CLOSE_TRACE: {
-  if (Trace_stream) {
-    delete Trace_stream;
-    Trace_stream = NULL;
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
 _EXIT,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["$exit"] = _EXIT;
@@ -71,68 +32,3 @@ case _EXIT: {
   exit(0);
   break;
 }
-
-:(before "End Primitive Recipe Declarations")
-_DUMP_TRACE,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["$dump-trace"] = _DUMP_TRACE;
-:(before "End Primitive Recipe Implementations")
-case _DUMP_TRACE: {
-  if (ingredients.empty()) {
-    DUMP("");
-  }
-  else {
-    DUMP(current_instruction().ingredients.at(0).name);
-  }
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_CLEAR_TRACE,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["$clear-trace"] = _CLEAR_TRACE;
-:(before "End Primitive Recipe Implementations")
-case _CLEAR_TRACE: {
-  CLEAR_TRACE;
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_DUMP_MEMORY,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["$dump-memory"] = _DUMP_MEMORY;
-:(before "End Primitive Recipe Implementations")
-case _DUMP_MEMORY: {
-  dump_memory();
-  break;
-}
-
-:(before "End Primitive Recipe Declarations")
-_DUMP,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["$dump"] = _DUMP;
-:(before "End Primitive Recipe Implementations")
-case _DUMP: {
-  reagent after_canonize = canonize(current_instruction().ingredients.at(0));
-  cerr << current_recipe_name() << ": " << current_instruction().ingredients.at(0).name << ' ' << current_instruction().ingredients.at(0).value << " => " << after_canonize.value << " => " << Memory[after_canonize.value] << '\n';
-  break;
-}
-
-//: Helper for debugging: grab an address and then dump its value.
-:(before "End Globals")
-long long int foo = -1;
-:(before "End Primitive Recipe Declarations")
-_FOO,
-:(before "End Primitive Recipe Numbers")
-Recipe_ordinal["$foo"] = _FOO;
-:(before "End Primitive Recipe Implementations")
-case _FOO: {
-  if (current_instruction().ingredients.empty()) {
-    if (foo != -1) cerr << foo << ": " << Memory[foo] << '\n';
-    else cerr << '\n';
-  }
-  else {
-    foo = canonize(current_instruction().ingredients.at(0)).value;
-  }
-  break;
-}
diff --git a/031address.cc b/031address.cc
index 9c63ebe3..4df2518c 100644
--- a/031address.cc
+++ b/031address.cc
@@ -98,20 +98,69 @@ recipe main [
 :(after "reagent base = " following "case GET_ADDRESS:")
 base = canonize(base);
 
-//:: helpers
-
-:(code)
-bool has_property(reagent x, string name) {
-  for (long long int i = /*skip name:type*/1; i < SIZE(x.properties); ++i) {
-    if (x.properties.at(i).first == name) return true;
+//:: Helpers for debugging
+
+:(before "End Primitive Recipe Declarations")
+_DUMP_TRACE,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["$dump-trace"] = _DUMP_TRACE;
+:(before "End Primitive Recipe Implementations")
+case _DUMP_TRACE: {
+  if (ingredients.empty()) {
+    DUMP("");
+  }
+  else {
+    DUMP(current_instruction().ingredients.at(0).name);
   }
-  return false;
+  break;
+}
+
+:(before "End Primitive Recipe Declarations")
+_CLEAR_TRACE,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["$clear-trace"] = _CLEAR_TRACE;
+:(before "End Primitive Recipe Implementations")
+case _CLEAR_TRACE: {
+  CLEAR_TRACE;
+  break;
 }
 
-vector<string> property(const reagent& r, const string& name) {
-  for (long long int p = /*skip name:type*/1; p != SIZE(r.properties); ++p) {
-    if (r.properties.at(p).first == name)
-      return r.properties.at(p).second;
+:(before "End Primitive Recipe Declarations")
+_DUMP_MEMORY,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["$dump-memory"] = _DUMP_MEMORY;
+:(before "End Primitive Recipe Implementations")
+case _DUMP_MEMORY: {
+  dump_memory();
+  break;
+}
+
+:(before "End Primitive Recipe Declarations")
+_DUMP,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["$dump"] = _DUMP;
+:(before "End Primitive Recipe Implementations")
+case _DUMP: {
+  reagent after_canonize = canonize(current_instruction().ingredients.at(0));
+  cerr << current_recipe_name() << ": " << current_instruction().ingredients.at(0).name << ' ' << current_instruction().ingredients.at(0).value << " => " << after_canonize.value << " => " << Memory[after_canonize.value] << '\n';
+  break;
+}
+
+//: grab an address, and then dump its value at intervals
+:(before "End Globals")
+long long int foo = -1;
+:(before "End Primitive Recipe Declarations")
+_FOO,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["$foo"] = _FOO;
+:(before "End Primitive Recipe Implementations")
+case _FOO: {
+  if (current_instruction().ingredients.empty()) {
+    if (foo != -1) cerr << foo << ": " << Memory[foo] << '\n';
+    else cerr << '\n';
+  }
+  else {
+    foo = canonize(current_instruction().ingredients.at(0)).value;
   }
-  return vector<string>();
+  break;
 }
diff --git a/999spaces.cc b/999spaces.cc
index f3e3771e..c57bc52e 100644
--- a/999spaces.cc
+++ b/999spaces.cc
@@ -20,7 +20,7 @@ assert(Reserved_for_tests == 1000);
 //: 1-199 - primitives
 assert(MAX_PRIMITIVE_RECIPES < 200);
 //: 200-999 - defined in .mu files as sequences of primitives
-assert(Next_recipe_ordinal < 1000);
+assert(Next_recipe_ordinal == 1000);
 //: 1000 onwards - reserved for tests, cleared between tests
 
 //:: Depths for tracing
diff --git a/makefile b/makefile
index a8c000b5..9569b116 100644
--- a/makefile
+++ b/makefile
@@ -5,12 +5,12 @@ mu_bin: makefile enumerate/enumerate tangle/tangle mu.cc termbox/libtermbox.a
 
 # To see what the program looks like after all layers have been applied, read
 # mu.cc
-mu.cc: 0*.cc
-	./tangle/tangle $$(./enumerate/enumerate --until 9999 |grep -v '.mu$$') > mu.cc
+mu.cc: [0-9]*.cc
+	./tangle/tangle $$(./enumerate/enumerate --until zzz |grep -v '.mu$$') > mu.cc
 	make --no-print-directory autogenerated_lists
 
-core.mu: 0*.mu mu.cc
-	cat $$(./enumerate/enumerate --until 9999 |grep '.mu$$') > core.mu
+core.mu: [0-9]*.mu mu.cc
+	cat $$(./enumerate/enumerate --until zzz |grep '.mu$$') > core.mu
 
 enumerate/enumerate:
 	cd enumerate && make && ./enumerate test