about summary refs log tree commit diff stats
path: root/054static_dispatch.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-19 22:10:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-19 22:10:35 -0700
commit6c96a437cef5140197660a0903309f11c364bf78 (patch)
treeea3b5a4d90100329eeb58a76773a500a6bee71da /054static_dispatch.cc
parent5a820205054a9c45a9b4dc71aa1f26b4612ec76d (diff)
downloadmu-6c96a437cef5140197660a0903309f11c364bf78.tar.gz
3522
Diffstat (limited to '054static_dispatch.cc')
-rw-r--r--054static_dispatch.cc50
1 files changed, 25 insertions, 25 deletions
diff --git a/054static_dispatch.cc b/054static_dispatch.cc
index a2cbe17a..79537a7c 100644
--- a/054static_dispatch.cc
+++ b/054static_dispatch.cc
@@ -55,7 +55,7 @@ else {
 :(code)
 string matching_variant_name(const recipe& rr) {
   const vector<recipe_ordinal>& variants = get_or_insert(Recipe_variants, rr.name);
-  for (int i = 0; i < SIZE(variants); ++i) {
+  for (int i = 0;  i < SIZE(variants);  ++i) {
     if (!contains_key(Recipe, variants.at(i))) continue;
     const recipe& candidate = get(Recipe, variants.at(i));
     if (!all_reagents_match(rr, candidate)) continue;
@@ -67,13 +67,13 @@ string matching_variant_name(const recipe& rr) {
 bool all_reagents_match(const recipe& r1, const recipe& r2) {
   if (SIZE(r1.ingredients) != SIZE(r2.ingredients)) return false;
   if (SIZE(r1.products) != SIZE(r2.products)) return false;
-  for (int i = 0; i < SIZE(r1.ingredients); ++i) {
+  for (int i = 0;  i < SIZE(r1.ingredients);  ++i) {
     expand_type_abbreviations(r1.ingredients.at(i).type);
     expand_type_abbreviations(r2.ingredients.at(i).type);
     if (!deeply_equal_type_names(r1.ingredients.at(i), r2.ingredients.at(i)))
       return false;
   }
-  for (int i = 0; i < SIZE(r1.products); ++i) {
+  for (int i = 0;  i < SIZE(r1.products);  ++i) {
     expand_type_abbreviations(r1.products.at(i).type);
     expand_type_abbreviations(r2.products.at(i).type);
     if (!deeply_equal_type_names(r1.products.at(i), r2.products.at(i)))
@@ -106,7 +106,7 @@ bool deeply_equal_type_names(const type_tree* a, const type_tree* b) {
 }
 
 string next_unused_recipe_name(const string& recipe_name) {
-  for (int i = 2; ; ++i) {
+  for (int i = 2;  /*forever*/;  ++i) {
     ostringstream out;
     out << recipe_name << '_' << i;
     if (!contains_key(Recipe_ordinal, out.str()))
@@ -131,9 +131,9 @@ def test a:num, b:num -> z:num [
 
 //: support recipe headers in a previous transform to fill in missing types
 :(before "End check_or_set_invalid_types")
-for (int i = 0; i < SIZE(caller.ingredients); ++i)
+for (int i = 0;  i < SIZE(caller.ingredients);  ++i)
   check_or_set_invalid_types(caller.ingredients.at(i).type, maybe(caller.name), "recipe header ingredient");
-for (int i = 0; i < SIZE(caller.products); ++i)
+for (int i = 0;  i < SIZE(caller.products);  ++i)
   check_or_set_invalid_types(caller.products.at(i).type, maybe(caller.name), "recipe header product");
 
 //: after filling in all missing types (because we'll be introducing 'blank' types in this transform in a later layer, for shape-shifting recipes)
@@ -153,7 +153,7 @@ list<call> resolve_stack;
 void resolve_ambiguous_calls(recipe_ordinal r) {
   recipe& caller_recipe = get(Recipe, r);
   trace(9991, "transform") << "--- resolve ambiguous calls for recipe " << caller_recipe.name << end();
-  for (int index = 0; index < SIZE(caller_recipe.steps); ++index) {
+  for (int index = 0;  index < SIZE(caller_recipe.steps);  ++index) {
     instruction& inst = caller_recipe.steps.at(index);
     if (inst.is_label) continue;
     if (non_ghost_size(get_or_insert(Recipe_variants, inst.name)) == 0) continue;
@@ -196,7 +196,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")
@@ -221,7 +221,7 @@ string best_variant(instruction& inst, const recipe& caller_recipe) {
 // phase 1
 vector<recipe_ordinal> strictly_matching_variants(const instruction& inst, vector<recipe_ordinal>& variants) {
   vector<recipe_ordinal> result;
-  for (int i = 0; i < SIZE(variants); ++i) {
+  for (int i = 0;  i < SIZE(variants);  ++i) {
     if (variants.at(i) == -1) continue;
     trace(9992, "transform") << "checking variant (strict) " << i << ": " << header_label(variants.at(i)) << end();
     if (all_header_reagents_strictly_match(inst, get(Recipe, variants.at(i))))
@@ -231,13 +231,13 @@ vector<recipe_ordinal> strictly_matching_variants(const instruction& inst, vecto
 }
 
 bool all_header_reagents_strictly_match(const instruction& inst, const recipe& variant) {
-  for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) {
+  for (int i = 0;  i < min(SIZE(inst.ingredients), SIZE(variant.ingredients));  ++i) {
     if (!types_strictly_match(variant.ingredients.at(i), inst.ingredients.at(i))) {
       trace(9993, "transform") << "strict match failed: ingredient " << i << end();
       return false;
     }
   }
-  for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.products)); ++i) {
+  for (int i = 0;  i < min(SIZE(inst.products), SIZE(variant.products));  ++i) {
     if (is_dummy(inst.products.at(i))) continue;
     if (!types_strictly_match(variant.products.at(i), inst.products.at(i))) {
       trace(9993, "transform") << "strict match failed: product " << i << end();
@@ -250,7 +250,7 @@ bool all_header_reagents_strictly_match(const instruction& inst, const recipe& v
 // phase 2
 vector<recipe_ordinal> strictly_matching_variants_except_literal_zero_against_address(const instruction& inst, vector<recipe_ordinal>& variants) {
   vector<recipe_ordinal> result;
-  for (int i = 0; i < SIZE(variants); ++i) {
+  for (int i = 0;  i < SIZE(variants);  ++i) {
     if (variants.at(i) == -1) continue;
     trace(9992, "transform") << "checking variant (strict except literal-zero-against-address) " << i << ": " << header_label(variants.at(i)) << end();
     if (all_header_reagents_strictly_match_except_literal_zero_against_address(inst, get(Recipe, variants.at(i))))
@@ -260,13 +260,13 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_zero_against_ad
 }
 
 bool all_header_reagents_strictly_match_except_literal_zero_against_address(const instruction& inst, const recipe& variant) {
-  for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) {
+  for (int i = 0;  i < min(SIZE(inst.ingredients), SIZE(variant.ingredients));  ++i) {
     if (!types_strictly_match_except_literal_zero_against_address(variant.ingredients.at(i), inst.ingredients.at(i))) {
       trace(9993, "transform") << "match failed: ingredient " << i << end();
       return false;
     }
   }
-  for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.products)); ++i) {
+  for (int i = 0;  i < min(SIZE(inst.products), SIZE(variant.products));  ++i) {
     if (is_dummy(inst.products.at(i))) continue;
     if (!types_strictly_match(variant.products.at(i), inst.products.at(i))) {
       trace(9993, "transform") << "match failed: product " << i << end();
@@ -285,7 +285,7 @@ bool types_strictly_match_except_literal_zero_against_address(const reagent& to,
 // phase 4
 vector<recipe_ordinal> strictly_matching_variants_except_literal_against_address_or_boolean(const instruction& inst, vector<recipe_ordinal>& variants) {
   vector<recipe_ordinal> result;
-  for (int i = 0; i < SIZE(variants); ++i) {
+  for (int i = 0;  i < SIZE(variants);  ++i) {
     if (variants.at(i) == -1) continue;
     trace(9992, "transform") << "checking variant (strict except literal-against-boolean) " << i << ": " << header_label(variants.at(i)) << end();
     if (all_header_reagents_strictly_match_except_literal_against_address_or_boolean(inst, get(Recipe, variants.at(i))))
@@ -295,13 +295,13 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_against_address
 }
 
 bool all_header_reagents_strictly_match_except_literal_against_address_or_boolean(const instruction& inst, const recipe& variant) {
-  for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) {
+  for (int i = 0;  i < min(SIZE(inst.ingredients), SIZE(variant.ingredients));  ++i) {
     if (!types_strictly_match_except_literal_against_address_or_boolean(variant.ingredients.at(i), inst.ingredients.at(i))) {
       trace(9993, "transform") << "match failed: ingredient " << i << end();
       return false;
     }
   }
-  for (int i = 0; i < min(SIZE(variant.products), SIZE(inst.products)); ++i) {
+  for (int i = 0;  i < min(SIZE(variant.products), SIZE(inst.products));  ++i) {
     if (is_dummy(inst.products.at(i))) continue;
     if (!types_strictly_match_except_literal_against_address_or_boolean(variant.products.at(i), inst.products.at(i))) {
       trace(9993, "transform") << "match failed: product " << i << end();
@@ -320,7 +320,7 @@ bool types_strictly_match_except_literal_against_address_or_boolean(const reagen
 // phase 5
 vector<recipe_ordinal> matching_variants(const instruction& inst, vector<recipe_ordinal>& variants) {
   vector<recipe_ordinal> result;
-  for (int i = 0; i < SIZE(variants); ++i) {
+  for (int i = 0;  i < SIZE(variants);  ++i) {
     if (variants.at(i) == -1) continue;
     trace(9992, "transform") << "checking variant " << i << ": " << header_label(variants.at(i)) << end();
     if (all_header_reagents_match(inst, get(Recipe, variants.at(i))))
@@ -330,13 +330,13 @@ vector<recipe_ordinal> matching_variants(const instruction& inst, vector<recipe_
 }
 
 bool all_header_reagents_match(const instruction& inst, const recipe& variant) {
-  for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) {
+  for (int i = 0;  i < min(SIZE(inst.ingredients), SIZE(variant.ingredients));  ++i) {
     if (!types_match(variant.ingredients.at(i), inst.ingredients.at(i))) {
       trace(9993, "transform") << "match failed: ingredient " << i << end();
       return false;
     }
   }
-  for (int i = 0; i < min(SIZE(variant.products), SIZE(inst.products)); ++i) {
+  for (int i = 0;  i < min(SIZE(variant.products), SIZE(inst.products));  ++i) {
     if (is_dummy(inst.products.at(i))) continue;
     if (!types_match(variant.products.at(i), inst.products.at(i))) {
       trace(9993, "transform") << "match failed: product " << i << end();
@@ -351,7 +351,7 @@ const recipe& best_variant(const instruction& inst, vector<recipe_ordinal>& cand
   assert(!candidates.empty());
   int min_score = 999;
   int min_index = 0;
-  for (int i = 0; i < SIZE(candidates); ++i) {
+  for (int i = 0;  i < SIZE(candidates);  ++i) {
     const recipe& candidate = get(Recipe, candidates.at(i));
     int score = abs(SIZE(candidate.products)-SIZE(inst.products))
                           + abs(SIZE(candidate.ingredients)-SIZE(inst.ingredients));
@@ -366,7 +366,7 @@ const recipe& best_variant(const instruction& inst, vector<recipe_ordinal>& cand
 
 int non_ghost_size(vector<recipe_ordinal>& variants) {
   int result = 0;
-  for (int i = 0; i < SIZE(variants); ++i)
+  for (int i = 0;  i < SIZE(variants);  ++i)
     if (variants.at(i) != -1) ++result;
   return result;
 }
@@ -374,7 +374,7 @@ int non_ghost_size(vector<recipe_ordinal>& variants) {
 bool next_stash(const call& c, instruction* stash_inst) {
   const recipe& specializer_recipe = get(Recipe, c.running_recipe);
   int index = c.running_step_index;
-  for (++index; index < SIZE(specializer_recipe.steps); ++index) {
+  for (++index;  index < SIZE(specializer_recipe.steps);  ++index) {
     const instruction& inst = specializer_recipe.steps.at(index);
     if (inst.name == "stash") {
       *stash_inst = inst;
@@ -564,10 +564,10 @@ string header_label(recipe_ordinal r) {
 string header_label(const recipe& caller) {
   ostringstream out;
   out << "recipe " << caller.name;
-  for (int i = 0; i < SIZE(caller.ingredients); ++i)
+  for (int i = 0;  i < SIZE(caller.ingredients);  ++i)
     out << ' ' << to_string(caller.ingredients.at(i));
   if (!caller.products.empty()) out << " ->";
-  for (int i = 0; i < SIZE(caller.products); ++i)
+  for (int i = 0;  i < SIZE(caller.products);  ++i)
     out << ' ' << to_string(caller.products.at(i));
   return out.str();
 }