From b2566a847948ba808d4ca93d02bcc62ee6487255 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 2 Feb 2016 09:59:40 -0800 Subject: 2625 --- html/059shape_shifting_recipe.cc.html | 63 ++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 26 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 dcbcd680..857bfca0 100644 --- a/html/059shape_shifting_recipe.cc.html +++ b/html/059shape_shifting_recipe.cc.html @@ -72,8 +72,8 @@ if (Current_routine->< //: Make sure we don't match up literals with type ingredients without //: specialization. -:(before "End Matching Types For Literal(lhs)") -if (contains_type_ingredient_name(lhs)) return false; +:(before "End Matching Types For Literal(to)") +if (contains_type_ingredient_name(to)) return false; //: We'll be creating recipes without loading them from anywhere by //: *specializing* existing recipes. @@ -112,14 +112,16 @@ if (best_score == -1(exemplar, inst, caller_recipe); if (new_recipe_ordinal == 0) goto done_constructing_variant; variants.push_back(new_recipe_ordinal); + recipe& variant = get(Recipe, 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(); - for (long long int t = 0; t < SIZE(Transform); ++t) { - (*Transform.at(t))(new_recipe_ordinal); + if (!variant.steps.empty()) { + trace(9992, "transform") << "transforming new specialization: " << variant.name << end(); + 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; - inst.name = get(Recipe, variants.back()).name; + variant.transformed_until = SIZE(Transform)-1; + inst.name = variant.name; trace(9992, "transform") << "new specialization: " << inst.name << end(); } done_constructing_variant:; @@ -227,10 +229,10 @@ bool any_type_ingredient_in_header(recipe_ordinal return false; } -bool deeply_equal_concrete_types(reagent lhs, reagent rhs) { - canonize_type(lhs); - canonize_type(rhs); - return deeply_equal_concrete_types(lhs.properties.at(0).second, rhs.properties.at(0).second, rhs); +bool deeply_equal_concrete_types(reagent to, reagent from) { + canonize_type(to); + canonize_type(from); + return deeply_equal_concrete_types(to.properties.at(0).second, from.properties.at(0).second, from); } long long int number_of_concrete_types(recipe_ordinal r) { @@ -257,24 +259,24 @@ long long int number_of_concrete_types(const stri return result; } -bool deeply_equal_concrete_types(const string_tree* lhs, const string_tree* rhs, const reagent& rhs_reagent) { - if (!lhs) return !rhs; - if (!rhs) return !lhs; - if (is_type_ingredient_name(lhs->value)) return true; // type ingredient matches anything - if (lhs->value == "literal" && rhs->value == "literal") +bool deeply_equal_concrete_types(const string_tree* to, const string_tree* from, const reagent& rhs_reagent) { + if (!to) return !from; + if (!from) return !to; + if (is_type_ingredient_name(to->value)) return true; // type ingredient matches anything + if (to->value == "literal" && from->value == "literal") return true; - if (lhs->value == "literal" - && Literal_type_names.find(rhs->value) != Literal_type_names.end()) + if (to->value == "literal" + && Literal_type_names.find(from->value) != Literal_type_names.end()) return true; - if (rhs->value == "literal" - && Literal_type_names.find(lhs->value) != Literal_type_names.end()) + if (from->value == "literal" + && Literal_type_names.find(to->value) != Literal_type_names.end()) return true; - if (rhs->value == "literal" && lhs->value == "address") + if (from->value == "literal" && to->value == "address") return rhs_reagent.name == "0"; -//? cerr << lhs->value << " vs " << rhs->value << '\n'; - return lhs->value == rhs->value - && deeply_equal_concrete_types(lhs->left, rhs->left, rhs_reagent) - && deeply_equal_concrete_types(lhs->right, rhs->right, rhs_reagent); +//? cerr << to->value << " vs " << from->value << '\n'; + return to->value == from->value + && deeply_equal_concrete_types(to->left, from->left, rhs_reagent) + && deeply_equal_concrete_types(to->right, from->right, rhs_reagent); } bool contains_type_ingredient_name(const reagent& x) { @@ -568,6 +570,15 @@ container foo:_t [ +mem: storing 14 in location 20 +mem: storing 15 in location 21 +:(scenario shape_shifting_recipe_empty) +recipe main [ + foo 1 +] +# shape-shifting recipe with no body +recipe foo a:_t [ +] +# shouldn't crash + :(scenario shape_shifting_recipe_handles_shape_shifting_new_ingredient) recipe main [ 1:address:shared:foo:point <- bar 3 -- cgit 1.4.1-2-gfad0