about summary refs log tree commit diff stats
path: root/cpp/012run
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-19 17:12:55 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-19 17:12:55 -0800
commitc7c822b27aac56de1e44555c9c2366ac6bbf13f2 (patch)
treecf921bd1677aa8121f6185678bc78a7e7a74e4e1 /cpp/012run
parentd7e112371c97b8d9e7b4ea4451071f8914b9b57f (diff)
downloadmu-c7c822b27aac56de1e44555c9c2366ac6bbf13f2.tar.gz
793
Diffstat (limited to 'cpp/012run')
-rw-r--r--cpp/012run16
1 files changed, 7 insertions, 9 deletions
diff --git a/cpp/012run b/cpp/012run
index 5ba43ee5..acc423a4 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -24,21 +24,19 @@ void run(string form) {
 
 void run(recipe_number r) {
   vector<instruction>& instructions(Recipe[r].steps);
-  int n = 0;
-  vector<instruction>::iterator p;
-  for (n = 0, p = instructions.begin(); p != instructions.end(); ++p, ++n) {
-    trace("run") << "instruction " << n;
-    switch (p->operation) {
+  for (size_t pc = 0; pc < instructions.size(); ++pc) {
+    trace("run") << "instruction " << pc;
+    switch (instructions[pc].operation) {
     // Primitive Recipe Implementations.
     case COPY: {
-      trace("run") << "ingredient 0 is " << p->ingredients[0].name;
-      vector<int> data = read_memory(p->ingredients[0]);
-      write_memory(p->products[0], data);
+      trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name;
+      vector<int> data = read_memory(instructions[pc].ingredients[0]);
+      write_memory(instructions[pc].products[0], data);
       break;
     }
     // End Primitive Recipe Implementations.
     default:
-      raise << "undefined operation " << p->operation;
+      raise << "undefined operation " << instructions[pc].operation;
     }
   }
 }