From 6251c2c5a1a3be7f1958dc44da605be5f7d43c64 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 9 Apr 2015 17:57:19 -0700 Subject: 1046 - mu programs can now add to the trace Still just raw strings, but interpolation is coming. --- cpp/.traces/trace | 7 +++++++ cpp/032trace | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 cpp/.traces/trace create mode 100644 cpp/032trace (limited to 'cpp') diff --git a/cpp/.traces/trace b/cpp/.traces/trace new file mode 100644 index 00000000..fb4fd081 --- /dev/null +++ b/cpp/.traces/trace @@ -0,0 +1,7 @@ +parse/0: instruction: 32 +parse/0: ingredient: {name: "foo", value: 0, type: 0, properties: ["foo": "literal-string"]} +parse/0: ingredient: {name: "this is a trace in mu", value: 0, type: 0, properties: ["this is a trace in mu": "literal-string"]} +after-brace/0: recipe main +after-brace/0: trace ... +run/0: instruction main/0 +foo/0: this is a trace in mu diff --git a/cpp/032trace b/cpp/032trace new file mode 100644 index 00000000..3a7b0b0e --- /dev/null +++ b/cpp/032trace @@ -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; +} -- cgit 1.4.1-2-gfad0