about summary refs log tree commit diff stats
path: root/036call_ingredient.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-13 16:33:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-13 16:34:10 -0700
commit31401373614ec131d415e9c6bcbb83dd78b98b6e (patch)
tree9e9ea6ccffb1438f1f776b16be3ec5626e085b19 /036call_ingredient.cc
parent5497090aa1e708c22cd240913a53dda32bb067aa (diff)
downloadmu-31401373614ec131d415e9c6bcbb83dd78b98b6e.tar.gz
1364 - trace call-stack when switching routines
Drop the #$%# 'encapsulated' stack ADT.
Diffstat (limited to '036call_ingredient.cc')
-rw-r--r--036call_ingredient.cc21
1 files changed, 11 insertions, 10 deletions
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) {