about summary refs log tree commit diff stats
path: root/cpp/020call
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/020call
parente7f76736d22acafa8b7b84df24fde0575d97686c (diff)
downloadmu-f89378d563330260c54496cd80bd4e2550e5988c.tar.gz
922
Diffstat (limited to 'cpp/020call')
-rw-r--r--cpp/020call16
1 files changed, 9 insertions, 7 deletions
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;