about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cpp/001help.cc3
-rw-r--r--cpp/002test.cc4
-rw-r--r--cpp/003trace.cc12
-rw-r--r--cpp/010vm.cc14
-rw-r--r--cpp/011load.cc2
-rw-r--r--cpp/012transform.cc10
-rw-r--r--cpp/014types.cc2
-rw-r--r--cpp/020run.cc8
-rw-r--r--cpp/027debug.cc2
-rw-r--r--cpp/030container.cc10
-rw-r--r--cpp/031address.cc4
-rw-r--r--cpp/034exclusive_container.cc6
-rw-r--r--cpp/035call.cc6
-rw-r--r--cpp/036call_ingredient.cc4
-rw-r--r--cpp/037call_reply.cc6
-rw-r--r--cpp/038scheduler.cc8
-rw-r--r--cpp/039wait.cc4
-rw-r--r--cpp/040brace.cc16
-rw-r--r--cpp/041name.cc24
-rw-r--r--cpp/042new.cc8
-rw-r--r--cpp/043space.cc2
-rw-r--r--cpp/044space_surround.cc2
-rw-r--r--cpp/045closure_name.cc18
-rw-r--r--cpp/049scenario_helpers.cc16
-rw-r--r--cpp/050scenario.cc2
-rw-r--r--cpp/070display.cc4
-rw-r--r--cpp/072scenario_screen.cc12
27 files changed, 105 insertions, 104 deletions
diff --git a/cpp/001help.cc b/cpp/001help.cc
index 2c48d297..8f2c65d4 100644
--- a/cpp/001help.cc
+++ b/cpp/001help.cc
@@ -41,4 +41,5 @@ using std::cerr;
 #include<cstring>
 #include<string>
 using std::string;
