about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-06 11:31:37 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-06 11:31:37 -0800
commit12f304a333ecee6326a8111e0d8e1c494ee92087 (patch)
tree5af25c6e5988ae686889f8f462de7d39cc8aad3f
parent795f5244abc9b9f26ff621fd1997db427289d2ba (diff)
downloadmu-12f304a333ecee6326a8111e0d8e1c494ee92087.tar.gz
2378
Now we're starting to run up against the misbehavior introduced by
generics: Type tries to insert rows for type ingredients. That is a
no-no.
-rw-r--r--010vm.cc10
-rw-r--r--011load.cc2
-rw-r--r--030container.cc6
-rw-r--r--033exclusive_container.cc2
-rw-r--r--037recipe.cc2
-rw-r--r--058generic_container.cc2
6 files changed, 12 insertions, 12 deletions
diff --git a/010vm.cc b/010vm.cc
index ef21cedf..5f583a73 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -128,17 +128,17 @@ void setup_types() {
   // Mu Types Initialization
   type_ordinal number = put(Type_ordinal, "number", Next_type_ordinal++);
   put(Type_ordinal, "location", get(Type_ordinal, "number"));  // wildcard type: either a pointer or a scalar
-  get(Type, number).name = "number";
+  get_or_insert(Type, number).name = "number";
   type_ordinal address = put(Type_ordinal, "address", Next_type_ordinal++);
-  get(Type, address).name = "address";
+  get_or_insert(Type, address).name = "address";
   type_ordinal boolean = put(Type_ordinal, "boolean", Next_type_ordinal++);
-  get(Type, boolean).name = "boolean";
+  get_or_insert(Type, boolean).name = "boolean";
   type_ordinal character = put(Type_ordinal, "character", Next_type_ordinal++);
-  get(Type, character).name = "character";
+  get_or_insert(Type, character).name = "character";
   // Array types are a special modifier to any other type. For example,
   // array:number or array:address:boolean.
   type_ordinal array = put(Type_ordinal, "array", Next_type_ordinal++);
-  get(Type, array).name = "array";
+  get_or_insert(Type, array).name = "array";
   // End Mu Types Initialization
 }
 void teardown_types() {
diff --git a/011load.cc b/011load.cc
index d7150335..2c5806e8 100644
--- a/011load.cc
+++ b/011load.cc
@@ -58,7 +58,7 @@ long long int slurp_recipe(istream& in) {
   }
   slurp_body(in, result);
   // End recipe Body(result)
-  get(Recipe, get(Recipe_ordinal, result.name)) = result;
+  get_or_insert(Recipe, get(Recipe_ordinal, result.name)) = result;
   // track added recipes because we may need to undo them in tests; see below
   recently_added_recipes.push_back(get(Recipe_ordinal, result.name));
   return get(Recipe_ordinal, result.name);
diff --git a/030container.cc b/030container.cc
index 05483cf4..2ad0a124 100644
--- a/030container.cc
+++ b/030container.cc
@@ -3,7 +3,7 @@
 :(before "End Mu Types Initialization")
 //: We'll use this container as a running example, with two number elements.
 type_ordinal point = put(Type_ordinal, "point", Next_type_ordinal++);
-get(Type, point).size = 2;
+get_or_insert(Type, point).size = 2;
 get(Type, point).kind = CONTAINER;
 get(Type, point).name = "point";
 get(Type, point).elements.push_back(new type_tree(number));
@@ -38,7 +38,7 @@ recipe main [
 // A more complex container, containing another container as one of its
 // elements.
 type_ordinal point_number = put(Type_ordinal, "point-number", Next_type_ordinal++);
-get(Type, point_number).size = 2;
+get_or_insert(Type, point_number).size = 2;
 get(Type, point_number).kind = CONTAINER;
 get(Type, point_number).name = "point-number";
 get(Type, point_number).elements.push_back(new type_tree(point));
@@ -396,7 +396,7 @@ void insert_container(const string& command, kind_of_type kind, istream& in) {
   }
   trace(9999, "parse") << "type number: " << get(Type_ordinal, name) << end();
   skip_bracket(in, "'container' must begin with '['");
-  type_info& info = get(Type, get(Type_ordinal, name));
+  type_info& info = get_or_insert(Type, get(Type_ordinal, name));
   recently_added_types.push_back(get(Type_ordinal, name));
   info.name = name;
   info.kind = kind;
diff --git a/033exclusive_container.cc b/033exclusive_container.cc
index bf14d9d7..7bf8cca8 100644
--- a/033exclusive_container.cc
+++ b/033exclusive_container.cc
@@ -8,7 +8,7 @@
 //: We'll use this container as a running example, with two number elements.
 {
 type_ordinal tmp = put(Type_ordinal, "number-or-point", Next_type_ordinal++);
-get(Type, tmp).size = 2;
+get_or_insert(Type, tmp).size = 2;
 get(Type, tmp).kind = EXCLUSIVE_CONTAINER;
 get(Type, tmp).name = "number-or-point";
 get(Type, tmp).elements.push_back(new type_tree(number));
diff --git a/037recipe.cc b/037recipe.cc
index 0a4fea4e..42cc2279 100644
--- a/037recipe.cc
+++ b/037recipe.cc
@@ -7,7 +7,7 @@
 put(Type_ordinal, "recipe", 0);
 // 'recipe-ordinal' is the literal that can store recipe literals
 type_ordinal recipe_ordinal = put(Type_ordinal, "recipe-ordinal", Next_type_ordinal++);
-get(Type, recipe_ordinal).name = "recipe-ordinal";
+get_or_insert(Type, recipe_ordinal).name = "recipe-ordinal";
 
 :(before "End Reagent-parsing Exceptions")
 if (r.properties.at(0).second && r.properties.at(0).second->value == "recipe") {
diff --git a/058generic_container.cc b/058generic_container.cc
index 6ba05d5e..843a89c3 100644
--- a/058generic_container.cc
+++ b/058generic_container.cc
@@ -52,7 +52,7 @@ void read_type_ingredients(string& name) {
   name = slurp_until(in, ':');
   if (Type_ordinal.find(name) == Type_ordinal.end() || get(Type_ordinal, name) == 0)
     put(Type_ordinal, name, Next_type_ordinal++);
-  type_info& info = get(Type, get(Type_ordinal, name));
+  type_info& info = get_or_insert(Type, get(Type_ordinal, name));
   long long int next_type_ordinal = START_TYPE_INGREDIENTS;
   while (!in.eof()) {
     string curr = slurp_until(in, ':');