about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-06-28 23:10:42 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-06-28 23:10:42 -0700
commit558bf3d388ee75cc3f37ba27b097af2f73e20b52 (patch)
tree0a038f93fc672d18eb73010ca3ea308c5de44313
parent1331848b2a5359e2b9d073266888bbda99151924 (diff)
downloadmu-558bf3d388ee75cc3f37ba27b097af2f73e20b52.tar.gz
3073
Support for containers without addresses.
-rw-r--r--073deep_copy.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/073deep_copy.cc b/073deep_copy.cc
index f564c81d..3f4edbb5 100644
--- a/073deep_copy.cc
+++ b/073deep_copy.cc
@@ -12,9 +12,23 @@ def main [
   local-scope
   x:number <- copy 34
   y:number <- deep-copy x
-  10:boolean/raw <- equal x y
+  10:boolean/raw <- equal x, y
 ]
-# non-addresses are identical
+# non-address primitives are identical
++mem: storing 1 in location 10
+
+:(scenario deep_copy_container_without_address)
+container foo [
+  x:number
+  y:number
+]
+def main [
+  local-scope
+  a:foo <- merge 34 35
+  b:foo <- deep-copy a
+  10:boolean/raw <- equal a, b
+]
+# containers are identical as long as they don't contain addresses
 +mem: storing 1 in location 10
 
 :(before "End Primitive Recipe Declarations")
@@ -71,4 +85,9 @@ void deep_copy(const reagent& canonized_in, map<int, int>& addresses_copied, vec
     out.push_back(result.at(0));
     return;
   }
+  if (get(Container_metadata, canonized_in.type).address.empty()) {
+    vector<double> result = read_memory(canonized_in);
+    out.insert(out.end(), result.begin(), result.end());
+    return;
+  }
 }