about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-07 15:49:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-07 15:49:40 -0700
commit05d177737c980aad2fcdb54765433e02021ab1e0 (patch)
tree3b146349a2674db7e585f396bfb5eb0062c4ccd9
parent0487a30e7078861ed7de42bdb21b5c71fb9b54a1 (diff)
downloadmu-05d177737c980aad2fcdb54765433e02021ab1e0.tar.gz
1299 - stop using [] in any vector
Useful check:

  $ grep "[^ '\"]\[[^\"]" *.cc \
    |perl -pwe 's/\Wargv\[|\WTests\[|\Wframe\[|\WMemory\[|\WName\[|\WSurrounding_space\[|\WRecipe\[|\WType\[|\WRecipe_number\[|\WType_number\[|\WBefore_fragments\[|\WAfter_fragments\[//g' \
    |perl -pwe 's/\Wargv\[|\WTests\[|\Wframe\[|\WMemory\[|\WName\[|\WSurrounding_space\[|\WRecipe\[|\WType\[|\WRecipe_number\[|\WType_number\[|\WBefore_fragments\[|\WAfter_fragments\[//g' \
    |grep '[^ ]\['
-rw-r--r--003trace.cc28
-rw-r--r--003trace.test.cc20
-rw-r--r--010vm.cc22
-rw-r--r--011load.cc14
-rw-r--r--012transform.cc8
-rw-r--r--013literal_string.cc6
-rw-r--r--014types.cc6
-rw-r--r--020run.cc8
-rw-r--r--025trace.cc8
-rw-r--r--030container.cc2
-rw-r--r--031address.cc14
-rw-r--r--032array.cc2
-rw-r--r--035call.cc2
-rw-r--r--037call_reply.cc4
-rw-r--r--038scheduler.cc16
-rw-r--r--039wait.cc22
-rw-r--r--040brace.cc6
-rw-r--r--041name.cc16
-rw-r--r--045closure_name.cc2
-rw-r--r--050scenario.cc12
-rw-r--r--072scenario_screen.cc4
-rw-r--r--075scenario_keyboard.cc2
22 files changed, 112 insertions, 112 deletions
diff --git a/003trace.cc b/003trace.cc
index 77d51fc4..585ab413 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -215,12 +215,12 @@ 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, "");
   index_t curr_expected_line = 0;
-  while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+  while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
   Trace_stream->newline();
   string layer, frame, contents;
-  parse_layer_frame_contents(expected_lines[curr_expected_line], &layer, &frame, &contents);
+  parse_layer_frame_contents(expected_lines.at(curr_expected_line), &layer, &frame, &contents);
   for (vector<pair<string, pair<int, string> > >::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
     if (!layer.empty() && !prefix_match(layer, p->first))
       continue;
@@ -232,10 +232,10 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expecte
       continue;
 
     ++curr_expected_line;
-    while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+    while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
       ++curr_expected_line;
     if (curr_expected_line == expected_lines.size()) return true;
-    parse_layer_frame_contents(expected_lines[curr_expected_line], &layer, &frame, &contents);
+    parse_layer_frame_contents(expected_lines.at(curr_expected_line), &layer, &frame, &contents);
   }
 
   ++Num_failures;
@@ -281,7 +281,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, "");
   index_t curr_expected_line = 0;
-  while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+  while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
   Trace_stream->newline();
@@ -289,16 +289,16 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer,
   for (vector<pair<string, pair<int, string> > >::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
     if (!layer.empty() && !any_prefix_match(layers, p->first))
       continue;
-    if (p->second.second != expected_lines[curr_expected_line])
+    if (p->second.second != expected_lines.at(curr_expected_line))
       continue;
     ++curr_expected_line;
-    while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+    while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
       ++curr_expected_line;
     if (curr_expected_line == expected_lines.size()) return true;
   }
 
   ++Num_failures;
-  cerr << "\nF " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines[curr_expected_line] << "] in trace:\n";
+  cerr << "\nF " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines.at(curr_expected_line) << "] in trace:\n";
   DUMP(layer);
   Passed = false;
   return false;
