about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-14 17:10:33 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-14 17:10:33 -0700
commit9cf71627174aebeabe9149df454785b3ef6b92d8 (patch)
treee6026a10113b1563960d84da06b84e51b5e9e5f9
parent4f5bc1e198b075c8fbec455a5614deb2c13a812e (diff)
downloadmu-9cf71627174aebeabe9149df454785b3ef6b92d8.tar.gz
910 - c++: call layer more coherent
-rw-r--r--cpp/012run19
-rw-r--r--cpp/020call17
2 files changed, 20 insertions, 16 deletions
diff --git a/cpp/012run b/cpp/012run
index 1a95f408..46a90b7f 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -72,22 +72,9 @@ void run(routine rr) {
     }
     // End Primitive Recipe Implementations.
     default: {
-      // unknown op = try to call a defined recipe
-      // TODO: this should be later, in the same layer as next_ingredient
-//?       cout << "non primitive op: " << instructions[pc].operation << '\n'; //? 1
-      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));
-      }
-      rr.calls.push(callee);
-      continue;  // not done with caller; don't increment pc
-    }}
+      cout << "non primitive op: " << instructions[pc].operation << '\n';
+    }
+    }
     ++pc;
   }
 #undef TOP_RECIPE
diff --git a/cpp/020call b/cpp/020call
index 18c54e63..1a7c4b89 100644
--- a/cpp/020call
+++ b/cpp/020call
@@ -7,6 +7,23 @@ recipe f [
 ]
 +mem: storing in location 3
 
+:(replace{} "End Primitive Recipe Implementations." then "default:")
+default: {
+  // unknown op = try to call a defined 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));
+  }
+  rr.calls.push(callee);
+  continue;  // not done with caller; don't increment pc
+}
+
 :(scenario "next_ingredient")
 recipe main [
   f 2:literal