about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-26 17:40:31 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-26 20:24:34 -0700
commit62ed0e4728ab0238c47f03dea38782a599bff3fb (patch)
tree0a91846931218ecd9f0fd23cb14366d91a2ad182
parent89173e25a96f9e940986185aaac4506be6a392c6 (diff)
downloadmu-62ed0e4728ab0238c47f03dea38782a599bff3fb.tar.gz
978
-rw-r--r--cpp/.traces/copy_handles_nested_record_elements34
-rw-r--r--cpp/018record20
2 files changed, 54 insertions, 0 deletions
diff --git a/cpp/.traces/copy_handles_nested_record_elements b/cpp/.traces/copy_handles_nested_record_elements
new file mode 100644
index 00000000..3edfa398
--- /dev/null
+++ b/cpp/.traces/copy_handles_nested_record_elements
@@ -0,0 +1,34 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "34", value: 0, type: 0, properties: [34: literal]}
+parse/0:   product: {name: "12", value: 0, type: 1, properties: [12: integer]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "35", value: 0, type: 0, properties: [35: literal]}
+parse/0:   product: {name: "13", value: 0, type: 1, properties: [13: integer]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "36", value: 0, type: 0, properties: [36: literal]}
+parse/0:   product: {name: "14", value: 0, type: 1, properties: [14: integer]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "12", value: 0, type: 5, properties: [12: point-integer]}
+parse/0:   product: {name: "15", value: 0, type: 5, properties: [15: point-integer]}
+after-brace/0: recipe main
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: copy ...
+run/0: instruction main/0
+run/0: ingredient 0 is 34
+mem/0: storing 34 in location 12
+run/0: instruction main/1
+run/0: ingredient 0 is 35
+mem/0: storing 35 in location 13
+run/0: instruction main/2
+run/0: ingredient 0 is 36
+mem/0: storing 36 in location 14
+run/0: instruction main/3
+run/0: ingredient 0 is 12
+mem/0: location 12 is 34
+mem/0: location 13 is 35
+mem/0: location 14 is 36
+mem/0: storing 34 in location 15
+mem/0: storing 35 in location 16
+mem/0: storing 36 in location 17
diff --git a/cpp/018record b/cpp/018record
index 91e142a3..5c1715a4 100644
--- a/cpp/018record
+++ b/cpp/018record
@@ -144,3 +144,23 @@ recipe main [
 +run: ingredient 1 is 1
 +run: address to copy is 13
 +mem: storing 13 in location 15
+
+:(scenario "copy_handles_nested_record_elements")
+recipe main [
+  12:integer <- copy 34:literal
+  13:integer <- copy 35:literal
+  14:integer <- copy 36:literal
+  15:point-integer <- copy 12:point-integer
+]
++mem: storing 36 in location 17
+
+:(before "End size_of Cases")
+if (t.is_record) {
+  size_t result = 0;
+  for (size_t i = 0; i < t.elements.size(); ++i) {
+    reagent x;
+    x.types.push_back(t.elements[i][0]);
+    result += size_of(x);
+  }
+  return result;
+}