@@ -350,7 +350,7 @@ bool trace_doesnt_contain(string layer, string line) {
 
 bool trace_doesnt_contain(string expected) {
   vector<string> tmp = split(expected, ": ");
-  return trace_doesnt_contain(tmp[0], tmp[1]);
+  return trace_doesnt_contain(tmp.at(0), tmp.at(1));
 }
 
 bool trace_doesnt_contain(string layer, int frame, string line) {
@@ -380,7 +380,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
   index_t curr_expected_line = 0;
-  while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+  while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
   Trace_stream->newline();
@@ -390,16 +390,16 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer,
       continue;
     if (p->second.first != frame)
       continue;
-    if (p->second.second != expected_lines[curr_expected_line])
+    if (p->second.second != expected_lines.at(curr_expected_line))
       continue;
     ++curr_expected_line;
-    while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+    while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
       ++curr_expected_line;
     if (curr_expected_line == expected_lines.size()) return true;
   }
 
   ++Num_failures;
-  cerr << "\nF " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines[curr_expected_line] << "] in trace/" << frame << ":\n";
+  cerr << "\nF " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines.at(curr_expected_line) << "] in trace/" << frame << ":\n";
   DUMP(layer);
   Passed = false;
   return false;
@@ -426,7 +426,7 @@ vector<string> split(string s, string delim) {
 
 bool any_prefix_match(const vector<string>& pats, const string& needle) {
   if (pats.empty()) return false;
-  if (*pats[0].rbegin() != '/')
+  if (*pats.at(0).rbegin() != '/')
     // prefix match not requested
     return find(pats.begin(), pats.end(), needle) != pats.end();
   // first pat ends in a '/'; assume all pats do.
diff --git a/003trace.test.cc b/003trace.test.cc
index 0acf8807..db9bda2b 100644
--- a/003trace.test.cc
+++ b/003trace.test.cc
@@ -136,34 +136,34 @@ void test_trace_supports_count2() {
 void test_split_returns_at_least_one_elem() {
   vector<string> result = split("", ",");
   CHECK_EQ(result.size(), 1);
-  CHECK_EQ(result[0], "");
+  CHECK_EQ(result.at(0), "");
 }
 
 void test_split_returns_entire_input_when_no_delim() {
   vector<string> result = split("abc", ",");
   CHECK_EQ(result.size(), 1);
-  CHECK_EQ(result[0], "abc");
+  CHECK_EQ(result.at(0), "abc");
 }
 
 void test_split_works() {
   vector<string> result = split("abc,def", ",");
   CHECK_EQ(result.size(), 2);
-  CHECK_EQ(result[0], "abc");
-  CHECK_EQ(result[1], "def");
+  CHECK_EQ(result.at(0), "abc");
+  CHECK_EQ(result.at(1), "def");
 }
 
 void test_split_works2() {
   vector<string> result = split("abc,def,ghi", ",");
   CHECK_EQ(result.size(), 3);
-  CHECK_EQ(result[0], "abc");
-  CHECK_EQ(result[1], "def");
-  CHECK_EQ(result[2], "ghi");
+  CHECK_EQ(result.at(0), "abc");
+  CHECK_EQ(result.at(1), "def");
+  CHECK_EQ(result.at(2), "ghi");
 }
 
 void test_split_handles_multichar_delim() {
   vector<string> result = split("abc,,def,,ghi", ",,");
   CHECK_EQ(result.size(), 3);
-  CHECK_EQ(result[0], "abc");
-  CHECK_EQ(result[1], "def");
-  CHECK_EQ(result[2], "ghi");
+  CHECK_EQ(result.at(0), "abc");
+  CHECK_EQ(result.at(1), "def");
+  CHECK_EQ(result.at(2), "ghi");
 }
diff --git a/010vm.cc b/010vm.cc
index 38fc582c..3bccbf5e 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -181,13 +181,13 @@ reagent::reagent(string s) :value(0), initialized(false) {
     properties.push_back(pair<string, vector<string> >(name, values));
   }
   // structures for the first row of properties
-  name = properties[0].first;
-  for (index_t i = 0; i < properties[0].second.size(); ++i) {
-    types.push_back(Type_number[properties[0].second[i]]);
+  name = properties.at(0).first;
+  for (index_t i = 0; i < properties.at(0).second.size(); ++i) {
+    types.push_back(Type_number[properties.at(0).second.at(i)]);
   }
   if (name == "_" && types.empty()) {
     types.push_back(0);
-    properties[0].second.push_back("dummy");
+    properties.at(0).second.push_back("dummy");
   }
 }
 reagent::reagent() :value(0), initialized(false) {
@@ -200,16 +200,16 @@ string reagent::to_string() const {
   ostringstream out;
   out << "{name: \"" << name << "\", value: " << value << ", type: ";
   for (index_t i = 0; i < types.size(); ++i) {
-    out << types[i];
+    out << types.at(i);
     if (i < types.size()-1) out << "-";
   }
   if (!properties.empty()) {
     out << ", properties: [";
     for (index_t i = 0; i < properties.size(); ++i) {
-      out << "\"" << properties[i].first << "\": ";
-      for (index_t j = 0; j < properties[i].second.size(); ++j) {
-        out << "\"" << properties[i].second[j] << "\"";
-        if (j < properties[i].second.size()-1) out << ":";
+      out << "\"" << properties.at(i).first << "\": ";
+      for (index_t j = 0; j < properties.at(i).second.size(); ++j) {
+        out << "\"" << properties.at(i).second.at(j) << "\"";
+        if (j < properties.at(i).second.size()-1) out << ":";
       }
       if (i < properties.size()-1) out << ", ";
       else out << "]";
@@ -224,13 +224,13 @@ string instruction::to_string() const {
   ostringstream out;
   for (index_t i = 0; i < products.size(); ++i) {
     if (i > 0) out << ", ";
-    out << products[i].to_string();
+    out << products.at(i).to_string();
   }
   if (!products.empty()) out << " <- ";
   out << name << '/' << operation << ' ';
   for (index_t i = 0; i < ingredients.size(); ++i) {
     if (i > 0) out << ", ";
-    out << ingredients[i].to_string();
+    out << ingredients.at(i).to_string();
   }
   return out.str();
 }
diff --git a/011load.cc b/011load.cc
index ae793b59..e7ff0142 100644
--- a/011load.cc
+++ b/011load.cc
@@ -81,15 +81,15 @@ bool next_instruction(istream& in, instruction* curr) {
   }
   skip_whitespace_and_comments(in);  if (in.eof()) return false;
 
-//?   if (words.size() == 1) cout << words[0] << ' ' << words[0].size() << '\n'; //? 1
-  if (words.size() == 1 && words[0] == "]") {
+//?   if (words.size() == 1) cout << words.at(0) << ' ' << words.at(0).size() << '\n'; //? 1
+  if (words.size() == 1 && words.at(0) == "]") {
 //?     cout << "AAA\n"; //? 1
     return false;  // end of recipe
   }
 
-  if (words.size() == 1 && !isalnum(words[0][0]) && words[0][0] != '$') {
+  if (words.size() == 1 && !isalnum(words.at(0).at(0)) && words.at(0).at(0) != '$') {
     curr->is_label = true;
-    curr->label = words[0];
+    curr->label = words.at(0);
     trace("parse") << "label: " << curr->label;
     return !in.eof();
   }
@@ -203,9 +203,9 @@ void show_rest_of_stream(istream& in) {
 vector<recipe_number> recently_added_recipes;
 :(before "End Setup")
 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]);
+//?   cout << "AAA clearing " << Recipe[recently_added_recipes.at(i)].name << '\n'; //? 2
+  Recipe_number.erase(Recipe[recently_added_recipes.at(i)].name);
+  Recipe.erase(recently_added_recipes.at(i));
 }
 // Clear Other State For recently_added_recipes
 recently_added_recipes.clear();
diff --git a/012transform.cc b/012transform.cc
index 2c1e4610..209eb5d9 100644
--- a/012transform.cc
+++ b/012transform.cc
@@ -21,7 +21,7 @@ void transform_all() {
       recipe& r = p->second;
       if (r.steps.empty()) continue;
       if (r.transformed_until != t-1) continue;
-      (*Transform[t])(/*recipe_number*/p->first);
+      (*Transform.at(t))(/*recipe_number*/p->first);
       r.transformed_until = t;
     }
   }
@@ -34,12 +34,12 @@ void parse_int_reagents() {
     recipe& r = p->second;
     if (r.steps.empty()) continue;
     for (index_t index = 0; index < r.steps.size(); ++index) {
-      instruction& inst = r.steps[index];
+      instruction& inst = r.steps.at(index);
       for (index_t i = 0; i < inst.ingredients.size(); ++i) {
-        populate_value(inst.ingredients[i]);
+        populate_value(inst.ingredients.at(i));
       }
       for (index_t i = 0; i < inst.products.size(); ++i) {
-        populate_value(inst.products[i]);
+        populate_value(inst.products.at(i));
       }
     }
   }
diff --git a/013literal_string.cc b/013literal_string.cc
index 57ac8c3a..9e492fbb 100644
--- a/013literal_string.cc
+++ b/013literal_string.cc
@@ -48,9 +48,9 @@ string slurp_quoted(istream& in) {
 }
 
 :(after "reagent::reagent(string s)")
-//?   cout << s[0] << '\n'; //? 1
-  if (s[0] == '[') {
-    assert(s[s.size()-1] == ']');
+//?   cout << s.at(0) << '\n'; //? 1
+  if (s.at(0) == '[') {
+    assert(*s.rbegin() == ']');
     // delete [] delimiters
     s.erase(0, 1);
     s.erase(s.size()-1, s.size());
diff --git a/014types.cc b/014types.cc
index 4ff0f545..775db323 100644
--- a/014types.cc
+++ b/014types.cc
@@ -75,9 +75,9 @@ else if (command == "exclusive-container") {
 vector<type_number> recently_added_types;
 :(before "End Setup")
 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]);
+//?   cout << "erasing " << Type[recently_added_types.at(i)].name << '\n'; //? 1
+  Type_number.erase(Type[recently_added_types.at(i)].name);
+  Type.erase(recently_added_types.at(i));
 }
 recently_added_types.clear();
 //: lastly, ensure scenarios are consistent by always starting them at the
diff --git a/020run.cc b/020run.cc
index 7dadff6d..0f196b82 100644
--- a/020run.cc
+++ b/020run.cc
@@ -111,7 +111,7 @@ inline const string& current_recipe_name() {
 }
 
 inline const instruction& current_instruction() {
-  return Recipe[Current_routine->running_recipe].steps[Current_routine->running_step_index];
+  return Recipe[Current_routine->running_recipe].steps.at(Current_routine->running_step_index);
 }
 
 inline bool routine::completed() const {
@@ -192,8 +192,8 @@ void write_memory(reagent x, vector<long long int> data) {
   if (size_of(x) != data.size())
     raise << "size mismatch in storing to " << x.to_string() << '\n';
   for (index_t offset = 0; offset < data.size(); ++offset) {
-    trace("mem") << "storing " << data[offset] << " in location " << base+offset;
-    Memory[base+offset] = data[offset];
+    trace("mem") << "storing " << data.at(offset) << " in location " << base+offset;
+    Memory[base+offset] = data.at(offset);
   }
 }
 
@@ -211,7 +211,7 @@ bool is_dummy(const reagent& x) {
 }
 
 bool isa_literal(const reagent& r) {
-  return r.types.size() == 1 && r.types[0] == 0;
+  return r.types.size() == 1 && r.types.at(0) == 0;
 }
 
 :(scenario run_label)
diff --git a/025trace.cc b/025trace.cc
index ae06cb8b..7d295b2f 100644
--- a/025trace.cc
+++ b/025trace.cc
@@ -12,10 +12,10 @@ TRACE,
 Recipe_number["trace"] = TRACE;
 :(before "End Primitive Recipe Implementations")
 case TRACE: {
-  assert(isa_literal(current_instruction().ingredients[0]));
-  string label = current_instruction().ingredients[0].name;
-  assert(isa_literal(current_instruction().ingredients[1]));
-  string message = current_instruction().ingredients[1].name;
+  assert(isa_literal(current_instruction().ingredients.at(0)));
+  string label = current_instruction().ingredients.at(0).name;
+  assert(isa_literal(current_instruction().ingredients.at(1)));
+  string message = current_instruction().ingredients.at(1).name;
   trace(label) << message;
   break;
 }
diff --git a/030container.cc b/030container.cc
index 071e3ea5..edde3395 100644
--- a/030container.cc
+++ b/030container.cc
@@ -123,7 +123,7 @@ case GET: {
   trace("run") << "address to copy is " << src;
   assert(Type[base_type].kind == container);
   assert(Type[base_type].elements.size() > offset);
-  type_number src_type = Type[base_type].elements[offset].at(0);
+  type_number src_type = Type[base_type].elements.at(offset).at(0);
   trace("run") << "its type is " << src_type;
   reagent tmp;
   tmp.set_value(src);
diff --git a/031address.cc b/031address.cc
index f6ad1f47..58d93466 100644
--- a/031address.cc
+++ b/031address.cc
@@ -45,7 +45,7 @@ reagent deref(reagent x) {
 //?   cout << "deref: " << x.to_string() << "\n"; //? 2
   static const type_number ADDRESS = Type_number["address"];
   reagent result;
-  assert(x.types[0] == ADDRESS);
+  assert(x.types.at(0) == ADDRESS);
 
   // compute value
   result.set_value(Memory[x.value]);
@@ -58,12 +58,12 @@ reagent deref(reagent x) {
   index_t i = 0;
   size_t len = x.properties.size();
   for (i = 0; i < len; ++i) {
-    if (x.properties[i].first == "deref") break;
-    result.properties.push_back(x.properties[i]);
+    if (x.properties.at(i).first == "deref") break;
+    result.properties.push_back(x.properties.at(i));
   }
   ++i;  // skip first deref
   for (; i < len; ++i) {
-    result.properties.push_back(x.properties[i]);
+    result.properties.push_back(x.properties.at(i));
   }
   return result;
 }
@@ -116,15 +116,15 @@ base = canonize(base);
 :(code)
 bool has_property(reagent x, string name) {
   for (index_t i = 0; i < x.properties.size(); ++i) {
-    if (x.properties[i].first == name) return true;
+    if (x.properties.at(i).first == name) return true;
   }
   return false;
 }
 
 vector<string> property(const reagent& r, const string& name) {
   for (index_t p = 0; p != r.properties.size(); ++p) {
-    if (r.properties[p].first == name)
-      return r.properties[p].second;
+    if (r.properties.at(p).first == name)
+      return r.properties.at(p).second;
   }
   return vector<string>();
 }
diff --git a/032array.cc b/032array.cc
index 69641aaa..67b03293 100644
--- a/032array.cc
+++ b/032array.cc
@@ -104,7 +104,7 @@ case INDEX: {
 //?   trace("run") << "ingredient 1 after canonize: " << offset.to_string(); //? 1
   vector<long long int> offset_val(read_memory(offset));
   vector<type_number> element_type = array_element(base.types);
-//?   trace("run") << "offset: " << offset_val[0]; //? 1
+//?   trace("run") << "offset: " << offset_val.at(0); //? 1
 //?   trace("run") << "size of elements: " << size_of(element_type); //? 1
   index_t src = base_address + 1 + offset_val.at(0)*size_of(element_type);
   trace("run") << "address to copy is " << src;
diff --git a/035call.cc b/035call.cc
index c88a16db..57c1513d 100644
--- a/035call.cc
+++ b/035call.cc
@@ -65,7 +65,7 @@ inline const string& current_recipe_name() {
 }
 :(replace{} "inline const instruction& current_instruction()")
 inline const instruction& current_instruction() {
-  return Recipe[Current_routine->calls.top().running_recipe].steps[Current_routine->calls.top().running_step_index];
+  return Recipe[Current_routine->calls.top().running_recipe].steps.at(Current_routine->calls.top().running_step_index);
 }
 
 :(replace{} "default:" following "End Primitive Recipe Implementations")
diff --git a/037call_reply.cc b/037call_reply.cc
index da1cf1f1..a13c88e5 100644
--- a/037call_reply.cc
+++ b/037call_reply.cc
@@ -33,8 +33,8 @@ case REPLY: {
       vector<string> tmp = property(reply_inst.ingredients.at(i), "same-as-ingredient");
       assert(tmp.size() == 1);
       long long int ingredient_index = to_int(tmp.at(0));
-      if (caller_instruction.products.at(i).value != caller_instruction.ingredients[ingredient_index].value)
-        raise << "'same-as-ingredient' result " << caller_instruction.products.at(i).value << " must be location " << caller_instruction.ingredients[ingredient_index].value << '\n';
+      if (caller_instruction.products.at(i).value != caller_instruction.ingredients.at(ingredient_index).value)
+        raise << "'same-as-ingredient' result " << caller_instruction.products.at(i).value << " must be location " << caller_instruction.ingredients.at(ingredient_index).value << '\n';
     }
   }
   // refresh instruction_counter to caller's step_index
diff --git a/038scheduler.cc b/038scheduler.cc
index ebc690a0..b8c51e40 100644
--- a/038scheduler.cc
+++ b/038scheduler.cc
@@ -44,7 +44,7 @@ Scheduling_interval = 500;
 :(replace{} "void run(recipe_number r)")
 void run(recipe_number r) {
   Routines.push_back(new routine(r));
-  Current_routine_index = 0, Current_routine = Routines[0];
+  Current_routine_index = 0, Current_routine = Routines.at(0);
   while (!all_routines_done()) {
     skip_to_next_routine();
 //?     cout << "scheduler: " << Current_routine_index << '\n'; //? 1
@@ -62,8 +62,8 @@ void run(recipe_number r) {
 :(code)
 bool all_routines_done() {
   for (index_t i = 0; i < Routines.size(); ++i) {
-//?     cout << "routine " << i << ' ' << Routines[i]->state << '\n'; //? 1
-    if (Routines[i]->state == RUNNING) {
+//?     cout << "routine " << i << ' ' << Routines.at(i)->state << '\n'; //? 1
+    if (Routines.at(i)->state == RUNNING) {
       return false;
     }
   }
@@ -75,10 +75,10 @@ void skip_to_next_routine() {
   assert(!Routines.empty());
   assert(Current_routine_index < 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) {
+    if (Routines.at(i)->state == RUNNING) {
 //?       cout << "switching to " << i << '\n'; //? 1
       Current_routine_index = i;
-      Current_routine = Routines[i];
+      Current_routine = Routines.at(i);
       return;
     }
   }
@@ -87,7 +87,7 @@ void skip_to_next_routine() {
 
 :(before "End Teardown")
 for (index_t i = 0; i < Routines.size(); ++i)
-  delete Routines[i];
+  delete Routines.at(i);
 Routines.clear();
 
 //:: To schedule new routines to run, call 'start-running'.
@@ -231,8 +231,8 @@ case ROUTINE_STATE: {
   index_t id = ingredients.at(0).at(0);
   long long int result = -1;
   for (index_t i = 0; i < Routines.size(); ++i) {
-    if (Routines[i]->id == id) {
-      result = Routines[i]->state;
+    if (Routines.at(i)->id == id) {
+      result = Routines.at(i)->state;
       break;
     }
   }
diff --git a/039wait.cc b/039wait.cc
index 2055a5b0..8d9086d6 100644
--- a/039wait.cc
+++ b/039wait.cc
@@ -48,12 +48,12 @@ case WAIT_FOR_LOCATION: {
 
 :(before "End Scheduler State Transitions")
 for (index_t i = 0; i < Routines.size(); ++i) {
-  if (Routines[i]->state != WAITING) continue;
-  if (Memory[Routines[i]->waiting_on_location] &&
-      Memory[Routines[i]->waiting_on_location] != Routines[i]->old_value_of_wating_location) {
+  if (Routines.at(i)->state != WAITING) continue;
+  if (Memory[Routines.at(i)->waiting_on_location] &&
+      Memory[Routines.at(i)->waiting_on_location] != Routines.at(i)->old_value_of_wating_location) {
     trace("schedule") << "waking up routine\n";
-    Routines[i]->state = RUNNING;
-    Routines[i]->waiting_on_location = Routines[i]->old_value_of_wating_location = 0;
+    Routines.at(i)->state = RUNNING;
+    Routines.at(i)->waiting_on_location = Routines.at(i)->old_value_of_wating_location = 0;
   }
 }
 
@@ -94,15 +94,15 @@ case WAIT_FOR_ROUTINE: {
 
 :(before "End Scheduler State Transitions")
 for (index_t i = 0; i < Routines.size(); ++i) {
-  if (Routines[i]->state != WAITING) continue;
-  if (!Routines[i]->waiting_on_routine) continue;
-  index_t id = Routines[i]->waiting_on_routine;
+  if (Routines.at(i)->state != WAITING) continue;
+  if (!Routines.at(i)->waiting_on_routine) continue;
+  index_t id = Routines.at(i)->waiting_on_routine;
   assert(id != i);
   for (index_t j = 0; j < Routines.size(); ++j) {
-    if (Routines[j]->id == id && Routines[j]->state != WAITING) {
+    if (Routines.at(j)->id == id && Routines.at(j)->state != WAITING) {
       trace("schedule") << "waking up routine\n";
-      Routines[i]->state = RUNNING;
-      Routines[i]->waiting_on_routine = 0;
+      Routines.at(i)->state = RUNNING;
+      Routines.at(i)->waiting_on_routine = 0;
     }
   }
 }
diff --git a/040brace.cc b/040brace.cc
index 90826e2e..fa8255ef 100644
--- a/040brace.cc
+++ b/040brace.cc
@@ -42,7 +42,7 @@ void transform_braces(const recipe_number r) {
   const int OPEN = 0, CLOSE = 1;
   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];
+    const instruction& inst = Recipe[r].steps.at(index);
     if (inst.label == "{") {
       trace("brace") << r << ": push (open, " << index << ")";
       braces.push_back(pair<int,index_t>(OPEN, index));
@@ -55,7 +55,7 @@ void transform_braces(const recipe_number r) {
   stack</*step*/index_t> open_braces;
   trace("after-brace") << "recipe " << Recipe[r].name;
   for (index_t index = 0; index < Recipe[r].steps.size(); ++index) {
-    instruction& inst = Recipe[r].steps[index];
+    instruction& inst = Recipe[r].steps.at(index);
 //?     cout << "AAA " << inst.name << ": " << inst.operation << '\n'; //? 1
     if (inst.label == "{") open_braces.push(index);
     else if (inst.label == "}") open_braces.pop();
@@ -74,7 +74,7 @@ void transform_braces(const recipe_number r) {
         inst.ingredients.push_back(ing);
         trace("after-brace") << "jump " << ing.value << ":offset";
         trace("after-brace") << index << ": " << ing.to_string();
-        trace("after-brace") << index << ": " << Recipe[r].steps[index].ingredients.at(0).to_string();
+        trace("after-brace") << index << ": " << Recipe[r].steps.at(index).ingredients.at(0).to_string();
       }
     }
     else if (inst.operation == Recipe_number["break"]) {
diff --git a/041name.cc b/041name.cc
index d73e5139..984e1ac1 100644
--- a/041name.cc
+++ b/041name.cc
@@ -24,7 +24,7 @@ recipe main [
 map<recipe_number, map<string, index_t> > Name;
 :(after "Clear Other State For recently_added_recipes")
 for (index_t i = 0; i < recently_added_recipes.size(); ++i) {
-  Name.erase(recently_added_recipes[i]);
+  Name.erase(recently_added_recipes.at(i));
 }
 
 :(code)
@@ -37,7 +37,7 @@ void transform_names(const recipe_number r) {
 //?   cout << Recipe[r].steps.size() << '\n'; //? 2
   for (index_t i = 0; i < Recipe[r].steps.size(); ++i) {
 //?     cout << "instruction " << i << '\n'; //? 2
-    instruction& inst = Recipe[r].steps[i];
+    instruction& inst = Recipe[r].steps.at(i);
     // Per-recipe Transforms
     // map names to addresses
     for (index_t in = 0; in < inst.ingredients.size(); ++in) {
@@ -50,7 +50,7 @@ void transform_names(const recipe_number r) {
       if (inst.ingredients.at(in).types.empty())
         raise << "missing type in " << inst.to_string() << '\n';
       assert(!inst.ingredients.at(in).types.empty());
-      if (inst.ingredients.at(in).types[0]  // not a literal
+      if (inst.ingredients.at(in).types.at(0)  // not a literal
           && !inst.ingredients.at(in).initialized
           && !is_number(inst.ingredients.at(in).name)) {
         if (!already_transformed(inst.ingredients.at(in), names)) {
@@ -64,10 +64,10 @@ void transform_names(const recipe_number r) {
 //?       cout << "products\n"; //? 1
       if (is_raw(inst.products.at(out))) continue;
 //?       cout << "product " << out << '/' << inst.products.size() << " " << inst.products.at(out).name << '\n'; //? 4
-//?       cout << inst.products.at(out).types[0] << '\n'; //? 1
+//?       cout << inst.products.at(out).types.at(0) << '\n'; //? 1
       if (inst.products.at(out).name == "default-space")
         inst.products.at(out).initialized = true;
-      if (inst.products.at(out).types[0]  // not a literal
+      if (inst.products.at(out).types.at(0)  // not a literal
           && !inst.products.at(out).initialized
           && !is_number(inst.products.at(out).name)) {
         if (names.find(inst.products.at(out).name) == names.end()) {
@@ -92,7 +92,7 @@ index_t lookup_name(const reagent& r, const recipe_number default_recipe) {
 
 type_number skip_addresses(const vector<type_number>& types) {
   for (index_t i = 0; i < types.size(); ++i) {
-    if (types[i] != Type_number["address"]) return types[i];
+    if (types.at(i) != Type_number["address"]) return types.at(i);
   }
   raise << "expected a container" << '\n' << die();
   return -1;
@@ -102,7 +102,7 @@ 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 (index_t i = 0; i < container.element_names.size(); ++i) {
-    if (container.element_names[i] == name) return i;
+    if (container.element_names.at(i) == name) return i;
   }
   raise << "unknown element " << name << " in container " << t << '\n' << die();
   return -1;
@@ -110,7 +110,7 @@ int find_element_name(const type_number t, const string& name) {
 
 bool is_raw(const reagent& r) {
   for (index_t i = /*skip value+type*/1; i < r.properties.size(); ++i) {
-    if (r.properties[i].first == "raw") return true;
+    if (r.properties.at(i).first == "raw") return true;
   }
   return false;
 }
diff --git a/045closure_name.cc b/045closure_name.cc
index 6273e880..83fbeede 100644
--- a/045closure_name.cc
+++ b/045closure_name.cc
@@ -43,7 +43,7 @@ map<recipe_number, recipe_number> Surrounding_space;
 :(code)
 void collect_surrounding_spaces(const recipe_number r) {
   for (index_t i = 0; i < Recipe[r].steps.size(); ++i) {
-    const instruction& inst = Recipe[r].steps[i];
+    const instruction& inst = Recipe[r].steps.at(i);
     if (inst.is_label) continue;
     for (index_t j = 0; j < inst.products.size(); ++j) {
       if (isa_literal(inst.products.at(j))) continue;
diff --git a/050scenario.cc b/050scenario.cc
index 6c048dfd..9a88d278 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -230,8 +230,8 @@ void check_type(const string& lhs, istream& in) {
     string literal = next_word(in);
     index_t address = x.value;
     // exclude quoting brackets
-    assert(literal.at(0) == '[');  literal.erase(0, 1);
-    assert(literal[literal.size()-1] == ']');  literal.erase(literal.size()-1);
+    assert(*literal.begin() == '[');  literal.erase(literal.begin());
+    assert(*--literal.end() == ']');  literal.erase(--literal.end());
     check_string(address, literal);
     return;
   }
@@ -323,15 +323,15 @@ bool check_trace(const string& expected) {
   if (expected_lines.empty()) return true;
   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;
+    if (expected_lines.at(curr_expected_line).first != p->first) continue;
+    if (expected_lines.at(curr_expected_line).second != p->second.second) continue;
     // match
     ++curr_expected_line;
     if (curr_expected_line == expected_lines.size()) return true;
   }
 
-  raise << "missing [" << expected_lines[curr_expected_line].second << "] "
-        << "in trace layer " << expected_lines[curr_expected_line].first << '\n';
+  raise << "missing [" << expected_lines.at(curr_expected_line).second << "] "
+        << "in trace layer " << expected_lines.at(curr_expected_line).first << '\n';
   Passed = false;
   return false;
 }
diff --git a/072scenario_screen.cc b/072scenario_screen.cc
index e2a70726..18121424 100644
--- a/072scenario_screen.cc
+++ b/072scenario_screen.cc
@@ -49,14 +49,14 @@ assert(Next_predefined_global_for_scenarios < Reserved_for_tests);
 // There's a restriction on the number of variables 'run' can use, so that
 // it can avoid colliding with the dynamic allocator in case it doesn't
 // initialize a default-space.
-assert(Name[tmp_recipe[0]][""] < Max_variables_in_scenarios);
+assert(Name[tmp_recipe.at(0)][""] < Max_variables_in_scenarios);
 
 :(before "End Globals")
 // Scenario Globals.
 const size_t SCREEN = Next_predefined_global_for_scenarios++;
 // End Scenario Globals.
 :(before "End Predefined Scenario Locals In Run")
-Name[tmp_recipe[0]]["screen"] = SCREEN;
+Name[tmp_recipe.at(0)]["screen"] = SCREEN;
 
 :(before "End Rewrite Instruction(curr)")
 // rewrite `assume-screen width, height` to
diff --git a/075scenario_keyboard.cc b/075scenario_keyboard.cc
index 388df7c7..0de6a2eb 100644
--- a/075scenario_keyboard.cc
+++ b/075scenario_keyboard.cc
@@ -28,7 +28,7 @@ scenario keyboard-in-scenario [
 :(before "End Scenario Globals")
 const size_t KEYBOARD = Next_predefined_global_for_scenarios++;
 :(before "End Predefined Scenario Locals In Run")
-Name[tmp_recipe[0]]["keyboard"] = KEYBOARD;
+Name[tmp_recipe.at(0)]["keyboard"] = KEYBOARD;
 
 :(before "End Rewrite Instruction(curr)")
 // rewrite `assume-keyboard string` to