about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cpp/.traces/run25
-rw-r--r--cpp/.traces/run_multiple47
-rw-r--r--cpp/049scenario_helpers.cc44
3 files changed, 116 insertions, 0 deletions
diff --git a/cpp/.traces/run b/cpp/.traces/run
new file mode 100644
index 00000000..6d7b4d41
--- /dev/null
+++ b/cpp/.traces/run
@@ -0,0 +1,25 @@
+parse/0: instruction: run
+parse/0:   ingredient: {name: "
+    1:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    1:integer <- copy 13:literal
+  ": "literal-string"]}
+after-brace/0: recipe main
+after-brace/0: run ...
+new/0: routine allocated memory from 1000 to 101000
+schedule/0: main
+run/0: instruction main/0
+run/0: run {name: "
+    1:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    1:integer <- copy 13:literal
+  ": "literal-string"]}
+parse/0: instruction: copy
+parse/0:   ingredient: {name: "13", value: 0, type: 0, properties: ["13": "literal"]}
+parse/0:   product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
+after-brace/0: recipe tmp0
+after-brace/0: copy ...
+run/0: instruction tmp0/0
+run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- copy {name: "13", value: 13, type: 0, properties: ["13": "literal"]}
+run/0: ingredient 0 is 13
+mem/0: storing 13 in location 1
diff --git a/cpp/.traces/run_multiple b/cpp/.traces/run_multiple
new file mode 100644
index 00000000..9da9ba0a
--- /dev/null
+++ b/cpp/.traces/run_multiple
@@ -0,0 +1,47 @@
+parse/0: instruction: run
+parse/0:   ingredient: {name: "
+    1:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    1:integer <- copy 13:literal
+  ": "literal-string"]}
+parse/0: instruction: run
+parse/0:   ingredient: {name: "
+    2:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    2:integer <- copy 13:literal
+  ": "literal-string"]}
+after-brace/0: recipe main
+after-brace/0: run ...
+after-brace/0: run ...
+new/0: routine allocated memory from 1000 to 101000
+schedule/0: main
+run/0: instruction main/0
+run/0: run {name: "
+    1:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    1:integer <- copy 13:literal
+  ": "literal-string"]}
+parse/0: instruction: copy
+parse/0:   ingredient: {name: "13", value: 0, type: 0, properties: ["13": "literal"]}
+parse/0:   product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
+after-brace/0: recipe tmp0
+after-brace/0: copy ...
+run/0: instruction tmp0/0
+run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- copy {name: "13", value: 13, type: 0, properties: ["13": "literal"]}
+run/0: ingredient 0 is 13
+mem/0: storing 13 in location 1
+run/0: instruction main/1
+run/0: run {name: "
+    2:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    2:integer <- copy 13:literal
+  ": "literal-string"]}
+parse/0: instruction: copy
+parse/0:   ingredient: {name: "13", value: 0, type: 0, properties: ["13": "literal"]}
+parse/0:   product: {name: "2", value: 0, type: 1, properties: ["2": "integer"]}
+after-brace/0: recipe tmp1
+after-brace/0: copy ...
+run/0: instruction tmp1/0
+run/0: {name: "2", value: 2, type: 1, properties: ["2": "integer"]} <- copy {name: "13", value: 13, type: 0, properties: ["13": "literal"]}
+run/0: ingredient 0 is 13
+mem/0: storing 13 in location 2
diff --git a/cpp/049scenario_helpers.cc b/cpp/049scenario_helpers.cc
new file mode 100644
index 00000000..8234c21f
--- /dev/null
+++ b/cpp/049scenario_helpers.cc
@@ -0,0 +1,44 @@
+//: Some pseudo-primitives to support writing tests in mu.
+//: When we throw out the C layer these will require more work.
+
+:(scenario run)
+#? % Trace_stream->dump_layer = "all";
+recipe main [
+  run [
+    1:integer <- copy 13:literal
+  ]
+]
++mem: storing 13 in location 1
+
+:(before "End Globals")
+size_t Num_temporary_recipes = 0;
+:(before "End Setup")
+Num_temporary_recipes = 0;
+
+:(before "End Primitive Recipe Declarations")
+RUN,
+:(before "End Primitive Recipe Numbers")
+Recipe_number["run"] = RUN;
+:(before "End Primitive Recipe Implementations")
+case RUN: {
+//?   cout << "recipe " << current_instruction().ingredients[0].name << '\n'; //? 1
+  ostringstream tmp;
+  tmp << "recipe tmp" << Num_temporary_recipes++ << " [ " << current_instruction().ingredients[0].name << " ]";
+  vector<recipe_number> tmp_recipe = load(tmp.str());
+  transform_all();
+//?   cout << tmp_recipe[0] << ' ' << Recipe_number["main"] << '\n'; //? 1
+  Current_routine->calls.push(call(tmp_recipe[0]));
+  continue;  // not done with caller; don't increment current_step_index()
+}
+
+:(scenario run_multiple)
+recipe main [
+  run [
+    1:integer <- copy 13:literal
+  ]
+  run [
+    2:integer <- copy 13:literal
+  ]
+]
++mem: storing 13 in location 1
++mem: storing 13 in location 2