From 67db19a05335c7fbea3ad6737303c8848fd39e74 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 15 Dec 2015 14:32:47 -0800 Subject: 2545 update html --- html/059shape_shifting_recipe.cc.html | 57 +++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 12 deletions(-) (limited to 'html/059shape_shifting_recipe.cc.html') diff --git a/html/059shape_shifting_recipe.cc.html b/html/059shape_shifting_recipe.cc.html index ce450999..4b895042 100644 --- a/html/059shape_shifting_recipe.cc.html +++ b/html/059shape_shifting_recipe.cc.html @@ -79,20 +79,20 @@ if (contains_type_ingredient_name//: *specializing* existing recipes. //: //: Keep track of these new recipes in a separate variable in addition to -//: recently_added_recipes, so that edit/ can clear them before reloading to +//: Recently_added_recipes, so that edit/ can clear them before reloading to //: regenerate errors. :(before "End Globals") -vector<recipe_ordinal> recently_added_shape_shifting_recipes; +vector<recipe_ordinal> Recently_added_shape_shifting_recipes; :(before "End Setup") //? cerr << "setup: clearing recently-added shape-shifting recipes\n"; -recently_added_shape_shifting_recipes.clear(); +Recently_added_shape_shifting_recipes.clear(); //: make sure we don't clear any of these recipes when we start running tests :(before "End Loading .mu Files") -recently_added_recipes.clear(); -recently_added_types.clear(); +Recently_added_recipes.clear(); +Recently_added_types.clear(); //? cerr << "clearing recently-added shape-shifting recipes\n"; -recently_added_shape_shifting_recipes.clear(); +Recently_added_shape_shifting_recipes.clear(); //: save original name of specialized recipes :(before "End recipe Fields") @@ -107,26 +107,58 @@ 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'; + LOG << "found variant to specialize: " << exemplar << ' ' << header(get(Recipe, exemplar)) << '\n'; recipe_ordinal new_recipe_ordinal = new_variant(exemplar, inst, caller_recipe); variants.push_back(new_recipe_ordinal); // perform all transforms on the new specialization const string& new_name = get(Recipe, variants.back()).name; trace(9992, "transform") << "transforming new specialization: " << new_name << end(); -//? cerr << "transforming new specialization: " << new_name << '\n'; + LOG << "transforming new specialization: " << header(get(Recipe, variants.back())) << '\n'; for (long long int t = 0; t < SIZE(Transform); ++t) { (*Transform.at(t))(new_recipe_ordinal); } get(Recipe, new_recipe_ordinal).transformed_until = SIZE(Transform)-1; -//? cerr << "-- replacing " << inst.name << " with " << get(Recipe, variants.back()).name << '\n' << debug_string(get(Recipe, variants.back())); + LOG << "replacing " << inst.name << " with " << get(Recipe, variants.back()).name << '\n'; inst.name = get(Recipe, variants.back()).name; trace(9992, "transform") << "new specialization: " << inst.name << end(); -//? cerr << "new specialization: " << inst.name << '\n'; + LOG << "new specialization: " << inst.name << '\n'; } } +//: make sure we have no unspecialized shape-shifting recipes being called +//: before running mu programs + +:(before "End Instruction Operation Checks") +//? LOG << inst.operation << " " << contains_key(Recipe, inst.operation) << '\n'; +if (contains_key(Recipe, inst.operation) && inst.operation >= MAX_PRIMITIVE_RECIPES + && any_type_ingredient_in_header(inst.operation)) { +//? LOG << header(caller) << "instruction " << inst.name << " has no valid specialization\n"; + raise_error << maybe(caller.name) << "instruction " << inst.name << " has no valid specialization\n" << end(); + return; +} + :(code) +string header(const recipe& caller) { + if (!caller.has_header) return maybe(caller.name); + ostringstream out; + out << caller.name; + for (long long int i = 0; i < SIZE(caller.ingredients); ++i) { + if (i > 0) out << ','; + out << ' ' << debug_string(caller.ingredients.at(i)); + } + if (!caller.products.empty()) { + out << " ->"; + for (long long int i = 0; i < SIZE(caller.products); ++i) { + if (i > 0) out << ','; + out << ' ' << debug_string(caller.products.at(i)); + } + } + out << ": "; + return out.str(); +} + 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'; recipe_ordinal result = 0; @@ -173,6 +205,7 @@ long long int shape_shifting_variant_score(const } 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'; @@ -270,8 +303,8 @@ recipe_ordinal new_variant(recipe_ordinal exempla // make a copy assert(contains_key(Recipe, exemplar)); assert(!contains_key(Recipe, new_recipe_ordinal)); - recently_added_recipes.push_back(new_recipe_ordinal); - recently_added_shape_shifting_recipes.push_back(new_recipe_ordinal); + Recently_added_recipes.push_back(new_recipe_ordinal); + Recently_added_shape_shifting_recipes.push_back(new_recipe_ordinal); put(Recipe, new_recipe_ordinal, get(Recipe, exemplar)); recipe& new_recipe = get(Recipe, new_recipe_ordinal); new_recipe.name = new_name; -- cgit 1.4.1-2-gfad0