about summary refs log tree commit diff stats
path: root/036refcount.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-05-17 18:32:41 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-05-17 18:32:41 -0700
commit0be82cde0a56c48cd8b358b4cb81cb9490ce3012 (patch)
treea1696603e0d2f823a09e2162dd0d7386633a4d45 /036refcount.cc
parent882989243a31354b3b82df021847bb332b483fd2 (diff)
downloadmu-0be82cde0a56c48cd8b358b4cb81cb9490ce3012.tar.gz
2972 - abandon recursive containers
Diffstat (limited to '036refcount.cc')
-rw-r--r--036refcount.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/036refcount.cc b/036refcount.cc
index a7da07b8..ad87b089 100644
--- a/036refcount.cc
+++ b/036refcount.cc
@@ -278,7 +278,7 @@ bool append_addresses(int base_offset, const type_tree* type, vector<address_ele
   const type_info& info = get(Type, type->value);
   if (type->name == "address") {
     assert(type->right && type->right->name != "array");  // array types can't be handled without a full reagent and its value
-    out.push_back(address_element_info(base_offset, new type_tree(*type)));
+    out.push_back(address_element_info(base_offset, new type_tree(*type->right)));
     return true;
   }
   if (info.kind == PRIMITIVE) return true;
@@ -288,7 +288,7 @@ bool append_addresses(int base_offset, const type_tree* type, vector<address_ele
     // Compute Container Address Offset(element)
     if (is_mu_address(element)) {
       trace(9993, "transform") << "address at offset " << curr_offset << end();
-      out.push_back(address_element_info(curr_offset, new type_tree(*element.type)));
+      out.push_back(address_element_info(curr_offset, new type_tree(*element.type->right)));
       ++curr_offset;
     }
     else if (is_mu_container(element)) {
@@ -346,13 +346,13 @@ void update_container_refcounts(const reagent& x, const vector<double>& data) {
   const container_metadata& metadata = get(Container_metadata, x.type);
   for (int i = 0; i < SIZE(metadata.address); ++i) {
     const address_element_info& info = metadata.address.at(i);
-    update_refcounts(get_or_insert(Memory, x.value + info.offset), data.at(info.offset), info.payload_type, size_of(info.payload_type));
+    update_refcounts(get_or_insert(Memory, x.value + info.offset), data.at(info.offset), info.payload_type, size_of(info.payload_type)+/*refcount*/1);
   }
   for (map<pair<int, int>, vector<address_element_info> >::const_iterator p = metadata.maybe_address.begin(); p != metadata.maybe_address.end(); ++p) {
     if (data.at(p->first.first) != p->first.second) continue;
     for (int i = 0; i < SIZE(p->second); ++i) {
       const address_element_info& info = p->second.at(i);
-      update_refcounts(get_or_insert(Memory, x.value + info.offset), data.at(info.offset), info.payload_type, size_of(info.payload_type));
+      update_refcounts(get_or_insert(Memory, x.value + info.offset), data.at(info.offset), info.payload_type, size_of(info.payload_type)+/*refcount*/1);
     }
   }
 }
@@ -515,13 +515,19 @@ def main [
 
 :(code)
 bool is_mu_container(const reagent& r) {
-  if (r.type->value == 0) return false;
-  type_info& info = get(Type, r.type->value);
+  return is_mu_container(r.type);
+}
+bool is_mu_container(const type_tree* type) {
+  if (type->value == 0) return false;
+  type_info& info = get(Type, type->value);
   return info.kind == CONTAINER;
 }
 
 bool is_mu_exclusive_container(const reagent& r) {
-  if (r.type->value == 0) return false;
-  type_info& info = get(Type, r.type->value);
+  return is_mu_exclusive_container(r.type);
+}
+bool is_mu_exclusive_container(const type_tree* type) {
+  if (type->value == 0) return false;
+  type_info& info = get(Type, type->value);
   return info.kind == EXCLUSIVE_CONTAINER;
 }