From 02a55f7183f1497284accb3b89abab4a103d6e68 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 23 Jun 2015 12:05:18 -0700 Subject: 1629 - new helper for constructing containers --- 030container.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to '030container.cc') 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) -- cgit 1.4.1-2-gfad0