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:25:06 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-14 22:25:06 -0700
commitf89378d563330260c54496cd80bd4e2550e5988c (patch)
tree62ce332f801c919814e1646f8c926d7fb4ae0c6c /cpp
parente7f76736d22acafa8b7b84df24fde0575d97686c (diff)
downloadmu-f89378d563330260c54496cd80bd4e2550e5988c.tar.gz
922
Diffstat (limited to 'cpp')
-rw-r--r--cpp/012run5
-rw-r--r--cpp/020call16
2 files changed, 10 insertions, 11 deletions
diff --git a/cpp/012run b/cpp/012run
index bd914faa..d2c22e44 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -23,9 +23,7 @@ recipe main [
 struct call {
   recipe_number running_recipe;
   size_t pc;
-  vector<vector<int> > incoming_atoms;
-  size_t next_ingredient_to_process;
-  vector<vector<int> > outgoing_atoms;
+  // End Call Fields
   call(recipe_number r) :running_recipe(r), pc(0), next_ingredient_to_process(0) {}
 };
 typedef stack<call> call_stack;
@@ -63,7 +61,6 @@ void run(routine rr) {
       ++rr.calls.top().pc;
     }
     size_t& pc = rr.calls.top().pc;
-//?     cout << "instruction " << TOP_RECIPE.name << '/' << pc << '\n'; //? 2
     trace("run") << "instruction " << TOP_RECIPE.name << '/' << pc;
     switch (instructions[pc].operation) {
       // Primitive Recipe Implementations.
diff --git a/cpp/020call b/cpp/020call
index 72eb19df..9aef7931 100644
--- a/cpp/020call
+++ b/cpp/020call
@@ -7,18 +7,20 @@ recipe f [
 ]
 +mem: storing in location 3
 
+:(before "End Call Fields")
+vector<vector<int> > ingredient_atoms;
+size_t next_ingredient_to_process;
+
 :(replace{} "End Primitive Recipe Implementations." then "default:")
 default: {
-  // unknown op = try to call a defined recipe
+  // not a primitive; try to look for a matching recipe
   if (Recipe.find(instructions[pc].operation) == Recipe.end()) {
     raise << "undefined operation " << instructions[pc].operation << '\n';
     break;
   }
-//?   cout << "calling " << instructions[pc].operation << '\n'; //? 2
   call callee(instructions[pc].operation);
   for (vector<reagent>::iterator p = instructions[pc].ingredients.begin(); p != instructions[pc].ingredients.end(); ++p) {
-//?     cout << "push back: " << p->to_string() << '\n'; //? 1
-    callee.incoming_atoms.push_back(read_memory(*p));
+    callee.ingredient_atoms.push_back(read_memory(*p));
   }
   rr.calls.push(callee);
   continue;  // not done with caller; don't increment pc
@@ -44,11 +46,11 @@ assert(Next_recipe_number == NEXT_INGREDIENT);
 Next_recipe_number++;
 :(before "End Primitive Recipe Implementations")
 case NEXT_INGREDIENT: {
-  if (rr.calls.top().next_ingredient_to_process < rr.calls.top().incoming_atoms.size()) {
+  if (rr.calls.top().next_ingredient_to_process < rr.calls.top().ingredient_atoms.size()) {
     trace("run") << "product 0 is "
-        << rr.calls.top().incoming_atoms[rr.calls.top().next_ingredient_to_process][0];
+        << rr.calls.top().ingredient_atoms[rr.calls.top().next_ingredient_to_process][0];
     write_memory(instructions[pc].products[0],
-        rr.calls.top().incoming_atoms[rr.calls.top().next_ingredient_to_process]);
+        rr.calls.top().ingredient_atoms[rr.calls.top().next_ingredient_to_process]);
     ++rr.calls.top().next_ingredient_to_process;
   }
   break;