about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-10 10:27:27 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-10 10:27:27 -0800
commitbd7a19a59014c64a2c3e9c0b6af802b04991de6a (patch)
tree53b09b12851f2b89d4a7db00fffd001b1ff44ad6
parent50e0065e1e2aca3f64130ede9cf0e33c9c725718 (diff)
downloadmu-bd7a19a59014c64a2c3e9c0b6af802b04991de6a.tar.gz
2644
More tweaking of traces as I debug recipe specialization.
-rw-r--r--057static_dispatch.cc9
-rw-r--r--059shape_shifting_recipe.cc2
2 files changed, 7 insertions, 4 deletions
diff --git a/057static_dispatch.cc b/057static_dispatch.cc
index 93a2e36e..fcae37ee 100644
--- a/057static_dispatch.cc
+++ b/057static_dispatch.cc
@@ -30,6 +30,7 @@ for (map<string, vector<recipe_ordinal> >::iterator p = Recipe_variants.begin();
 }
 
 :(before "End Load Recipe Header(result)")
+// there can only ever be one variant for main
 if (result.name != "main" && contains_key(Recipe_ordinal, result.name)) {
   const recipe_ordinal r = get(Recipe_ordinal, result.name);
 //?   cerr << result.name << ": " << contains_key(Recipe, r) << (contains_key(Recipe, r) ? get(Recipe, r).has_header : 0) << matching_variant_name(result) << '\n';
@@ -41,6 +42,7 @@ if (result.name != "main" && contains_key(Recipe_ordinal, result.name)) {
       put(Recipe_ordinal, new_name, Next_recipe_ordinal++);
       get_or_insert(Recipe_variants, result.name).push_back(get(Recipe_ordinal, new_name));
     }
+    trace(9999, "load") << "switching " << result.name << " to " << new_name << end();
     result.name = new_name;
 //?     cerr << "=> " << new_name << '\n';
   }
@@ -169,7 +171,7 @@ void resolve_ambiguous_calls(recipe_ordinal r) {
 }
 
 void replace_best_variant(instruction& inst, const recipe& caller_recipe) {
-  trace(9992, "transform") << "instruction " << inst.name << end();
+  trace(9992, "transform") << "instruction " << inst.original_string << end();
   vector<recipe_ordinal>& variants = get(Recipe_variants, inst.name);
 //?   trace(9992, "transform") << "checking base: " << get(Recipe_ordinal, inst.name) << end();
   long long int best_score = variant_score(inst, get(Recipe_ordinal, inst.name));
@@ -180,6 +182,7 @@ void replace_best_variant(instruction& inst, const recipe& caller_recipe) {
     long long int current_score = variant_score(inst, variants.at(i));
     trace(9992, "transform") << "score for variant " << i << ": " << current_score << end();
     if (current_score > best_score) {
+      trace(9993, "transform") << "switching " << inst.name << " to " << get(Recipe, variants.at(i)).name << end();
       inst.name = get(Recipe, variants.at(i)).name;
       best_score = current_score;
     }
@@ -456,10 +459,10 @@ string header_label(recipe_ordinal r) {
   ostringstream out;
   out << "recipe " << caller.name;
   for (long long int i = 0; i < SIZE(caller.ingredients); ++i)
-    out << ' ' << caller.ingredients.at(i).original_string;
+    out << ' ' << caller.ingredients.at(i).to_string();
   if (!caller.products.empty()) out << " ->";
   for (long long int i = 0; i < SIZE(caller.products); ++i)
-    out << ' ' << caller.products.at(i).original_string;
+    out << ' ' << caller.products.at(i).to_string();
   return out.str();
 }
 
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc
index 39ec6fb4..f83b09f0 100644
--- a/059shape_shifting_recipe.cc
+++ b/059shape_shifting_recipe.cc
@@ -258,7 +258,7 @@ bool is_type_ingredient_name(const string& type) {
 
 recipe_ordinal new_variant(recipe_ordinal exemplar, const instruction& inst, const recipe& caller_recipe) {
   string new_name = next_unused_recipe_name(inst.name);
-  trace(9993, "transform") << "switching " << inst.name << " to " << new_name << end();
+  trace(9993, "transform") << "switching " << inst.name << " to specialized " << new_name << end();
   assert(!contains_key(Recipe_ordinal, new_name));
   recipe_ordinal new_recipe_ordinal = put(Recipe_ordinal, new_name, Next_recipe_ordinal++);
   // make a copy