about summary refs log tree commit diff stats
path: root/cpp/012run
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-13 17:39:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-13 17:42:44 -0700
commit781f24623374b5657cec6e408549d2a74ec94399 (patch)
treea853a822d9058c5f9050a44861fb98974f7c570f /cpp/012run
parente0b570c087a5c0d365a309261c256c97934ce779 (diff)
downloadmu-781f24623374b5657cec6e408549d2a74ec94399.tar.gz
900 - c++: calling 'recipes'
Diffstat (limited to 'cpp/012run')
-rw-r--r--cpp/012run17
1 files changed, 13 insertions, 4 deletions
diff --git a/cpp/012run b/cpp/012run
index 2145f360..1a17c6d2 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -23,6 +23,8 @@ recipe main [
 struct call {
   recipe_number running_recipe;
   size_t pc;
+  vector<int> incoming_atoms;
+  vector<int> outgoing_atoms;
   call(recipe_number r) :running_recipe(r), pc(0) {}
 };
 typedef stack<call> call_stack;
@@ -38,7 +40,7 @@ struct routine {
 
 :(code)
 void run(string form) {
-  recipe_number r = add_recipe(form);
+  recipe_number r = add_recipes(form);
   routine rr;
   rr.calls.push(call(r));
   run(rr);
@@ -57,6 +59,7 @@ void run(routine rr) {
       ++rr.calls.top().pc;
     }
     size_t& pc = rr.calls.top().pc;
+//?     cout << "instruction " << TOP_RECIPE.name << '/' << pc << '\n'; //? 1
     trace("run") << "instruction " << TOP_RECIPE.name << '/' << pc;
     switch (instructions[pc].operation) {
     // Primitive Recipe Implementations.
@@ -67,9 +70,15 @@ void run(routine rr) {
       break;
     }
     // End Primitive Recipe Implementations.
-    default:
-      raise << "undefined operation " << instructions[pc].operation;
-    }
+    default: {
+      if (Recipe.find(instructions[pc].operation) == Recipe.end()) {
+        raise << "undefined operation " << instructions[pc].operation << '\n';
+        break;
+      }
+//?       cout << "calling " << instructions[pc].operation << '\n'; //? 1
+      rr.calls.push(call(instructions[pc].operation));
+      // todo: push incoming atoms
+    }}
     ++pc;
   }
 #undef TOP_RECIPE