about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cpp/020run7
-rw-r--r--cpp/035call7
-rw-r--r--cpp/038scheduler4
3 files changed, 10 insertions, 8 deletions
diff --git a/cpp/020run b/cpp/020run
index d5a161d1..e4ffafc7 100644
--- a/cpp/020run
+++ b/cpp/020run
@@ -34,6 +34,7 @@ struct routine {
   recipe_number running_recipe;
   size_t running_at;
   routine(recipe_number r) :running_recipe(r), running_at(0) {}
+  bool completed() const;
 };
 
 :(before "End Globals")
@@ -48,7 +49,7 @@ void run(recipe_number r) {
 
 void run_current_routine()
 {  // curly on a separate line, because later layers will modify header
-  while (!done())  // later layers will modify condition
+  while (!Current_routine->completed())  // later layers will modify condition
   {
     // Running One Instruction.
     vector<instruction>& instructions = steps();
@@ -95,8 +96,8 @@ inline vector<instruction>& steps() {
   return Recipe[Current_routine->running_recipe].steps;
 }
 
-inline bool done() {
-  return running_at() >= steps().size();
+inline bool routine::completed() const {
+  return running_step_index >= Recipe[running_recipe].steps.size();
 }
 
 :(before "End Commandline Parsing")
diff --git a/cpp/035call b/cpp/035call
index 28c570dd..c7052e62 100644
--- a/cpp/035call
+++ b/cpp/035call
@@ -44,6 +44,7 @@ struct routine {
   call_stack calls;
   // End routine Fields
   routine(recipe_number r);
+  bool completed() const;
 };
 :(code)
   routine::routine(recipe_number r) {
@@ -78,9 +79,9 @@ default: {
 
 //:: finally, we need to fix the termination conditions for the run loop
 
-:(replace{} "inline bool done()")
-inline bool done() {
-  return Current_routine->calls.empty();
+:(replace{} "inline bool routine::completed() const")
+inline bool routine::completed() const {
+  return calls.empty();
 }
 
 :(before "Running One Instruction")
diff --git a/cpp/038scheduler b/cpp/038scheduler
index 5ca6cbdc..08be7821 100644
--- a/cpp/038scheduler
+++ b/cpp/038scheduler
@@ -14,8 +14,8 @@ void run(recipe_number r) {
 }
 :(replace "void run_current_routine()")
 void run_current_routine(size_t time_slice)
-:(replace "while (!done())" following "void run_current_routine(size_t time_slice)")
+:(replace "while (!Current_routine->completed())" following "void run_current_routine(size_t time_slice)")
 size_t ninstrs = 0;
-while (!done() && ninstrs < time_slice)
+while (!Current_routine->completed() && ninstrs < time_slice)
 :(after "Running One Instruction")
 ninstrs++;