diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-10-31 23:09:04 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-10-31 23:12:39 -0700 |
commit | bcd33d6dbfb1fb0325ac21910bec9847ca1dd8df (patch) | |
tree | d51c4841d69e7e4cafdd1a4f1fc3bdea37ecb0a9 /057static_dispatch.cc | |
parent | 3929c26cfc6e2dce8bfd119a722e4a8531886f96 (diff) | |
download | mu-bcd33d6dbfb1fb0325ac21910bec9847ca1dd8df.tar.gz |
2336
Minor tweak: track all recipe variants.
Diffstat (limited to '057static_dispatch.cc')
-rw-r--r-- | 057static_dispatch.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/057static_dispatch.cc b/057static_dispatch.cc index cc99f5ed..6a86beba 100644 --- a/057static_dispatch.cc +++ b/057static_dispatch.cc @@ -19,16 +19,24 @@ recipe test a:number, b:number -> z:number [ :(before "End Globals") map<string, vector<recipe_ordinal> > Recipe_variants; +:(before "End Setup") +Recipe_variants.clear(); :(before "End Load Recipe Header(result)") -if (Recipe_ordinal.find(result.name) != Recipe_ordinal.end() - && (Recipe.find(Recipe_ordinal[result.name]) == Recipe.end() - || Recipe[Recipe_ordinal[result.name]].has_header) - && !header_already_exists(result)) { - string new_name = next_unused_recipe_name(result.name); - Recipe_ordinal[new_name] = Next_recipe_ordinal++; - Recipe_variants[result.name].push_back(Recipe_ordinal[new_name]); - result.name = new_name; +if (Recipe_ordinal.find(result.name) != Recipe_ordinal.end()) { + if ((Recipe.find(Recipe_ordinal[result.name]) == Recipe.end() + || Recipe[Recipe_ordinal[result.name]].has_header) + && !header_already_exists(result)) { + string new_name = next_unused_recipe_name(result.name); + Recipe_ordinal[new_name] = Next_recipe_ordinal++; + Recipe_variants[result.name].push_back(Recipe_ordinal[new_name]); + result.name = new_name; + } +} +else { + // save first variant + Recipe_ordinal[result.name] = Next_recipe_ordinal++; + Recipe_variants[result.name].push_back(Recipe_ordinal[result.name]); } :(code) @@ -99,6 +107,8 @@ void resolve_ambiguous_calls(recipe_ordinal r) { instruction& inst = Recipe[r].steps.at(index); if (inst.is_label) continue; if (Recipe_variants.find(inst.name) == Recipe_variants.end()) continue; + assert(!Recipe_variants[inst.name].empty()); + if (++Recipe_variants[inst.name].begin() == Recipe_variants[inst.name].end()) continue; replace_best_variant(inst); } } |