From a802f0cedc7b5580d746f46ae62fcf8074ae3c49 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 2 Mar 2017 04:41:24 -0800 Subject: 3749 --- html/056shape_shifting_recipe.cc.html | 62 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'html/056shape_shifting_recipe.cc.html') diff --git a/html/056shape_shifting_recipe.cc.html b/html/056shape_shifting_recipe.cc.html index 3896e1e9..a2519c1b 100644 --- a/html/056shape_shifting_recipe.cc.html +++ b/html/056shape_shifting_recipe.cc.html @@ -102,7 +102,7 @@ if ('onhashchange' in window) { 37 if (Current_routine->calls.front().running_step_index == 0 38 && any_type_ingredient_in_header(Current_routine->calls.front().running_recipe)) { 39 //? DUMP(""); - 40 raise << "ran into unspecialized shape-shifting recipe " << current_recipe_name() << '\n' << end(); + 40 raise << "ran into unspecialized shape-shifting recipe " << current_recipe_name() << '\n' << end(); 41 //? exit(0); 42 } 43 @@ -122,14 +122,14 @@ if ('onhashchange' in window) { 57 candidates = strictly_matching_shape_shifting_variants(inst, variants); 58 if (!candidates.empty()) { 59 recipe_ordinal exemplar = best_shape_shifting_variant(inst, candidates); - 60 trace(9992, "transform") << "found variant to specialize: " << exemplar << ' ' << get(Recipe, exemplar).name << end(); + 60 trace(9992, "transform") << "found variant to specialize: " << exemplar << ' ' << get(Recipe, exemplar).name << end(); 61 recipe_ordinal new_recipe_ordinal = new_variant(exemplar, inst, caller_recipe); 62 if (new_recipe_ordinal == 0) goto skip_shape_shifting_variants; 63 variants.push_back(new_recipe_ordinal); // side-effect 64 recipe& variant = get(Recipe, new_recipe_ordinal); 65 // perform all transforms on the new specialization 66 if (!variant.steps.empty()) { - 67 trace(9992, "transform") << "transforming new specialization: " << variant.name << end(); + 67 trace(9992, "transform") << "transforming new specialization: " << variant.name << end(); 68 for (int t = 0; t < SIZE(Transform); ++t) { 69 // one exception: skip tangle, which would have already occurred inside new_variant above 70 if (Transform.at(t) == /*disambiguate overloading*/static_cast<transform_fn>(insert_fragments)) @@ -138,7 +138,7 @@ if ('onhashchange' in window) { 73 } 74 } 75 variant.transformed_until = SIZE(Transform)-1; - 76 trace(9992, "transform") << "new specialization: " << variant.name << end(); + 76 trace(9992, "transform") << "new specialization: " << variant.name << end(); 77 return variant.name; 78 } 79 skip_shape_shifting_variants:; @@ -149,7 +149,7 @@ if ('onhashchange' in window) { 84 :(before "End Instruction Operation Checks") 85 if (contains_key(Recipe, inst.operation) && inst.operation >= MAX_PRIMITIVE_RECIPES 86 && any_type_ingredient_in_header(inst.operation)) { - 87 raise << maybe(caller.name) << "instruction '" << inst.name << "' has no valid specialization\n" << end(); + 87 raise << maybe(caller.name) << "instruction '" << inst.name << "' has no valid specialization\n" << end(); 88 return; 89 } 90 @@ -176,14 +176,14 @@ if ('onhashchange' in window) { 111 bool all_concrete_header_reagents_strictly_match(const instruction& inst, const recipe& variant) { 112 for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { 113 if (!concrete_type_names_strictly_match(variant.ingredients.at(i), inst.ingredients.at(i))) { - 114 trace(9993, "transform") << "concrete-type match failed: ingredient " << i << end(); + 114 trace(9993, "transform") << "concrete-type match failed: ingredient " << i << end(); 115 return false; 116 } 117 } 118 for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.ingredients)); ++i) { 119 if (is_dummy(inst.products.at(i))) continue; 120 if (!concrete_type_names_strictly_match(variant.products.at(i), inst.products.at(i))) { - 121 trace(9993, "transform") << "concrete-type match failed: product " << i << end(); + 121 trace(9993, "transform") << "concrete-type match failed: product " << i << end(); 122 return false; 123 } 124 } @@ -251,9 +251,9 @@ if ('onhashchange' in window) { 186 if (from->atom != to->atom) return false; 187 // both from and to are atoms 188 if (from->name == "literal") - 189 return Literal_type_names.find(to->name) != Literal_type_names.end(); + 189 return Literal_type_names.find(to->name) != Literal_type_names.end(); 190 if (to->name == "literal") - 191 return Literal_type_names.find(from->name) != Literal_type_names.end(); + 191 return Literal_type_names.find(from->name) != Literal_type_names.end(); 192 return to->name == from->name; 193 } 194 @@ -299,7 +299,7 @@ if ('onhashchange' in window) { 234 recipe new_recipe = get(Recipe, exemplar); 235 new_recipe.name = new_name; 236 new_recipe.is_autogenerated = true; - 237 trace(9993, "transform") << "switching " << inst.name << " to specialized " << header_label(new_recipe) << end(); + 237 trace(9993, "transform") << "switching " << inst.name << " to specialized " << header_label(new_recipe) << end(); 238 239 // Replace type ingredients with concrete types in new_recipe. 240 // @@ -318,7 +318,7 @@ if ('onhashchange' in window) { 253 compute_type_ingredient_mappings(get(Recipe, exemplar), inst, mappings, caller_recipe, &error); 254 if (!error) error = (SIZE(mappings) != type_ingredient_count_in_header(exemplar)); 255 if (!error) replace_type_ingredients(new_recipe, mappings); - 256 for (map<string, const type_tree*>::iterator p = mappings.begin(); p != mappings.end(); ++p) + 256 for (map<string, const type_tree*>::iterator p = mappings.begin(); p != mappings.end(); ++p) 257 delete p->second; 258 if (error) return 0; 259 } @@ -328,7 +328,7 @@ if ('onhashchange' in window) { 263 } 264 265 void compute_type_names(recipe& variant) { - 266 trace(9993, "transform") << "-- compute type names: " << variant.name << end(); + 266 trace(9993, "transform") << "-- compute type names: " << variant.name << end(); 267 map<string, type_tree*> type_names; 268 for (int i = 0; i < SIZE(variant.ingredients); ++i) 269 save_or_deduce_type_name(variant.ingredients.at(i), type_names, variant, ""); @@ -336,7 +336,7 @@ if ('onhashchange' in window) { 271 save_or_deduce_type_name(variant.products.at(i), type_names, variant, ""); 272 for (int i = 0; i < SIZE(variant.steps); ++i) { 273 instruction& inst = variant.steps.at(i); - 274 trace(9993, "transform") << " instruction: " << to_string(inst) << end(); + 274 trace(9993, "transform") << " instruction: " << to_string(inst) << end(); 275 for (int in = 0; in < SIZE(inst.ingredients); ++in) 276 save_or_deduce_type_name(inst.ingredients.at(in), type_names, variant, " in '" + inst.original_string + "'"); 277 for (int out = 0; out < SIZE(inst.products); ++out) @@ -345,20 +345,20 @@ if ('onhashchange' in window) { 280 } 281 282 void save_or_deduce_type_name(reagent& x, map<string, type_tree*>& type, const recipe& variant, const string& context) { - 283 trace(9994, "transform") << " checking " << to_string(x) << ": " << names_to_string(x.type) << end(); + 283 trace(9994, "transform") << " checking " << to_string(x) << ": " << names_to_string(x.type) << end(); 284 if (!x.type && contains_key(type, x.name)) { 285 x.type = new type_tree(*get(type, x.name)); - 286 trace(9994, "transform") << " deducing type to " << names_to_string(x.type) << end(); + 286 trace(9994, "transform") << " deducing type to " << names_to_string(x.type) << end(); 287 return; 288 } 289 if (!x.type) { - 290 raise << maybe(variant.original_name) << "unknown type for '" << x.original_string << "'" << context << " (check the name for typos)\n" << end(); + 290 raise << maybe(variant.original_name) << "unknown type for '" << x.original_string << "'" << context << " (check the name for typos)\n" << end(); 291 return; 292 } 293 if (contains_key(type, x.name)) return; 294 if (x.type->name == "offset" || x.type->name == "variant") return; // special-case for container-access instructions 295 put(type, x.name, x.type); - 296 trace(9993, "transform") << "type of '" << x.name << "' is " << names_to_string(x.type) << end(); + 296 trace(9993, "transform") << "type of '" << x.name << "' is " << names_to_string(x.type) << end(); 297 } 298 299 void compute_type_ingredient_mappings(const recipe& exemplar, const instruction& inst, map<string, const type_tree*>& mappings, const recipe& caller_recipe, bool* error) { @@ -390,13 +390,13 @@ if ('onhashchange' in window) { 325 if (!refinement_type) { 326 // probably a bug in mu 327 // todo: make this smarter; only flag an error if exemplar_type contains some *new* type ingredient - 328 raise << maybe(exemplar.name) << "missing type ingredient for " << exemplar_reagent.original_string << '\n' << end(); - 329 raise << " (called from '" << to_original_string(call_instruction) << "')\n" << end(); + 328 raise << maybe(exemplar.name) << "missing type ingredient for " << exemplar_reagent.original_string << '\n' << end(); + 329 raise << " (called from '" << to_original_string(call_instruction) << "')\n" << end(); 330 return; 331 } 332 if (!exemplar_type->atom && exemplar_type->right == NULL && !refinement_type->atom && refinement_type->right != NULL) { 333 exemplar_type = exemplar_type->left; - 334 assert_for_now(exemplar_type->atom); + 334 assert_for_now(exemplar_type->atom); 335 } 336 if (exemplar_type->atom) { 337 if (is_type_ingredient_name(exemplar_type->name)) { @@ -408,12 +408,12 @@ if ('onhashchange' in window) { 343 curr_refinement_type = new type_tree(*refinement_type->left); 344 } 345 if (!contains_key(mappings, exemplar_type->name)) { - 346 trace(9993, "transform") << "adding mapping from " << exemplar_type->name << " to " << to_string(curr_refinement_type) << end(); + 346 trace(9993, "transform") << "adding mapping from " << exemplar_type->name << " to " << to_string(curr_refinement_type) << end(); 347 put(mappings, exemplar_type->name, new type_tree(*curr_refinement_type)); 348 } 349 else { 350 if (!deeply_equal_type_names(get(mappings, exemplar_type->name), curr_refinement_type)) { - 351 raise << maybe(caller_recipe.name) << "no call found for '" << to_original_string(call_instruction) << "'\n" << end(); + 351 raise << maybe(caller_recipe.name) << "no call found for '" << to_original_string(call_instruction) << "'\n" << end(); 352 *error = true; 353 delete curr_refinement_type; 354 return; @@ -435,16 +435,16 @@ if ('onhashchange' in window) { 370 void replace_type_ingredients(recipe& new_recipe, const map<string, const type_tree*>& mappings) { 371 // update its header 372 if (mappings.empty()) return; - 373 trace(9993, "transform") << "replacing in recipe header ingredients" << end(); + 373 trace(9993, "transform") << "replacing in recipe header ingredients" << end(); 374 for (int i = 0; i < SIZE(new_recipe.ingredients); ++i) 375 replace_type_ingredients(new_recipe.ingredients.at(i), mappings, new_recipe); - 376 trace(9993, "transform") << "replacing in recipe header products" << end(); + 376 trace(9993, "transform") << "replacing in recipe header products" << end(); 377 for (int i = 0; i < SIZE(new_recipe.products); ++i) 378 replace_type_ingredients(new_recipe.products.at(i), mappings, new_recipe); 379 // update its body 380 for (int i = 0; i < SIZE(new_recipe.steps); ++i) { 381 instruction& inst = new_recipe.steps.at(i); - 382 trace(9993, "transform") << "replacing in instruction '" << to_string(inst) << "'" << end(); + 382 trace(9993, "transform") << "replacing in instruction '" << to_string(inst) << "'" << end(); 383 for (int j = 0; j < SIZE(inst.ingredients); ++j) 384 replace_type_ingredients(inst.ingredients.at(j), mappings, new_recipe); 385 for (int j = 0; j < SIZE(inst.products); ++j) @@ -461,9 +461,9 @@ if ('onhashchange' in window) { 396 397 void replace_type_ingredients(reagent& x, const map<string, const type_tree*>& mappings, const recipe& caller) { 398 string before = to_string(x); - 399 trace(9993, "transform") << "replacing in ingredient " << x.original_string << end(); + 399 trace(9993, "transform") << "replacing in ingredient " << x.original_string << end(); 400 if (!x.type) { - 401 raise << "specializing " << caller.original_name << ": missing type for '" << x.original_string << "'\n" << end(); + 401 raise << "specializing " << caller.original_name << ": missing type for '" << x.original_string << "'\n" << end(); 402 return; 403 } 404 replace_type_ingredients(x.type, mappings); @@ -485,7 +485,7 @@ if ('onhashchange' in window) { 420 if (!contains_key(mappings, type->name)) 421 return; 422 const type_tree* replacement = get(mappings, type->name); - 423 trace(9993, "transform") << type->name << " => " << names_to_string(replacement) << end(); + 423 trace(9993, "transform") << type->name << " => " << names_to_string(replacement) << end(); 424 if (replacement->atom) { 425 if (!contains_key(Type_ordinal, replacement->name)) { 426 // error in program; should be reported elsewhere @@ -546,7 +546,7 @@ if ('onhashchange' in window) { 481 } 482 483 void ensure_all_concrete_types(/*const*/ recipe& new_recipe, const recipe& exemplar) { - 484 trace(9993, "transform") << "-- ensure all concrete types in recipe " << new_recipe.name << end(); + 484 trace(9993, "transform") << "-- ensure all concrete types in recipe " << new_recipe.name << end(); 485 for (int i = 0; i < SIZE(new_recipe.ingredients); ++i) 486 ensure_all_concrete_types(new_recipe.ingredients.at(i), exemplar); 487 for (int i = 0; i < SIZE(new_recipe.products); ++i) @@ -562,12 +562,12 @@ if ('onhashchange' in window) { 497 498 void ensure_all_concrete_types(/*const*/ reagent& x, const recipe& exemplar) { 499 if (!x.type || contains_type_ingredient_name(x.type)) { - 500 raise << maybe(exemplar.name) << "failed to map a type to " << x.original_string << '\n' << end(); + 500 raise << maybe(exemplar.name) << "failed to map a type to " << x.original_string << '\n' << end(); 501 if (!x.type) x.type = new type_tree("", 0); // just to prevent crashes later 502 return; 503 } 504 if (x.type->value == -1) { - 505 raise << maybe(exemplar.name) << "failed to map a type to the unknown " << x.original_string << '\n' << end(); + 505 raise << maybe(exemplar.name) << "failed to map a type to the unknown " << x.original_string << '\n' << end(); 506 return; 507 } 508 } -- cgit 1.4.1-2-gfad0