about summary refs log tree commit diff stats
path: root/033exclusive_container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-30 22:13:22 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-30 22:13:22 -0700
commit2eab85b3a43316a391aed3564a1a75a97504a5ca (patch)
treeb7701085d29e8d10dd0725ff4a931b1637db399a /033exclusive_container.cc
parent4639ef6149176445cb014feea9885c3ea7b36d2b (diff)
downloadmu-2eab85b3a43316a391aed3564a1a75a97504a5ca.tar.gz
2115
Merging in unnecessary '0/empty' fields was a pain, and also made me do
some additional debugging in the last commit.
Diffstat (limited to '033exclusive_container.cc')
-rw-r--r--033exclusive_container.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/033exclusive_container.cc b/033exclusive_container.cc
index 42993231..58276b9a 100644
--- a/033exclusive_container.cc
+++ b/033exclusive_container.cc
@@ -148,3 +148,39 @@ recipe main [
 +mem: storing 34 in location 3
 +mem: storing 1 in location 4
 +mem: storing 34 in location 5
+
+//: Since the different variants of an exclusive-container might have
+//: different sizes, relax the size mismatch check for 'merge' instructions.
+:(before "End size_mismatch(x) Cases")
+if (current_instruction().operation == MERGE
+    && !current_instruction().products.empty()
+    && !current_instruction().products.at(0).types.empty()) {
+  reagent x = canonize(current_instruction().products.at(0));
+  if (Type[x.types.at(0)].kind == exclusive_container) {
+    return size_of(x) < SIZE(data);
+  }
+}
+
+:(scenario merge_exclusive_container_with_mismatched_sizes)
+container foo [
+  x:number
+  y:number
+]
+
+exclusive-container bar [
+  x:number
+  y:foo
+]
+
+recipe main [
+  1:number <- copy 34
+  2:number <- copy 35
+  3:bar <- merge 0/x, 1:number
+  6:bar <- merge 1/foo, 1:number, 2:number
+]
++mem: storing 0 in location 3
++mem: storing 34 in location 4
+# bar is always 3 large so location 5 is skipped
++mem: storing 1 in location 6
++mem: storing 34 in location 7
++mem: storing 35 in location 8