about summary refs log tree commit diff stats
path: root/059shape_shifting_recipe.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-18 23:55:54 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-12-15 10:20:41 -0800
commit82177734ca98cfc67afe5d87be4edd3f86546231 (patch)
tree9d2823281500f4846e36cb379d387e4b6f5d21a1 /059shape_shifting_recipe.cc
parenta5ab5b24e71fc93c58cb2d00fbde54d874a6263a (diff)
downloadmu-82177734ca98cfc67afe5d87be4edd3f86546231.tar.gz
layer 3 of edit/ now working
Now I complain before running if a call somewhere doesn't line up with
its ingredients, or if no specialization can be made to match it.
Diffstat (limited to '059shape_shifting_recipe.cc')
-rw-r--r--059shape_shifting_recipe.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc
index 774230a2..04c72af8 100644
--- a/059shape_shifting_recipe.cc
+++ b/059shape_shifting_recipe.cc
@@ -72,6 +72,7 @@ if (best_score == -1) {
 //?   cerr << "no variant found for " << inst.name << "; searching for variant with suitable type ingredients" << '\n';
   recipe_ordinal exemplar = pick_matching_shape_shifting_variant(variants, inst, best_score);
   if (exemplar) {
+//?     cerr << "specializing " << inst.name << '\n';
     trace(9992, "transform") << "found variant to specialize: " << exemplar << ' ' << get(Recipe, exemplar).name << end();
 //?     cerr << "found variant to specialize: " << exemplar << ' ' << get(Recipe, exemplar).name << '\n';
     recipe_ordinal new_recipe_ordinal = new_variant(exemplar, inst, caller_recipe);
@@ -91,6 +92,16 @@ if (best_score == -1) {
   }
 }
 
+//: make sure we have no unspecialized shape-shifting recipes being called
+//: before running mu programs
+
+:(before "End Instruction Operation Checks")
+if (contains_key(Recipe, inst.operation)
+    && any_type_ingredient_in_header(inst.operation)) {
+  raise_error << maybe(caller.name) << "instruction " << inst.name << " has no valid specialization\n" << end();
+  return;
+}
+
 :(code)
 recipe_ordinal pick_matching_shape_shifting_variant(vector<recipe_ordinal>& variants, const instruction& inst, long long int& best_score) {
 //?   cerr << "---- " << inst.name << ": " << non_ghost_size(variants) << '\n';
@@ -138,6 +149,7 @@ long long int shape_shifting_variant_score(const instruction& inst, recipe_ordin
   }
   const vector<reagent>& header_products = get(Recipe, variant).products;
   for (long long int i = 0; i < SIZE(inst.products); ++i) {
+    if (is_dummy(inst.products.at(i))) continue;
     if (!deeply_equal_concrete_types(header_products.at(i), inst.products.at(i))) {
       trace(9993, "transform") << "mismatch: product " << i << end();
 //?       cerr << "mismatch: product " << i << '\n';