-const size_t NOT_FOUND = string::npos;
+typedef size_t index_t;
+const index_t NOT_FOUND = string::npos;
diff --git a/cpp/002test.cc b/cpp/002test.cc
index 3daa1aed..af56ae97 100644
--- a/cpp/002test.cc
+++ b/cpp/002test.cc
@@ -53,7 +53,7 @@ if (Run_tests) {
   // End Test Run Initialization
   time_t t; time(&t);
   cerr << "C tests: " << ctime(&t);
-  for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) {
+  for (index_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) {
     run_test(i);
   }
   // End Tests
@@ -66,7 +66,7 @@ if (Run_tests) {
 }
 
 :(code)
-void run_test(size_t i) {
+void run_test(index_t i) {
   if (i >= sizeof(Tests)/sizeof(Tests[0])) {
     cerr << "no test " << i << '\n';
     return;
diff --git a/cpp/003trace.cc b/cpp/003trace.cc
index 5a275154..77d51fc4 100644
--- a/cpp/003trace.cc
+++ b/cpp/003trace.cc
@@ -214,7 +214,7 @@ void trace_all(const string& label, const list<string>& in) {
 
 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) {  // missing layer == anywhere, frame, hierarchical layers
   vector<string> expected_lines = split(expected, "");
-  size_t curr_expected_line = 0;
+  index_t curr_expected_line = 0;
   while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
@@ -252,7 +252,7 @@ void parse_layer_frame_contents(const string& orig, string* layer, string* frame
 }
 
 void parse_contents(const string& s, const string& delim, string* prefix, string* contents) {
-  string::size_type pos = s.find(delim);
+  index_t pos = s.find(delim);
   if (pos == NOT_FOUND) {
     *prefix = "";
     *contents = s;
@@ -264,7 +264,7 @@ void parse_contents(const string& s, const string& delim, string* prefix, string
 }
 
 void parse_layer_and_frame(const string& orig, string* layer, string* frame) {
-  size_t last_slash = orig.rfind('/');
+  index_t last_slash = orig.rfind('/');
   if (last_slash == NOT_FOUND
       || orig.find_last_not_of("0123456789") != last_slash) {
     *layer = orig;
@@ -280,7 +280,7 @@ void parse_layer_and_frame(const string& orig, string* layer, string* frame) {
 
 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer, string expected) {  // empty layer == everything, multiple layers, hierarchical layers
   vector<string> expected_lines = split(expected, "");
-  size_t curr_expected_line = 0;
+  index_t curr_expected_line = 0;
   while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
@@ -379,7 +379,7 @@ struct lease_trace_frame {
 
 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer, int frame, string expected) {  // multiple layers, hierarchical layers
   vector<string> expected_lines = split(expected, "");  // hack: doesn't handle newlines in embedded in lines
-  size_t curr_expected_line = 0;
+  index_t curr_expected_line = 0;
   while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
@@ -411,7 +411,7 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer,
 
 vector<string> split(string s, string delim) {
   vector<string> result;
-  string::size_type begin=0, end=s.find(delim);
+  index_t begin=0, end=s.find(delim);
   while (true) {
     if (end == NOT_FOUND) {
       result.push_back(string(s, begin, NOT_FOUND));
diff --git a/cpp/010vm.cc b/cpp/010vm.cc
index b24bcfad..2d1ce2ba 100644
--- a/cpp/010vm.cc
+++ b/cpp/010vm.cc
@@ -57,7 +57,7 @@ struct property {
 
 :(before "End Globals")
 // Locations refer to a common 'memory'. Each location can store a number.
-map<size_t, int> Memory;
+map<index_t, int> Memory;
 :(before "End Setup")
 Memory.clear();
 
@@ -182,7 +182,7 @@ reagent::reagent(string s) :value(0), initialized(false) {
   }
   // structures for the first row of properties
   name = properties[0].first;
-  for (size_t i = 0; i < properties[0].second.size(); ++i) {
+  for (index_t i = 0; i < properties[0].second.size(); ++i) {
     types.push_back(Type_number[properties[0].second[i]]);
   }
   if (name == "_" && types.empty()) {
@@ -199,15 +199,15 @@ reagent::reagent() :value(0), initialized(false) {
 string reagent::to_string() const {
   ostringstream out;
   out << "{name: \"" << name << "\", value: " << value << ", type: ";
-  for (size_t i = 0; i < types.size(); ++i) {
+  for (index_t i = 0; i < types.size(); ++i) {
     out << types[i];
     if (i < types.size()-1) out << "-";
   }
   if (!properties.empty()) {
     out << ", properties: [";
-    for (size_t i = 0; i < properties.size(); ++i) {
+    for (index_t i = 0; i < properties.size(); ++i) {
       out << "\"" << properties[i].first << "\": ";
-      for (size_t j = 0; j < properties[i].second.size(); ++j) {
+      for (index_t j = 0; j < properties[i].second.size(); ++j) {
         out << "\"" << properties[i].second[j] << "\"";
         if (j < properties[i].second.size()-1) out << ":";
       }
@@ -222,13 +222,13 @@ string reagent::to_string() const {
 string instruction::to_string() const {
   if (is_label) return label;
   ostringstream out;
-  for (size_t i = 0; i < products.size(); ++i) {
+  for (index_t i = 0; i < products.size(); ++i) {
     if (i > 0) out << ", ";
     out << products[i].to_string();
   }
   if (!products.empty()) out << " <- ";
   out << name << '/' << operation << ' ';
-  for (size_t i = 0; i < ingredients.size(); ++i) {
+  for (index_t i = 0; i < ingredients.size(); ++i) {
     if (i > 0) out << ", ";
     out << ingredients[i].to_string();
   }
diff --git a/cpp/011load.cc b/cpp/011load.cc
index cee2c493..3f0f8e1e 100644
--- a/cpp/011load.cc
+++ b/cpp/011load.cc
@@ -213,7 +213,7 @@ void show_rest_of_stream(istream& in) {
 :(before "End Globals")
 vector<recipe_number> recently_added_recipes;
 :(before "End Setup")
-for (size_t i = 0; i < recently_added_recipes.size(); ++i) {
+for (index_t i = 0; i < recently_added_recipes.size(); ++i) {
 //?   cout << "AAA clearing " << Recipe[recently_added_recipes[i]].name << '\n'; //? 2
   Recipe_number.erase(Recipe[recently_added_recipes[i]].name);
   Recipe.erase(recently_added_recipes[i]);
diff --git a/cpp/012transform.cc b/cpp/012transform.cc
index 888c7585..2c1e4610 100644
--- a/cpp/012transform.cc
+++ b/cpp/012transform.cc
@@ -4,7 +4,7 @@
 //: deconstructed alternative to conventional compilers.
 
 :(before "End recipe Fields")
-size_t transformed_until;
+index_t transformed_until;
   recipe() :transformed_until(-1) {}
 
 :(before "End Types")
@@ -16,7 +16,7 @@ vector<transform_fn> Transform;
 :(code)
 void transform_all() {
 //?   cout << "AAA transform_all\n"; //? 1
-  for (size_t t = 0; t < Transform.size(); ++t) {
+  for (index_t t = 0; t < Transform.size(); ++t) {
     for (map<recipe_number, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) {
       recipe& r = p->second;
       if (r.steps.empty()) continue;
@@ -33,12 +33,12 @@ void parse_int_reagents() {
   for (map<recipe_number, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) {
     recipe& r = p->second;
     if (r.steps.empty()) continue;
-    for (size_t index = 0; index < r.steps.size(); ++index) {
+    for (index_t index = 0; index < r.steps.size(); ++index) {
       instruction& inst = r.steps[index];
-      for (size_t i = 0; i < inst.ingredients.size(); ++i) {
+      for (index_t i = 0; i < inst.ingredients.size(); ++i) {
         populate_value(inst.ingredients[i]);
       }
-      for (size_t i = 0; i < inst.products.size(); ++i) {
+      for (index_t i = 0; i < inst.products.size(); ++i) {
         populate_value(inst.products[i]);
       }
     }
diff --git a/cpp/014types.cc b/cpp/014types.cc
index ffbd8b63..4ff0f545 100644
--- a/cpp/014types.cc
+++ b/cpp/014types.cc
@@ -74,7 +74,7 @@ else if (command == "exclusive-container") {
 :(before "End Globals")
 vector<type_number> recently_added_types;
 :(before "End Setup")
-for (size_t i = 0; i < recently_added_types.size(); ++i) {
+for (index_t i = 0; i < recently_added_types.size(); ++i) {
 //?   cout << "erasing " << Type[recently_added_types[i]].name << '\n'; //? 1
   Type_number.erase(Type[recently_added_types[i]].name);
   Type.erase(recently_added_types[i]);
diff --git a/cpp/020run.cc b/cpp/020run.cc
index 963fcd78..9fc1f624 100644
--- a/cpp/020run.cc
+++ b/cpp/020run.cc
@@ -32,7 +32,7 @@ recipe main [
 //: Later layers will change this.
 struct routine {
   recipe_number running_recipe;
-  size_t running_step_index;
+  index_t running_step_index;
   routine(recipe_number r) :running_recipe(r), running_step_index(0) {}
   bool completed() const;
 };
@@ -77,7 +77,7 @@ void run_current_routine()
 //: We'll need to override these later as we change the definition of routine.
 //: Important that they return referrences into the routine.
 
-inline size_t& current_step_index() {
+inline index_t& current_step_index() {
   return Current_routine->running_step_index;
 }
 
@@ -153,7 +153,7 @@ vector<int> read_memory(reagent x) {
   }
   int base = x.value;
   size_t size = size_of(x);
-  for (size_t offset = 0; offset < size; ++offset) {
+  for (index_t offset = 0; offset < size; ++offset) {
     int val = Memory[base+offset];
     trace("mem") << "location " << base+offset << " is " << val;
     result.push_back(val);
@@ -166,7 +166,7 @@ void write_memory(reagent x, vector<int> data) {
   int base = x.value;
   if (size_of(x) != data.size())
     raise << "size mismatch in storing to " << x.to_string() << '\n';
-  for (size_t offset = 0; offset < data.size(); ++offset) {
+  for (index_t offset = 0; offset < data.size(); ++offset) {
     trace("mem") << "storing " << data[offset] << " in location " << base+offset;
     Memory[base+offset] = data[offset];
   }
diff --git a/cpp/027debug.cc b/cpp/027debug.cc
index d5de1072..167e896b 100644
--- a/cpp/027debug.cc
+++ b/cpp/027debug.cc
@@ -12,7 +12,7 @@ case _PRINT: {
     break;
   }
   vector<int> result(read_memory(current_instruction().ingredients[0]));
-  for (size_t i = 0; i < result.size(); ++i) {
+  for (index_t i = 0; i < result.size(); ++i) {
     trace("run") << "$print: " << result[i];
     if (i > 0) cout << " ";
     cout << result[i];
diff --git a/cpp/030container.cc b/cpp/030container.cc
index 1741af1b..51d2fdde 100644
--- a/cpp/030container.cc
+++ b/cpp/030container.cc
@@ -53,7 +53,7 @@ type_info t = Type[types[0]];
 if (t.kind == container) {
   // size of a container is the sum of the sizes of its elements
   size_t result = 0;
-  for (size_t i = 0; i < t.elements.size(); ++i) {
+  for (index_t i = 0; i < t.elements.size(); ++i) {
     result += size_of(t.elements[i]);
   }
   return result;
@@ -88,9 +88,9 @@ case GET: {
   assert(Type[base_type].kind == container);
   trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name;
   assert(isa_literal(current_instruction().ingredients[1]));
-  size_t offset = current_instruction().ingredients[1].value;
+  index_t offset = current_instruction().ingredients[1].value;
   int src = base_address;
-  for (size_t i = 0; i < offset; ++i) {
+  for (index_t i = 0; i < offset; ++i) {
     src += size_of(Type[base_type].elements[i]);
   }
   trace("run") << "address to copy is " << src;
@@ -155,9 +155,9 @@ case GET_ADDRESS: {
   assert(Type[base_type].kind == container);
   trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name;
   assert(isa_literal(current_instruction().ingredients[1]));
-  size_t offset = current_instruction().ingredients[1].value;
+  index_t offset = current_instruction().ingredients[1].value;
   int src = base_address;
-  for (size_t i = 0; i < offset; ++i) {
+  for (index_t i = 0; i < offset; ++i) {
     src += size_of(Type[base_type].elements[i]);
   }
   trace("run") << "address to copy is " << src;
diff --git a/cpp/031address.cc b/cpp/031address.cc
index fd9037b1..f84af8d7 100644
--- a/cpp/031address.cc
+++ b/cpp/031address.cc
@@ -115,14 +115,14 @@ base = canonize(base);
 
 :(code)
 bool has_property(reagent x, string name) {
-  for (size_t i = 0; i < x.properties.size(); ++i) {
+  for (index_t i = 0; i < x.properties.size(); ++i) {
     if (x.properties[i].first == name) return true;
   }
   return false;
 }
 
 vector<string> property(const reagent& r, const string& name) {
-  for (size_t p = 0; p != r.properties.size(); ++p) {
+  for (index_t p = 0; p != r.properties.size(); ++p) {
     if (r.properties[p].first == name)
       return r.properties[p].second;
   }
diff --git a/cpp/034exclusive_container.cc b/cpp/034exclusive_container.cc
index 89a4f921..b0edebfa 100644
--- a/cpp/034exclusive_container.cc
+++ b/cpp/034exclusive_container.cc
@@ -45,7 +45,7 @@ if (t.kind == exclusive_container) {
 //?   cout << "point: " << Type_number["point"] << " " << Type[Type_number["point"]].name << " " << Type[Type_number["point"]].size << '\n'; //? 1
 //?   cout << t.name << ' ' << t.size << ' ' << t.elements.size() << '\n'; //? 1
   size_t result = 0;
-  for (size_t i = 0; i < t.size; ++i) {
+  for (index_t i = 0; i < t.size; ++i) {
     size_t tmp = size_of(t.elements[i]);
 //?     cout << i << ": " << t.elements[i][0] << ' ' << tmp << ' ' << result << '\n'; //? 1
     if (tmp > result) result = tmp;
@@ -95,9 +95,9 @@ case MAYBE_CONVERT: {
   assert(Type[base_type].kind == exclusive_container);
   trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name;
   assert(isa_literal(current_instruction().ingredients[1]));
-  size_t tag = current_instruction().ingredients[1].value;
+  index_t tag = current_instruction().ingredients[1].value;
   vector<int> result;
-  if (tag == static_cast<size_t>(Memory[base_address])) {
+  if (tag == static_cast<index_t>(Memory[base_address])) {
     result.push_back(base_address+1);
   }
   else {
diff --git a/cpp/035call.cc b/cpp/035call.cc
index 75c617a6..2cb40af8 100644
--- a/cpp/035call.cc
+++ b/cpp/035call.cc
@@ -33,7 +33,7 @@ recipe f [
 // This requires maintaining a 'stack' of interrupted recipes or 'calls'.
 struct call {
   recipe_number running_recipe;
-  size_t running_step_index;
+  index_t running_step_index;
   // End call Fields
   call(recipe_number r) :running_recipe(r), running_step_index(0) {}
 };
@@ -55,8 +55,8 @@ routine::routine(recipe_number r) {
 
 //:: now update routine's helpers
 
-:(replace{} "inline size_t& current_step_index()")
-inline size_t& current_step_index() {
+:(replace{} "inline index_t& current_step_index()")
+inline index_t& current_step_index() {
   return Current_routine->calls.top().running_step_index;
 }
 :(replace{} "inline const string& current_recipe_name()")
diff --git a/cpp/036call_ingredient.cc b/cpp/036call_ingredient.cc
index d928f286..87abe5ef 100644
--- a/cpp/036call_ingredient.cc
+++ b/cpp/036call_ingredient.cc
@@ -24,7 +24,7 @@ recipe f [
 
 :(before "End call Fields")
 vector<vector<int> > ingredient_atoms;
-size_t next_ingredient_to_process;
+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) {}
 
@@ -105,7 +105,7 @@ INGREDIENT,
 Recipe_number["ingredient"] = INGREDIENT;
 :(before "End Primitive Recipe Implementations")
 case INGREDIENT: {
-  if (static_cast<size_t>(current_instruction().ingredients[0].value) < Current_routine->calls.top().ingredient_atoms.size()) {
+  if (static_cast<index_t>(current_instruction().ingredients[0].value) < Current_routine->calls.top().ingredient_atoms.size()) {
     Current_routine->calls.top().next_ingredient_to_process = current_instruction().ingredients[0].value;
     trace("run") << "product 0 is "
         << Current_routine->calls.top().ingredient_atoms[Current_routine->calls.top().next_ingredient_to_process][0];
diff --git a/cpp/037call_reply.cc b/cpp/037call_reply.cc
index a0dfa2ea..39fb1606 100644
--- a/cpp/037call_reply.cc
+++ b/cpp/037call_reply.cc
@@ -22,7 +22,7 @@ Recipe_number["reply"] = REPLY;
 :(before "End Primitive Recipe Implementations")
 case REPLY: {
   vector<vector<int> > callee_results;
-  for (size_t i = 0; i < current_instruction().ingredients.size(); ++i) {
+  for (index_t i = 0; i < current_instruction().ingredients.size(); ++i) {
     callee_results.push_back(read_memory(current_instruction().ingredients[i]));
   }
   const instruction& reply_inst = current_instruction();  // save pointer into recipe before pop
@@ -30,7 +30,7 @@ case REPLY: {
   assert(!Current_routine->calls.empty());
   const instruction& caller_instruction = current_instruction();
   assert(caller_instruction.products.size() <= callee_results.size());
-  for (size_t i = 0; i < caller_instruction.products.size(); ++i) {
+  for (index_t i = 0; i < caller_instruction.products.size(); ++i) {
     trace("run") << "result " << i << " is " << to_string(callee_results[i]);
     // check that any reply ingredients with /same-as-ingredient connect up
     // the corresponding ingredient and product in the caller.
@@ -86,7 +86,7 @@ string to_string(const vector<int>& in) {
     return out.str();
   }
   out << "[";
-  for (size_t i = 0; i < in.size(); ++i) {
+  for (index_t i = 0; i < in.size(); ++i) {
     if (i > 0) out << ", ";
     out << in[i];
   }
diff --git a/cpp/038scheduler.cc b/cpp/038scheduler.cc
index 6e3f74b8..f750e4a3 100644
--- a/cpp/038scheduler.cc
+++ b/cpp/038scheduler.cc
@@ -37,7 +37,7 @@ state = RUNNING;
 
 :(before "End Globals")
 vector<routine*> Routines;
-size_t Current_routine_index = 0;
+index_t Current_routine_index = 0;
 size_t Scheduling_interval = 500;
 :(before "End Setup")
 Scheduling_interval = 500;
@@ -61,7 +61,7 @@ void run(recipe_number r) {
 
 :(code)
 bool all_routines_done() {
-  for (size_t i = 0; i < Routines.size(); ++i) {
+  for (index_t i = 0; i < Routines.size(); ++i) {
 //?     cout << "routine " << i << ' ' << Routines[i]->state << '\n'; //? 1
     if (Routines[i]->state == RUNNING) {
       return false;
@@ -74,7 +74,7 @@ bool all_routines_done() {
 void skip_to_next_routine() {
   assert(!Routines.empty());
   assert(Current_routine_index < Routines.size());
-  for (size_t i = (Current_routine_index+1)%Routines.size();  i != Current_routine_index;  i = (i+1)%Routines.size()) {
+  for (index_t i = (Current_routine_index+1)%Routines.size();  i != Current_routine_index;  i = (i+1)%Routines.size()) {
     if (Routines[i]->state == RUNNING) {
 //?       cout << "switching to " << i << '\n'; //? 1
       Current_routine_index = i;
@@ -86,7 +86,7 @@ void skip_to_next_routine() {
 }
 
 :(before "End Teardown")
-for (size_t i = 0; i < Routines.size(); ++i)
+for (index_t i = 0; i < Routines.size(); ++i)
   delete Routines[i];
 Routines.clear();
 
diff --git a/cpp/039wait.cc b/cpp/039wait.cc
index b273c737..b9208590 100644
--- a/cpp/039wait.cc
+++ b/cpp/039wait.cc
@@ -23,7 +23,7 @@ recipe f2 [
 WAITING,
 :(before "End routine Fields")
 // only if state == WAITING
-size_t waiting_on_location;
+index_t waiting_on_location;
 int old_value_of_wating_location;
 :(before "End routine Constructor")
 waiting_on_location = old_value_of_wating_location = 0;
@@ -47,7 +47,7 @@ case WAIT_FOR_LOCATION: {
 //: scheduler tweak to get routines out of that state
 
 :(before "End Scheduler State Transitions")
-for (size_t i = 0; i < Routines.size(); ++i) {
+for (index_t i = 0; i < Routines.size(); ++i) {
   if (Routines[i]->state != WAITING) continue;
   if (Memory[Routines[i]->waiting_on_location] != Routines[i]->old_value_of_wating_location) {
     trace("schedule") << "waking up routine\n";
diff --git a/cpp/040brace.cc b/cpp/040brace.cc
index fa9efab5..0b3f6f1b 100644
--- a/cpp/040brace.cc
+++ b/cpp/040brace.cc
@@ -40,21 +40,21 @@ void transform_braces(const recipe_number r) {
 //?   cout << "AAA transform_braces\n"; //? 1
 //?   exit(0); //? 1
   const int OPEN = 0, CLOSE = 1;
-  list<pair<int/*OPEN/CLOSE*/, size_t/*step index*/> > braces;
-  for (size_t index = 0; index < Recipe[r].steps.size(); ++index) {
+  list<pair<int/*OPEN/CLOSE*/, /*step*/index_t> > braces;
+  for (index_t index = 0; index < Recipe[r].steps.size(); ++index) {
     const instruction& inst = Recipe[r].steps[index];
     if (inst.label == "{") {
       trace("brace") << r << ": push (open, " << index << ")";
-      braces.push_back(pair<int,size_t>(OPEN, index));
+      braces.push_back(pair<int,index_t>(OPEN, index));
     }
     if (inst.label == "}") {
       trace("brace") << "push (close, " << index << ")";
-      braces.push_back(pair<int,size_t>(CLOSE, index));
+      braces.push_back(pair<int,index_t>(CLOSE, index));
     }
   }
-  stack<size_t/*step index*/> open_braces;
+  stack</*step*/index_t> open_braces;
   trace("after-brace") << "recipe " << Recipe[r].name;
-  for (size_t index = 0; index < Recipe[r].steps.size(); ++index) {
+  for (index_t index = 0; index < Recipe[r].steps.size(); ++index) {
     instruction& inst = Recipe[r].steps[index];
 //?     cout << "AAA " << inst.name << ": " << inst.operation << '\n'; //? 1
     if (inst.label == "{") open_braces.push(index);
@@ -148,9 +148,9 @@ void transform_braces(const recipe_number r) {
   }
 }
 
-size_t matching_brace(size_t index, const list<pair<int, size_t> >& braces) {
+int matching_brace(index_t index, const list<pair<int, index_t> >& braces) {
   int stacksize = 0;
-  for (list<pair<int, size_t> >::const_iterator p = braces.begin(); p != braces.end(); ++p) {
+  for (list<pair<int, index_t> >::const_iterator p = braces.begin(); p != braces.end(); ++p) {
     if (p->second < index) continue;
     stacksize += (p->first ? 1 : -1);
     if (stacksize == 0) return p->second;
diff --git a/cpp/041name.cc b/cpp/041name.cc
index 23972393..5f37fb6b 100644
--- a/cpp/041name.cc
+++ b/cpp/041name.cc
@@ -21,26 +21,26 @@ recipe main [
   Transform.push_back(transform_names);
 
 :(before "End Globals")
-map<recipe_number, map<string, int> > Name;
+map<recipe_number, map<string, index_t> > Name;
 :(after "Clear Other State For recently_added_recipes")
-for (size_t i = 0; i < recently_added_recipes.size(); ++i) {
+for (index_t i = 0; i < recently_added_recipes.size(); ++i) {
   Name.erase(recently_added_recipes[i]);
 }
 
 :(code)
 void transform_names(const recipe_number r) {
-  map<string, int>& names = Name[r];
+  map<string, index_t>& names = Name[r];
   // store the indices 'used' so far in the map
-  int& curr_idx = names[""];
+  index_t& curr_idx = names[""];
   ++curr_idx;  // avoid using index 0, benign skip in some other cases
 //?   cout << "Recipe " << r << ": " << Recipe[r].name << '\n'; //? 3
 //?   cout << Recipe[r].steps.size() << '\n'; //? 2
-  for (size_t i = 0; i < Recipe[r].steps.size(); ++i) {
+  for (index_t i = 0; i < Recipe[r].steps.size(); ++i) {
 //?     cout << "instruction " << i << '\n'; //? 2
     instruction& inst = Recipe[r].steps[i];
     // Per-recipe Transforms
     // map names to addresses
-    for (size_t in = 0; in < inst.ingredients.size(); ++in) {
+    for (index_t in = 0; in < inst.ingredients.size(); ++in) {
 //?       cout << "ingredients\n"; //? 2
       if (is_raw(inst.ingredients[in])) continue;
 //?       cout << "ingredient " << inst.ingredients[in].name << '\n'; //? 3
@@ -60,7 +60,7 @@ void transform_names(const recipe_number r) {
 //?         cout << "lookup ingredient " << Recipe[r].name << "/" << i << ": " << inst.ingredients[in].to_string() << '\n'; //? 1
       }
     }
-    for (size_t out = 0; out < inst.products.size(); ++out) {
+    for (index_t out = 0; out < inst.products.size(); ++out) {
 //?       cout << "products\n"; //? 1
       if (is_raw(inst.products[out])) continue;
 //?       cout << "product " << out << '/' << inst.products.size() << " " << inst.products[out].name << '\n'; //? 4
@@ -82,16 +82,16 @@ void transform_names(const recipe_number r) {
   }
 }
 
-bool already_transformed(const reagent& r, const map<string, int>& names) {
+bool already_transformed(const reagent& r, const map<string, index_t>& names) {
   return names.find(r.name) != names.end();
 }
 
-size_t lookup_name(const reagent& r, const recipe_number default_recipe) {
+index_t lookup_name(const reagent& r, const recipe_number default_recipe) {
   return Name[default_recipe][r.name];
 }
 
 type_number skip_addresses(const vector<type_number>& types) {
-  for (size_t i = 0; i < types.size(); ++i) {
+  for (index_t i = 0; i < types.size(); ++i) {
     if (types[i] != Type_number["address"]) return types[i];
   }
   raise << "expected a container" << '\n' << die();
@@ -101,7 +101,7 @@ type_number skip_addresses(const vector<type_number>& types) {
 int find_element_name(const type_number t, const string& name) {
   const type_info& container = Type[t];
 //?   cout << "looking for element " << name << " in type " << container.name << " with " << container.element_names.size() << " elements\n"; //? 1
-  for (size_t i = 0; i < container.element_names.size(); ++i) {
+  for (index_t i = 0; i < container.element_names.size(); ++i) {
     if (container.element_names[i] == name) return i;
   }
   raise << "unknown element " << name << " in container " << t << '\n' << die();
@@ -109,7 +109,7 @@ int find_element_name(const type_number t, const string& name) {
 }
 
 bool is_raw(const reagent& r) {
-  for (size_t i = /*skip value+type*/1; i < r.properties.size(); ++i) {
+  for (index_t i = /*skip value+type*/1; i < r.properties.size(); ++i) {
     if (r.properties[i].first == "raw") return true;
   }
   return false;
diff --git a/cpp/042new.cc b/cpp/042new.cc
index e901b2a9..ea05a3ed 100644
--- a/cpp/042new.cc
+++ b/cpp/042new.cc
@@ -12,13 +12,13 @@ recipe main [
 
 :(before "End Globals")
 size_t Reserved_for_tests = 1000;
-size_t Memory_allocated_until = Reserved_for_tests;
+index_t Memory_allocated_until = Reserved_for_tests;
 size_t Initial_memory_per_routine = 100000;
 :(before "End Setup")
 Memory_allocated_until = Reserved_for_tests;
 Initial_memory_per_routine = 100000;
 :(before "End routine Fields")
-size_t alloc, alloc_max;
+index_t alloc, alloc_max;
 :(before "End routine Constructor")
 alloc = Memory_allocated_until;
 Memory_allocated_until += Initial_memory_per_routine;
@@ -78,7 +78,7 @@ case NEW: {
     Current_routine->alloc_max = Memory_allocated_until;
     trace("new") << "routine allocated memory from " << Current_routine->alloc << " to " << Current_routine->alloc_max;
   }
-  const size_t result = Current_routine->alloc;
+  const index_t result = Current_routine->alloc;
   trace("mem") << "new alloc: " << result;
   if (current_instruction().ingredients.size() > 1) {
     // initialize array
@@ -149,7 +149,7 @@ if (current_instruction().ingredients[0].properties[0].second[0] == "literal-str
   // assume that all characters fit in a single location
 //?   cout << "new string literal: " << current_instruction().ingredients[0].name << '\n'; //? 1
   Memory[Current_routine->alloc++] = current_instruction().ingredients[0].name.size();
-  for (size_t i = 0; i < current_instruction().ingredients[0].name.size(); ++i) {
+  for (index_t i = 0; i < current_instruction().ingredients[0].name.size(); ++i) {
     Memory[Current_routine->alloc++] = current_instruction().ingredients[0].name[i];
   }
   // mu strings are not null-terminated in memory
diff --git a/cpp/043space.cc b/cpp/043space.cc
index e94cf023..82b9115a 100644
--- a/cpp/043space.cc
+++ b/cpp/043space.cc
@@ -26,7 +26,7 @@ recipe main [
 +mem: storing 34 in location 8
 
 :(before "End call Fields")
-size_t default_space;
+index_t default_space;
 :(replace "call(recipe_number r) :running_recipe(r)")
 call(recipe_number r) :running_recipe(r), running_step_index(0), next_ingredient_to_process(0), default_space(0) {}
 
diff --git a/cpp/044space_surround.cc b/cpp/044space_surround.cc
index c5a03176..bfc73eee 100644
--- a/cpp/044space_surround.cc
+++ b/cpp/044space_surround.cc
@@ -42,7 +42,7 @@ int space_base(const reagent& x, int space_index, int base) {
 }
 
 int space_index(const reagent& x) {
-  for (size_t i = 0; i < x.properties.size(); ++i) {
+  for (index_t i = 0; i < x.properties.size(); ++i) {
     if (x.properties[i].first == "space")
       return to_int(x.properties[i].second[0]);
   }
diff --git a/cpp/045closure_name.cc b/cpp/045closure_name.cc
index b13b4c21..3f90f308 100644
--- a/cpp/045closure_name.cc
+++ b/cpp/045closure_name.cc
@@ -42,10 +42,10 @@ map<recipe_number, recipe_number> Surrounding_space;
 
 :(code)
 void collect_surrounding_spaces(const recipe_number r) {
-  for (size_t i = 0; i < Recipe[r].steps.size(); ++i) {
+  for (index_t i = 0; i < Recipe[r].steps.size(); ++i) {
     const instruction& inst = Recipe[r].steps[i];
     if (inst.is_label) continue;
-    for (size_t j = 0; j < inst.products.size(); ++j) {
+    for (index_t j = 0; j < inst.products.size(); ++j) {
       if (isa_literal(inst.products[j])) continue;
       if (inst.products[j].name != "0") continue;
       if (inst.products[j].types.size() != 3
@@ -74,8 +74,8 @@ void collect_surrounding_spaces(const recipe_number r) {
 //: Once surrounding spaces are available, transform_names uses them to handle
 //: /space properties.
 
-:(replace{} "size_t lookup_name(const reagent& r, const recipe_number default_recipe)")
-size_t lookup_name(const reagent& x, const recipe_number default_recipe) {
+:(replace{} "index_t lookup_name(const reagent& r, const recipe_number default_recipe)")
+index_t lookup_name(const reagent& x, const recipe_number default_recipe) {
 //?   cout << "AAA " << default_recipe << " " << Recipe[default_recipe].name << '\n'; //? 2
 //?   cout << "AAA " << x.to_string() << '\n'; //? 1
   if (!has_property(x, "space")) {
@@ -94,11 +94,11 @@ size_t lookup_name(const reagent& x, const recipe_number default_recipe) {
 
 // If the recipe we need to lookup this name in doesn't have names done yet,
 // recursively call transform_names on it.
-size_t lookup_name(const reagent& x, const recipe_number r, set<recipe_number>& done, vector<recipe_number>& path) {
+index_t lookup_name(const reagent& x, const recipe_number r, set<recipe_number>& done, vector<recipe_number>& path) {
   if (!Name[r].empty()) return Name[r][x.name];
   if (done.find(r) != done.end()) {
     raise << "can't compute address of " << x.to_string() << " because ";
-    for (size_t i = 1; i < path.size(); ++i) {
+    for (index_t i = 1; i < path.size(); ++i) {
       raise << path[i-1] << " requires computing names of " << path[i] << '\n';
     }
     raise << path[path.size()-1] << " requires computing names of " << r << "..ad infinitum\n" << die();
@@ -111,7 +111,7 @@ size_t lookup_name(const reagent& x, const recipe_number r, set<recipe_number>&
   return Name[r][x.name];
 }
 
-recipe_number lookup_surrounding_recipe(const recipe_number r, size_t n) {
+recipe_number lookup_surrounding_recipe(const recipe_number r, index_t n) {
   if (n == 0) return r;
   if (Surrounding_space.find(r) == Surrounding_space.end()) {
     raise << "don't know surrounding recipe of " << Recipe[r].name << '\n';
@@ -122,8 +122,8 @@ recipe_number lookup_surrounding_recipe(const recipe_number r, size_t n) {
 }
 
 //: weaken use-before-set warnings just a tad
-:(replace{} "bool already_transformed(const reagent& r, const map<string, int>& names)")
-bool already_transformed(const reagent& r, const map<string, int>& names) {
+:(replace{} "bool already_transformed(const reagent& r, const map<string, index_t>& names)")
+bool already_transformed(const reagent& r, const map<string, index_t>& names) {
   if (has_property(r, "space")) {
     vector<string> p = property(r, "space");
     assert(p.size() == 1);
diff --git a/cpp/049scenario_helpers.cc b/cpp/049scenario_helpers.cc
index 8e125a8f..3e1dd25a 100644
--- a/cpp/049scenario_helpers.cc
+++ b/cpp/049scenario_helpers.cc
@@ -77,7 +77,7 @@ case MEMORY_SHOULD_CONTAIN: {
 void check_memory(const string& s) {
   istringstream in(s);
   in >> std::noskipws;
-  set<size_t> locations_checked;
+  set<index_t> locations_checked;
   while (true) {
     skip_whitespace_and_comments(in);
     if (in.eof()) break;
@@ -109,7 +109,7 @@ void check_type(const string& lhs, istream& in) {
     assert(_assign == "<-");
     skip_whitespace_and_comments(in);
     string literal = next_word(in);
-    size_t address = x.value;
+    index_t address = x.value;
     // exclude quoting brackets
     assert(literal[0] == '[');  literal.erase(0, 1);
     assert(literal[literal.size()-1] == ']');  literal.erase(literal.size()-1);
@@ -119,12 +119,12 @@ void check_type(const string& lhs, istream& in) {
   raise << "don't know how to check memory for " << lhs << '\n';
 }
 
-void check_string(size_t address, const string& literal) {
+void check_string(index_t address, const string& literal) {
   trace("run") << "checking string length at " << address;
   if (Memory[address] != static_cast<signed>(literal.size()))
     raise << "expected location " << address << " to contain length " << literal.size() << " of string [" << literal << "] but saw " << Memory[address] << '\n';
   ++address;  // now skip length
-  for (size_t i = 0; i < literal.size(); ++i) {
+  for (index_t i = 0; i < literal.size(); ++i) {
     trace("run") << "checking location " << address+i;
     if (Memory[address+i] != literal[i])
       raise << "expected location " << (address+i) << " to contain " << literal[i] << " but saw " << Memory[address+i] << '\n';
@@ -199,7 +199,7 @@ bool check_trace(const string& expected) {
   Trace_stream->newline();
   vector<pair<string, string> > expected_lines = parse_trace(expected);
   if (expected_lines.empty()) return true;
-  size_t curr_expected_line = 0;
+  index_t curr_expected_line = 0;
   for (vector<pair<string, pair<int, string> > >::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
     if (expected_lines[curr_expected_line].first != p->first) continue;
     if (expected_lines[curr_expected_line].second != p->second.second) continue;
@@ -217,10 +217,10 @@ bool check_trace(const string& expected) {
 vector<pair<string, string> > parse_trace(const string& expected) {
   vector<string> buf = split(expected, "\n");
   vector<pair<string, string> > result;
-  for (size_t i = 0; i < buf.size(); ++i) {
+  for (index_t i = 0; i < buf.size(); ++i) {
     buf[i] = trim(buf[i]);
     if (buf[i].empty()) continue;
-    size_t delim = buf[i].find(": ");
+    index_t delim = buf[i].find(": ");
     result.push_back(pair<string, string>(buf[i].substr(0, delim), buf[i].substr(delim+2)));
   }
   return result;
@@ -293,7 +293,7 @@ case TRACE_SHOULD_NOT_CONTAIN: {
 bool check_trace_missing(const string& in) {
   Trace_stream->newline();
   vector<pair<string, string> > lines = parse_trace(in);
-  for (size_t i = 0; i < lines.size(); ++i) {
+  for (index_t i = 0; i < lines.size(); ++i) {
     if (trace_count(lines[i].first, lines[i].second) != 0) {
       raise << "unexpected [" << lines[i].second << "] in trace layer " << lines[i].first << '\n';
       Passed = false;
diff --git a/cpp/050scenario.cc b/cpp/050scenario.cc
index bc60fcbc..b1baa1a5 100644
--- a/cpp/050scenario.cc
+++ b/cpp/050scenario.cc
@@ -105,7 +105,7 @@ else if (command == "scenario") {
 :(before "End Tests")
 time_t mu_time; time(&mu_time);
 cerr << "\nMu tests: " << ctime(&mu_time);
-for (size_t i = 0; i < Scenarios.size(); ++i) {
+for (index_t i = 0; i < Scenarios.size(); ++i) {
 //?   cerr << Passed << '\n'; //? 1
   run_mu_scenario(Scenarios[i]);
   if (Passed) cerr << ".";
diff --git a/cpp/070display.cc b/cpp/070display.cc
index 6a94cec9..b2bb8d06 100644
--- a/cpp/070display.cc
+++ b/cpp/070display.cc
@@ -3,7 +3,7 @@
 //:: Display management
 
 :(before "End Globals")
-size_t Display_row = 0, Display_column = 0;
+index_t Display_row = 0, Display_column = 0;
 
 :(before "End Primitive Recipe Declarations")
 SWITCH_TO_DISPLAY,
@@ -44,7 +44,7 @@ Recipe_number["clear-line-on-display"] = CLEAR_LINE_ON_DISPLAY;
 :(before "End Primitive Recipe Implementations")
 case CLEAR_LINE_ON_DISPLAY: {
   size_t width = tb_width();
-  for (size_t x = Display_column; x < width; ++x) {
+  for (index_t x = Display_column; x < width; ++x) {
     tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_DEFAULT);
   }
   tb_set_cursor(Display_column, Display_row);
diff --git a/cpp/072scenario_screen.cc b/cpp/072scenario_screen.cc
index a0f9c78e..e928f867 100644
--- a/cpp/072scenario_screen.cc
+++ b/cpp/072scenario_screen.cc
@@ -63,11 +63,11 @@ case SCREEN_SHOULD_CONTAIN: {
 void check_screen(const string& contents) {
   static const int screen_variable = Reserved_for_tests-1;
   assert(!Current_routine->calls.top().default_space);  // not supported
-  size_t screen_location = Memory[screen_variable];
+  index_t screen_location = Memory[screen_variable];
   int data_offset = find_element_name(Type_number["screen"], "data");
   assert(data_offset >= 0);
-  size_t screen_data_location = screen_location+data_offset;  // type: address:array:character
-  size_t screen_data_start = Memory[screen_data_location];  // type: array:character
+  index_t screen_data_location = screen_location+data_offset;  // type: address:array:character
+  index_t screen_data_start = Memory[screen_data_location];  // type: array:character
   int width_offset = find_element_name(Type_number["screen"], "num-columns");
   size_t screen_width = Memory[screen_location+width_offset];
   int height_offset = find_element_name(Type_number["screen"], "num-rows");
@@ -75,11 +75,11 @@ void check_screen(const string& contents) {
   string expected_contents;
   istringstream in(contents);
   in >> std::noskipws;
-  for (size_t row = 0; row < screen_height; ++row) {
+  for (index_t row = 0; row < screen_height; ++row) {
     skip_whitespace_and_comments(in);
     assert(!in.eof());
     assert(in.get() == '.');
-    for (size_t column = 0; column < screen_width; ++column) {
+    for (index_t column = 0; column < screen_width; ++column) {
       assert(!in.eof());
       expected_contents += in.get();
     }
@@ -92,7 +92,7 @@ void check_screen(const string& contents) {
   if (Memory[screen_data_start] > static_cast<signed>(expected_contents.size()))
     raise << "expected contents are larger than screen size " << Memory[screen_data_start] << '\n';
   ++screen_data_start;  // now skip length
-  for (size_t i = 0; i < expected_contents.size(); ++i) {
+  for (index_t i = 0; i < expected_contents.size(); ++i) {
     trace("run") << "checking location " << screen_data_start+i;
     if ((!Memory[screen_data_start+i] && !isspace(expected_contents[i]))  // uninitialized memory => spaces
         || (Memory[screen_data_start+i] && Memory[screen_data_start+i] != expected_contents[i])) {