about summary refs log tree commit diff stats
path: root/cpp/042trace
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-17 09:56:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-17 09:56:04 -0700
commit9da1b126cc017e14035b94c4615d211e5bc4bb21 (patch)
treea69baf5f6b75be08e68003a725d33cd478659b56 /cpp/042trace
parentc8087de8d99a4c3c4264eb89e4d0b35a4fb2c816 (diff)
downloadmu-9da1b126cc017e14035b94c4615d211e5bc4bb21.tar.gz
1072
Diffstat (limited to 'cpp/042trace')
-rw-r--r--cpp/042trace21
1 files changed, 21 insertions, 0 deletions
diff --git a/cpp/042trace b/cpp/042trace
new file mode 100644
index 00000000..3a7b0b0e
--- /dev/null
+++ b/cpp/042trace
@@ -0,0 +1,21 @@
+:(scenario "trace")
+recipe main [
+  trace [foo], [this is a trace in mu]
+]
++foo: this is a trace in mu
+
+:(before "End Globals")
+const int TRACE = 32;
+:(before "End Primitive Recipe Numbers")
+Recipe_number["trace"] = TRACE;
+assert(Next_recipe_number == TRACE);
+Next_recipe_number++;
+:(before "End Primitive Recipe Implementations")
+case TRACE: {
+  assert(isa_literal(instructions[pc].ingredients[0]));
+  string label = instructions[pc].ingredients[0].name;
+  assert(isa_literal(instructions[pc].ingredients[1]));
+  string message = instructions[pc].ingredients[1].name;
+  trace(label) << message;
+  break;
+}