about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-09 11:03:49 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-09 12:06:04 -0700
commit97a418438d79fed91e8564bea64e31c670e994b2 (patch)
tree0af8bf18c82fda19bda9ebb82346c9e3a7493887
parentf9d069b53ca8733753346262ab10a4ac05d28db2 (diff)
downloadmu-97a418438d79fed91e8564bea64e31c670e994b2.tar.gz
3307
-rw-r--r--030container.cc3
-rw-r--r--033exclusive_container.cc10
-rw-r--r--035lookup.cc2
3 files changed, 10 insertions, 5 deletions
diff --git a/030container.cc b/030container.cc
index a1499a8b..c24d6f7d 100644
--- a/030container.cc
+++ b/030container.cc
@@ -202,6 +202,9 @@ void compute_container_sizes(const type_tree* type, set<type_ordinal>& pending_m
   if (!contains_key(Type, type->value)) return;  // error raised elsewhere
   type_info& info = get(Type, type->value);
   if (info.kind == CONTAINER) {
+    // size of a container is the sum of the sizes of its element
+    // (So it can only contain arrays if they're static and include their
+    // length in the type.)
     container_metadata metadata;
     for (int i = 0; i < SIZE(info.elements); ++i) {
       reagent/*copy*/ element = info.elements.at(i);
diff --git a/033exclusive_container.cc b/033exclusive_container.cc
index 462521dd..ff384de5 100644
--- a/033exclusive_container.cc
+++ b/033exclusive_container.cc
@@ -37,19 +37,19 @@ if (t.kind == EXCLUSIVE_CONTAINER) {
 }
 :(before "End compute_container_sizes Cases")
 if (info.kind == EXCLUSIVE_CONTAINER) {
-  container_metadata metadata;
   // size of an exclusive container is the size of its largest variant
-  // (So like containers, it can't contain arrays.)
-  int size = 0;
+  // (So, like containers, it can only contain arrays if they're static and
+  // include their length in the type.)
+  container_metadata metadata;
   for (int i = 0; i < SIZE(info.elements); ++i) {
     reagent/*copy*/ element = info.elements.at(i);
     // Compute Exclusive Container Size(element)
     compute_container_sizes(element.type, pending_metadata);
     int variant_size = size_of(element);
-    if (variant_size > size) size = variant_size;
+    if (variant_size > metadata.size) metadata.size = variant_size;
   }
   // ...+1 for its tag.
-  metadata.size = size+1;
+  ++metadata.size;
   Container_metadata.push_back(pair<type_tree*, container_metadata>(new type_tree(*type), metadata));
 }
 
diff --git a/035lookup.cc b/035lookup.cc
index 54dee6e3..91314aee 100644
--- a/035lookup.cc
+++ b/035lookup.cc
@@ -151,6 +151,8 @@ if (!canonize_type(rcopy)) return;
 
 :(before "Compute Container Size(element)")
 assert(!has_property(element, "lookup"));
+:(before "Compute Exclusive Container Size(element)")
+assert(!has_property(element, "lookup"));
 
 :(code)
 bool canonize_type(reagent& r) {