about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-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;
+}