about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-06-23 12:05:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-06-23 12:05:18 -0700
commit02a55f7183f1497284accb3b89abab4a103d6e68 (patch)
tree7769c96d5be8f0e86b4ce16b709038fed940c647 /030container.cc
parent4938a720b31ebaf49a33b4c3ba1d7b772b7c6592 (diff)
downloadmu-02a55f7183f1497284accb3b89abab4a103d6e68.tar.gz
1629 - new helper for constructing containers
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/030container.cc b/030container.cc
index cff5dcf1..551a76a4 100644
--- a/030container.cc
+++ b/030container.cc
@@ -371,6 +371,33 @@ void check_container_field_types() {
   }
 }
 
+//:: Construct types out of their constituent fields. Doesn't currently do
+//:: type-checking but *does* match sizes.
+:(before "End Primitive Recipe Declarations")
+MERGE,
+:(before "End Primitive Recipe Numbers")
+Recipe_number["merge"] = MERGE;
+:(before "End Primitive Recipe Implementations")
+case MERGE: {
+  products.resize(1);
+  for (long long int i = 0; i < SIZE(ingredients); ++i)
+    for (long long int j = 0; j < SIZE(ingredients.at(i)); ++j)
+      products.at(0).push_back(ingredients.at(i).at(j));
+  break;
+}
+
+:(scenario merge)
+container foo [
+  x:number
+  y:number
+]
+
+recipe main [
+  1:foo <- merge 3:literal, 4:literal
+]
++mem: storing 3 in location 1
++mem: storing 4 in location 2
+
 //:: helpers
 
 :(code)