about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-09 21:31:21 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-09 21:31:31 -0800
commitb0450faf28ba629374adb025a3127a9a244c6380 (patch)
tree2f471db21e3d72e909c553f38eb320adb94eb123
parentc1720b71386b51a7e1da814f8257799d30e6013d (diff)
downloadmu-b0450faf28ba629374adb025a3127a9a244c6380.tar.gz
2413 - another backfilled test for 2391
This time for the support for 'new' that was added in 2393.
-rw-r--r--010vm.cc1
-rw-r--r--056recipe_header.cc8
-rw-r--r--058generic_container.cc6
-rw-r--r--059generic_recipe.cc25
4 files changed, 40 insertions, 0 deletions
diff --git a/010vm.cc b/010vm.cc
index 6512158c..92721d32 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -434,6 +434,7 @@ string instruction::to_string() const {
 string debug_string(const recipe& x) {
   ostringstream out;
   out << "recipe " << x.name << '\n';
+  // Begin debug_string(recipe x)
   for (long long int index = 0; index < SIZE(x.steps); ++index) {
     const instruction& inst = x.steps.at(index);
     out << "  inst: " << inst.to_string() << '\n';
diff --git a/056recipe_header.cc b/056recipe_header.cc
index e6a83383..53670931 100644
--- a/056recipe_header.cc
+++ b/056recipe_header.cc
@@ -72,6 +72,14 @@ recipe bar [
 ]
 +mem: storing 4 in location 1
 
+:(after "Begin debug_string(recipe x)")
+out << "ingredients:\n";
+for (long long int i = 0; i < SIZE(x.ingredients); ++i)
+  out << "  " << debug_string(x.ingredients.at(i)) << '\n';
+out << "products:\n";
+for (long long int i = 0; i < SIZE(x.products); ++i)
+  out << "  " << debug_string(x.products.at(i)) << '\n';
+
 //: If a recipe never mentions any ingredients or products, assume it has a header.
 
 :(scenario recipe_without_ingredients_or_products_has_header)
diff --git a/058generic_container.cc b/058generic_container.cc
index ddfb87c2..0bf6f699 100644
--- a/058generic_container.cc
+++ b/058generic_container.cc
@@ -100,6 +100,12 @@ long long int size_of_type_ingredient(const type_tree* element_template, const t
   }
   assert(curr);
   assert(!curr->left);  // unimplemented
+  if (!contains_key(Type, curr->value)) {
+    // temporarily while we're still ironing out kinks; eventually replace with a raise_error
+    DUMP("");
+    cerr << "missing type " << debug_string(curr) << '\n';
+    exit(0);
+  }
   assert(contains_key(Type, curr->value));
   trace(9999, "type") << "type deduced to be " << get(Type, curr->value).name << "$" << end();
   type_tree tmp(curr->value);
diff --git a/059generic_recipe.cc b/059generic_recipe.cc
index 63439af6..d4e7401f 100644
--- a/059generic_recipe.cc
+++ b/059generic_recipe.cc
@@ -98,6 +98,10 @@ bool any_type_ingredient_in_header(recipe_ordinal variant) {
     if (contains_type_ingredient_name(get(Recipe, variant).ingredients.at(i)))
       return true;
   }
+  for (long long int i = 0; i < SIZE(get(Recipe, variant).products); ++i) {
+    if (contains_type_ingredient_name(get(Recipe, variant).products.at(i)))
+      return true;
+  }
   return false;
 }
 
@@ -362,3 +366,24 @@ container foo:_t [
 ]
 +mem: storing 14 in location 20
 +mem: storing 15 in location 21
+
+:(scenario generic_recipe_handles_generic_new_ingredient)
+recipe main [
+  1:address:foo:point <- bar 3
+  11:foo:point <- copy *1:address:foo:point
+]
+container foo:_t [
+  x:_t
+  y:number
+]
+recipe bar x:number -> result:address:foo:_t [
+  local-scope
+  load-ingredients
+  # new refers to _t in its ingredient *value*
+  result <- new {(foo _t) : type}
+]
++mem: storing 0 in location 11
++mem: storing 0 in location 12
++mem: storing 0 in location 13
+
+# todo: container after generic recipe containing 'new'