about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-14 22:33:42 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-14 22:33:42 -0700
commit0cc8fa9af894f1d8594173f3083acf5acfbebf3a (patch)
tree049453af51cb6ee4d1044b353e077ca470ec8afe /cpp
parent15433557812c1b8153fe3f238311ff808c8389b6 (diff)
downloadmu-0cc8fa9af894f1d8594173f3083acf5acfbebf3a.tar.gz
924
Diffstat (limited to 'cpp')
-rw-r--r--cpp/.traces/next_ingredient6
-rw-r--r--cpp/012run3
-rw-r--r--cpp/020call9
3 files changed, 11 insertions, 7 deletions
diff --git a/cpp/.traces/next_ingredient b/cpp/.traces/next_ingredient
index 8ded3d51..1970698a 100644
--- a/cpp/.traces/next_ingredient
+++ b/cpp/.traces/next_ingredient
@@ -16,3 +16,9 @@ run/0: ingredient 1 is 12
 mem/0: location 12 is 2
 run/0: product 0 is 3
 mem/0: storing in location 13
+run/0: instruction main/1
+run/0: ingredient 0 is 1
+run/0: ingredient 1 is 12
+mem/0: location 12 is 2
+run/0: product 0 is 3
+mem/0: storing in location 13
diff --git a/cpp/012run b/cpp/012run
index 0d102660..eec9b61c 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -51,8 +51,8 @@ void run(recipe_number r) {
 void run(routine rr) {
 // #defines save us the trouble of updating aliases when dependent variables
 // change.
-#define instructions Recipe[rr.calls.top().running_recipe].steps
   while (!rr.calls.empty()) {
+    vector<instruction>& instructions = Recipe[rr.calls.top().running_recipe].steps;
     while (rr.calls.top().pc >= instructions.size()) {
       rr.calls.pop();
       if (rr.calls.empty()) return;
@@ -76,7 +76,6 @@ void run(routine rr) {
     }
     ++pc;
   }
-#undef instructions
 }
 
 :(before "End Main")
diff --git a/cpp/020call b/cpp/020call
index 9aef7931..1b40b1de 100644
--- a/cpp/020call
+++ b/cpp/020call
@@ -85,12 +85,11 @@ case REPLY: {
   }
   rr.calls.pop();
   size_t& caller_pc = rr.calls.top().pc;
-//?   cout << caller_pc << ": " << instructions[caller_pc].products.size() << " <=> " << callee_results.size(); //? 2
-  assert(instructions[caller_pc].products.size() <= callee_results.size());
-  for (size_t i = 0; i < instructions[caller_pc].products.size(); ++i) {
-//?     cout << "AAA " << i << '\n'; //? 1
+  instruction& caller_instruction = Recipe[rr.calls.top().running_recipe].steps[caller_pc];
+  assert(caller_instruction.products.size() <= callee_results.size());
+  for (size_t i = 0; i < caller_instruction.products.size(); ++i) {
     trace("run") << "result " << i << " is " << callee_results[i].size() << "[" << callee_results[i][0] << "...]";
-    write_memory(instructions[caller_pc].products[i], callee_results[i]);
+    write_memory(caller_instruction.products[i], callee_results[i]);
   }
   ++caller_pc;
   break;