about summary refs log tree commit diff stats
path: root/cpp/011load
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-07 23:48:22 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-07 23:57:40 -0700
commit9ea7648336251d440a9cd8d91112254e8b38268c (patch)
tree8c2128b06e56b0c7d504076e49c4fcd5821356a2 /cpp/011load
parentf5f4b698533b3d7a5016d1d80c5d59e2c2d8ea6e (diff)
downloadmu-9ea7648336251d440a9cd8d91112254e8b38268c.tar.gz
1030 - better test isolation for break/loop
I've been resetting all recipes after every single test, but the arc
version has shown that this gets slow all too quickly. And the longer I
wait to fix it the harder it gets to fix. Already, boy, were this and
the next couple of commits hard to track down.
Diffstat (limited to 'cpp/011load')
-rw-r--r--cpp/011load11
1 files changed, 9 insertions, 2 deletions
diff --git a/cpp/011load b/cpp/011load
index 8cbf2e53..5657486b 100644
--- a/cpp/011load
+++ b/cpp/011load
@@ -40,8 +40,10 @@ recipe_number add_recipe(istream& in) {
   if (recipe_name.empty())
     raise << "empty recipe name\n";
 //?     raise << "empty recipe name in " << in.str() << '\n';
-  if (Recipe_number.find(recipe_name) == Recipe_number.end())
+  if (Recipe_number.find(recipe_name) == Recipe_number.end()) {
     Recipe_number[recipe_name] = Next_recipe_number++;
+//?     cout << "AAA: " << recipe_name << " is now " << Recipe_number[recipe_name] << '\n'; //? 1
+  }
   recipe_number r = Recipe_number[recipe_name];
 //?   cout << recipe_name << ": adding recipe " << r << '\n'; //? 3
 
@@ -98,8 +100,13 @@ bool next_instruction(istream& in, instruction* curr) {
   }
 
   curr->name = *p;
-  if (Recipe_number.find(*p) == Recipe_number.end())
+  if (Recipe_number.find(*p) == Recipe_number.end()) {
     Recipe_number[*p] = Next_recipe_number++;
+//?     cout << "AAA: " << *p << " is now " << Recipe_number[*p] << '\n'; //? 1
+  }
+  if (Recipe_number[*p] == 0) {
+    raise << "Recipe " << *p << " has number 0, which is reserved for IDLE.\n" << die();
+  }
   curr->operation = Recipe_number[*p];  ++p;
 
   for (; p != words.end(); ++p) {