about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--035call.cc20
-rw-r--r--036call_ingredient.cc21
-rw-r--r--037call_reply.cc2
-rw-r--r--038scheduler.cc14
-rw-r--r--043space.cc8
-rw-r--r--044space_surround.cc2
-rw-r--r--050scenario.cc2
-rw-r--r--072scenario_screen.cc2
8 files changed, 43 insertions, 28 deletions
diff --git a/035call.cc b/035call.cc
index 8682944d..c80331d2 100644
--- a/035call.cc
+++ b/035call.cc
@@ -37,7 +37,7 @@ struct call {
   // End call Fields
   call(recipe_number r) :running_recipe(r), running_step_index(0) {}
 };
-typedef stack<call> call_stack;
+typedef list<call> call_stack;
 
 :(replace{} "struct routine")
 struct routine {
@@ -49,7 +49,7 @@ struct routine {
 };
 :(code)
 routine::routine(recipe_number r) {
-  calls.push(call(r));
+  calls.push_front(call(r));
   // End routine Constructor
 }
 
@@ -57,15 +57,18 @@ routine::routine(recipe_number r) {
 
 :(replace{} "inline index_t& current_step_index()")
 inline index_t& current_step_index() {
-  return Current_routine->calls.top().running_step_index;
+  assert(!Current_routine->calls.empty());
+  return Current_routine->calls.front().running_step_index;
 }
 :(replace{} "inline const string& current_recipe_name()")
 inline const string& current_recipe_name() {
-  return Recipe[Current_routine->calls.top().running_recipe].name;
+  assert(!Current_routine->calls.empty());
+  return Recipe[Current_routine->calls.front().running_recipe].name;
 }
 :(replace{} "inline const instruction& current_instruction()")
 inline const instruction& current_instruction() {
-  return Recipe[Current_routine->calls.top().running_recipe].steps.at(Current_routine->calls.top().running_step_index);
+  assert(!Current_routine->calls.empty());
+  return Recipe[Current_routine->calls.front().running_recipe].steps.at(Current_routine->calls.front().running_step_index);
 }
 
 :(replace{} "default:" following "End Primitive Recipe Implementations")
@@ -75,7 +78,7 @@ default: {
     raise << "undefined operation " << current_instruction().operation << ": " << current_instruction().to_string() << '\n';
     break;
   }
-  Current_routine->calls.push(call(current_instruction().operation));
+  Current_routine->calls.push_front(call(current_instruction().operation));
   continue;  // not done with caller; don't increment current_step_index()
 }
 
@@ -87,14 +90,15 @@ inline bool routine::completed() const {
 }
 
 inline const vector<instruction>& routine::steps() const {
-  return Recipe[calls.top().running_recipe].steps;
+  assert(!calls.empty());
+  return Recipe[calls.front().running_recipe].steps;
 }
 
 :(before "Running One Instruction")
 // when we reach the end of one call, we may reach the end of the one below
 // it, and the one below that, and so on
 while (current_step_index() >= Current_routine->steps().size()) {
-  Current_routine->calls.pop();
+  Current_routine->calls.pop_front();
   if (Current_routine->calls.empty()) return;
   // todo: no results returned warning
   ++current_step_index();
diff --git a/036call_ingredient.cc b/036call_ingredient.cc
index b07c2d3b..a6fbb181 100644
--- a/036call_ingredient.cc
+++ b/036call_ingredient.cc
@@ -28,12 +28,12 @@ index_t next_ingredient_to_process;
 :(replace{} "call(recipe_number r)")
 call(recipe_number r) :running_recipe(r), running_step_index(0), next_ingredient_to_process(0) {}
 
-:(replace "Current_routine->calls.push(call(current_instruction().operation))" following "End Primitive Recipe Implementations")
+:(replace "Current_routine->calls.push_front(call(current_instruction().operation))" following "End Primitive Recipe Implementations")
 call callee(current_instruction().operation);
 for (size_t i = 0; i < ingredients.size(); ++i) {
   callee.ingredient_atoms.push_back(ingredients.at(i));
 }
-Current_routine->calls.push(callee);
+Current_routine->calls.push_front(callee);
 
 :(before "End Primitive Recipe Declarations")
 NEXT_INGREDIENT,
@@ -41,12 +41,13 @@ NEXT_INGREDIENT,
 Recipe_number["next-ingredient"] = NEXT_INGREDIENT;
 :(before "End Primitive Recipe Implementations")
 case NEXT_INGREDIENT: {
-  if (Current_routine->calls.top().next_ingredient_to_process < Current_routine->calls.top().ingredient_atoms.size()) {
+  assert(!Current_routine->calls.empty());
+  if (Current_routine->calls.front().next_ingredient_to_process < Current_routine->calls.front().ingredient_atoms.size()) {
     products.push_back(
-        Current_routine->calls.top().ingredient_atoms.at(Current_routine->calls.top().next_ingredient_to_process));
+        Current_routine->calls.front().ingredient_atoms.at(Current_routine->calls.front().next_ingredient_to_process));
     assert(products.size() == 1);  products.resize(2);  // push a new vector
     products.at(1).push_back(1);
-    ++Current_routine->calls.top().next_ingredient_to_process;
+    ++Current_routine->calls.front().next_ingredient_to_process;
   }
   else {
     products.resize(2);
@@ -77,7 +78,7 @@ REWIND_INGREDIENTS,
 Recipe_number["rewind-ingredients"] = REWIND_INGREDIENTS;
 :(before "End Primitive Recipe Implementations")
 case REWIND_INGREDIENTS: {
-  Current_routine->calls.top().next_ingredient_to_process = 0;
+  Current_routine->calls.front().next_ingredient_to_process = 0;
   break;
 }
 
@@ -100,13 +101,13 @@ Recipe_number["ingredient"] = INGREDIENT;
 case INGREDIENT: {
   assert(isa_literal(current_instruction().ingredients.at(0)));
   assert(ingredients.at(0).size() == 1);  // scalar
-  if (static_cast<index_t>(ingredients.at(0).at(0)) < Current_routine->calls.top().ingredient_atoms.size()) {
-    Current_routine->calls.top().next_ingredient_to_process = ingredients.at(0).at(0);
+  if (static_cast<index_t>(ingredients.at(0).at(0)) < Current_routine->calls.front().ingredient_atoms.size()) {
+    Current_routine->calls.front().next_ingredient_to_process = ingredients.at(0).at(0);
     products.push_back(
-        Current_routine->calls.top().ingredient_atoms.at(Current_routine->calls.top().next_ingredient_to_process));
+        Current_routine->calls.front().ingredient_atoms.at(Current_routine->calls.front().next_ingredient_to_process));
     assert(products.size() == 1);  products.resize(2);  // push a new vector
     products.at(1).push_back(1);
-    ++Current_routine->calls.top().next_ingredient_to_process;
+    ++Current_routine->calls.front().next_ingredient_to_process;
   }
   else {
     if (current_instruction().products.size() > 1) {
diff --git a/037call_reply.cc b/037call_reply.cc
index dc743a0a..e22f243b 100644
--- a/037call_reply.cc
+++ b/037call_reply.cc
@@ -20,7 +20,7 @@ Recipe_number["reply"] = REPLY;
 :(before "End Primitive Recipe Implementations")
 case REPLY: {
   const instruction& reply_inst = current_instruction();  // save pointer into recipe before pop
-  Current_routine->calls.pop();
+  Current_routine->calls.pop_front();
   // just in case 'main' returns a value, drop it for now
   if (Current_routine->calls.empty()) goto stop_running_current_routine;
   const instruction& caller_instruction = current_instruction();
diff --git a/038scheduler.cc b/038scheduler.cc
index 8b42e01c..3d425d50 100644
--- a/038scheduler.cc
+++ b/038scheduler.cc
@@ -53,7 +53,7 @@ void run(recipe_number r) {
 //?     cout << "scheduler: " << Current_routine_index << '\n'; //? 1
     assert(Current_routine);
     assert(Current_routine->state == RUNNING);
-    trace("schedule") << current_recipe_name();
+    trace("schedule") << current_routine_label();
 //?     trace("schedule") << Current_routine_index << ": " << current_recipe_name(); //? 1
 //?     trace("schedule") << Current_routine->id << " " << current_recipe_name(); //? 1
     run_current_routine(Scheduling_interval);
@@ -94,6 +94,16 @@ void skip_to_next_routine() {
 //?   cout << "all done\n"; //? 1
 }
 
+string current_routine_label() {
+  ostringstream result;
+  call_stack calls = Current_routine->calls;
+  for (call_stack::iterator p = calls.begin(); p != calls.end(); ++p) {
+    if (p != calls.begin()) result << '/';
+    result << Recipe[p->running_recipe].name;
+  }
+  return result.str();
+}
+
 :(before "End Teardown")
 for (index_t i = 0; i < Routines.size(); ++i)
   delete Routines.at(i);
@@ -133,7 +143,7 @@ case START_RUNNING: {
   new_routine->parent_index = Current_routine_index;
   // populate ingredients
   for (index_t i = 1; i < current_instruction().ingredients.size(); ++i)
-    new_routine->calls.top().ingredient_atoms.push_back(ingredients.at(i));
+    new_routine->calls.front().ingredient_atoms.push_back(ingredients.at(i));
   Routines.push_back(new_routine);
   products.resize(1);
   products.at(0).push_back(new_routine->id);
diff --git a/043space.cc b/043space.cc
index 88cc5aa3..ec63e19a 100644
--- a/043space.cc
+++ b/043space.cc
@@ -94,7 +94,7 @@ tmp.properties.push_back(pair<string, vector<string> >("raw", vector<string>()))
 
 :(code)
 index_t space_base(const reagent& x) {
-  return Current_routine->calls.top().default_space;
+  return Current_routine->calls.front().default_space;
 }
 
 index_t address(index_t offset, index_t base) {
@@ -110,8 +110,8 @@ index_t address(index_t offset, index_t base) {
 :(after "void write_memory(reagent x, vector<double> data)")
   if (x.name == "default-space") {
     assert(data.size() == 1);
-    Current_routine->calls.top().default_space = data.at(0);
-//?     cout << "AAA " << Current_routine->calls.top().default_space << '\n'; //? 1
+    Current_routine->calls.front().default_space = data.at(0);
+//?     cout << "AAA " << Current_routine->calls.front().default_space << '\n'; //? 1
     return;
   }
 
@@ -125,6 +125,6 @@ recipe main [
 :(after "vector<double> read_memory(reagent x)")
   if (x.name == "default-space") {
     vector<double> result;
-    result.push_back(Current_routine->calls.top().default_space);
+    result.push_back(Current_routine->calls.front().default_space);
     return result;
   }
diff --git a/044space_surround.cc b/044space_surround.cc
index 21a68fdd..b2c04213 100644
--- a/044space_surround.cc
+++ b/044space_surround.cc
@@ -27,7 +27,7 @@ recipe main [
 
 :(replace{} "index_t space_base(const reagent& x)")
 index_t space_base(const reagent& x) {
-  return space_base(x, space_index(x), Current_routine->calls.top().default_space);
+  return space_base(x, space_index(x), Current_routine->calls.front().default_space);
 }
 
 index_t space_base(const reagent& x, index_t space_index, index_t base) {
diff --git a/050scenario.cc b/050scenario.cc
index e91cb3ae..d5b7d546 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -158,7 +158,7 @@ case RUN: {
   // End Predefined Scenario Locals In Run.
   transform_all();
 //?   cout << tmp_recipe.at(0) << ' ' << Recipe_number["main"] << '\n'; //? 1
-  Current_routine->calls.push(call(tmp_recipe.at(0)));
+  Current_routine->calls.push_front(call(tmp_recipe.at(0)));
   continue;  // not done with caller; don't increment current_step_index()
 }
 
diff --git a/072scenario_screen.cc b/072scenario_screen.cc
index f75e7fdc..06566b7d 100644
--- a/072scenario_screen.cc
+++ b/072scenario_screen.cc
@@ -85,7 +85,7 @@ case SCREEN_SHOULD_CONTAIN: {
 
 :(code)
 void check_screen(const string& contents) {
-  assert(!Current_routine->calls.top().default_space);  // not supported
+  assert(!Current_routine->calls.front().default_space);  // not supported
   index_t screen_location = Memory[SCREEN];
   int data_offset = find_element_name(Type_number["screen"], "data");
   assert(data_offset >= 0);