diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-11-23 19:40:47 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-11-23 19:40:47 -0800 |
commit | 6ca1ac7a6ce0a79a7d857d6e21825037c00ba0c3 (patch) | |
tree | a3548f1d711692291d2ebf9f064e92972bca38f3 /054static_dispatch.cc | |
parent | ca4210b479603ccc25b274d7c3489eac0f9a22d6 (diff) | |
download | mu-6ca1ac7a6ce0a79a7d857d6e21825037c00ba0c3.tar.gz |
3684
Trying to find examples where a layer includes complexity just so later layers can hook into it. Resolve_stack is the one big one I've found that isn't just a simple function-call indirection that may later get more complex. Conclusion of a conversation with Stephen Malina: Such examples should make one very nervous, because this sort of creep is how we end up with over-engineered abstractions (http://www.joelonsoftware.com/articles/fog0000000018.html). We need to step very carefully anytime we make the outsider reader's comprehension task harder..
Diffstat (limited to '054static_dispatch.cc')
-rw-r--r-- | 054static_dispatch.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/054static_dispatch.cc b/054static_dispatch.cc index 6967b92a..fdebc79f 100644 --- a/054static_dispatch.cc +++ b/054static_dispatch.cc @@ -150,7 +150,7 @@ Transform.push_back(resolve_ambiguous_calls); // idempotent //: We're punning the 'call' data structure just because it has slots for //: calling recipe and calling instruction. :(before "End Globals") -list<call> resolve_stack; +list<call> Resolve_stack; :(code) void resolve_ambiguous_calls(const recipe_ordinal r) { @@ -161,14 +161,15 @@ void resolve_ambiguous_calls(const recipe_ordinal r) { if (inst.is_label) continue; if (non_ghost_size(get_or_insert(Recipe_variants, inst.name)) == 0) continue; trace(9992, "transform") << "instruction " << inst.original_string << end(); - resolve_stack.push_front(call(r)); - resolve_stack.front().running_step_index = index; + assert(Resolve_stack.empty()); + Resolve_stack.push_front(call(r)); + Resolve_stack.front().running_step_index = index; string new_name = best_variant(inst, caller_recipe); if (!new_name.empty()) inst.name = new_name; - assert(resolve_stack.front().running_recipe == r); - assert(resolve_stack.front().running_step_index == index); - resolve_stack.pop_front(); + assert(Resolve_stack.front().running_recipe == r); + assert(Resolve_stack.front().running_step_index == index); + Resolve_stack.pop_front(); } } @@ -199,7 +200,7 @@ string best_variant(instruction& inst, const recipe& caller_recipe) { // error messages if (get(Recipe_ordinal, inst.name) >= MAX_PRIMITIVE_RECIPES) { // we currently don't check types for primitive variants raise << maybe(caller_recipe.name) << "failed to find a matching call for '" << inst.original_string << "'\n" << end(); - for (list<call>::iterator p = /*skip*/++resolve_stack.begin(); p != resolve_stack.end(); ++p) { + for (list<call>::iterator p = /*skip*/++Resolve_stack.begin(); p != Resolve_stack.end(); ++p) { const recipe& specializer_recipe = get(Recipe, p->running_recipe); const instruction& specializer_inst = specializer_recipe.steps.at(p->running_step_index); if (specializer_recipe.name != "interactive") |