about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-19 02:21:37 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-19 02:25:13 -0800
commitd4dea9bd5f2f80795bd1bf6871c73b863f0525a1 (patch)
treef51097814539b9b9663c9b0b88511278a22d6083 /030container.cc
parent29c7c23c96b616297ac348b12c2cc2578c6ac724 (diff)
downloadmu-d4dea9bd5f2f80795bd1bf6871c73b863f0525a1.tar.gz
2679 - all tests passing again
Still not done, though:

a) There's a few memory leaks to track down, including one in hash from
2668.

b) replace_type_ingredients has gotten *even* uglier. I need to rethink
it.
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/030container.cc b/030container.cc
index a7ae2984..15e6471f 100644
--- a/030container.cc
+++ b/030container.cc
@@ -87,6 +87,10 @@ if (type->value == 0) {
   assert(!type->left && !type->right);
   return 1;
 }
+if (!contains_key(Type, type->value)) {
+  raise_error << "no such type " << type->value << '\n' << end();
+  return 0;
+}
 type_info t = get(Type, type->value);
 if (t.kind == CONTAINER) {
   // size of a container is the sum of the sizes of its elements
@@ -97,8 +101,9 @@ if (t.kind == CONTAINER) {
       raise_error << "container " << t.name << " can't include itself as a member\n" << end();
       return 0;
     }
-    // End size_of(type) Container Cases
-    result += size_of(t.elements.at(i).type);
+    reagent tmp;
+    tmp.type = new type_tree(*type);
+    result += size_of(element_type(tmp, i));
   }
   return result;
 }
@@ -177,7 +182,7 @@ case GET: {
   long long int src = base_address;
   for (long long int i = 0; i < offset; ++i) {
     // End GET field Cases
-    src += size_of(get(Type, base_type).elements.at(i).type);
+    src += size_of(element_type(base, i));
   }
   trace(9998, "run") << "address to copy is " << src << end();
   reagent tmp = element_type(base, offset);
@@ -318,7 +323,7 @@ case GET_ADDRESS: {
   long long int result = base_address;
   for (long long int i = 0; i < offset; ++i) {
     // End GET_ADDRESS field Cases
-    result += size_of(get(Type, base_type).elements.at(i).type);
+    result += size_of(element_type(base, i));
   }
   trace(9998, "run") << "address to copy is " << result << end();
   products.resize(1);