about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-05-17 10:44:12 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-05-17 10:44:12 -0700
commitd8603e814cc993233a694ead4787a51ae32467c2 (patch)
treef067259fd1e05270448e20aa75dbdeeee32193c1
parent8e1c4783692824238b2d55f8e00bd996261d521c (diff)
downloadmu-d8603e814cc993233a694ead4787a51ae32467c2.tar.gz
2966
-rw-r--r--030container.cc2
-rw-r--r--035lookup.cc7
-rw-r--r--036refcount.cc9
3 files changed, 10 insertions, 8 deletions
diff --git a/030container.cc b/030container.cc
index f45a8932..3135d5f2 100644
--- a/030container.cc
+++ b/030container.cc
@@ -94,7 +94,7 @@ def main [
 
 //: Global data structure for container metadata.
 //: Can't put this in type_info because later layers will add support for more
-//: complex type trees where metadata depends not just on the root of the type tree.
+//: complex type trees where metadata depends on *combinations* of types.
 
 :(after "Types")
 struct container_metadata {
diff --git a/035lookup.cc b/035lookup.cc
index 1f1c988f..98490d29 100644
--- a/035lookup.cc
+++ b/035lookup.cc
@@ -89,10 +89,15 @@ void lookup_memory(reagent& x) {
     raise << maybe(current_recipe_name()) << "tried to /lookup 0\n" << end();
     return;
   }
+  lookup_memory_core(x);
+}
+
+void lookup_memory_core(reagent& x) {
+  if (x.value == 0) return;
   trace(9999, "mem") << "location " << x.value << " is " << no_scientific(get_or_insert(Memory, x.value)) << end();
   x.set_value(get_or_insert(Memory, x.value));
   drop_from_type(x, "address");
-  if (x.value != 0) {
+  if (x.value) {
     trace(9999, "mem") << "skipping refcount at " << x.value << end();
     x.set_value(x.value+1);  // skip refcount
   }
diff --git a/036refcount.cc b/036refcount.cc
index bb32ada5..8c593943 100644
--- a/036refcount.cc
+++ b/036refcount.cc
@@ -19,13 +19,12 @@ def main [
 
 :(before "End write_memory(x) Special-cases")
 if (is_mu_address(x)) {
-  // compute old address of x, as well as new address we want to write in
   assert(scalar(data));
   assert(x.value);
+  assert(!x.metadata.size);
   update_refcounts(get_or_insert(Memory, x.value), data.at(0), payload_size(x));
 }
 :(code)
-// variant of write_memory for addresses
 void update_refcounts(int old_address, int new_address, int size) {
   if (old_address == new_address) {
     trace(9999, "mem") << "copying address to itself; refcount unchanged" << end();
@@ -56,10 +55,8 @@ void update_refcounts(int old_address, int new_address, int size) {
 }
 
 int payload_size(reagent/*copy*/ x) {
-  // lookup_memory without drop_one_lookup
-  if (x.value)
-    x.set_value(get_or_insert(Memory, x.value)+/*skip refcount*/1);
-  drop_from_type(x, "address");
+  x.properties.push_back(pair<string, string_tree*>("lookup", NULL));
+  lookup_memory_core(x);
   return size_of(x)+/*refcount*/1;
 }