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/convert_names_handles_records11
-rw-r--r--cpp/025name12
2 files changed, 22 insertions, 1 deletions
diff --git a/cpp/.traces/convert_names_handles_records b/cpp/.traces/convert_names_handles_records
new file mode 100644
index 00000000..0b2464e9
--- /dev/null
+++ b/cpp/.traces/convert_names_handles_records
@@ -0,0 +1,11 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "0", value: 0, type: 0, properties: [0: literal]}
+parse/0:   product: {name: "a", value: 0, type: 4, properties: [a: point]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "0", value: 0, type: 0, properties: [0: literal]}
+parse/0:   product: {name: "b", value: 0, type: 1, properties: [b: integer]}
+name/0: assign a 1
+name/0: assign b 3
+after-brace/0: recipe main
+after-brace/0: copy ...
+after-brace/0: copy ...
diff --git a/cpp/025name b/cpp/025name
index e3d290c3..7654907a 100644
--- a/cpp/025name
+++ b/cpp/025name
@@ -68,7 +68,7 @@ void transform_names(const recipe_number r) {
         if (names.find(inst.products[out].name) == names.end()) {
           trace("name") << "assign " << inst.products[out].name << " " << curr_idx;
           names[inst.products[out].name] = curr_idx;
-          ++curr_idx;
+          curr_idx += size_of(inst.products[out]);
         }
         inst.products[out].value = names[inst.products[out].name];
         inst.products[out].initialized = true;
@@ -136,3 +136,13 @@ recipe main [
 ]
 +name: field y of type point is at offset 1
 +name: field x of type point is at offset 0
+
+//: this test is actually illegal so can't call run
+:(scenarios transform_test)
+:(scenario "convert_names_handles_records")
+recipe main [
+  a:point <- copy 0:literal
+  b:integer <- copy 0:literal
+]
++name: assign a 1
++name: assign b 3