From b24eb4766ad12eceaafa2ee0d620e070e21a3293 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 13 Mar 2016 20:26:47 -0700 Subject: 2773 - switch to 'int' This should eradicate the issue of 2771. --- 059shape_shifting_recipe.cc | 80 ++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to '059shape_shifting_recipe.cc') diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index d1ba0e4a..35791147 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -77,7 +77,7 @@ if (!candidates.empty()) { // perform all transforms on the new specialization if (!variant.steps.empty()) { trace(9992, "transform") << "transforming new specialization: " << variant.name << end(); - for (long long int t = 0; t < SIZE(Transform); ++t) { + for (int t = 0; t < SIZE(Transform); ++t) { (*Transform.at(t))(new_recipe_ordinal); } } @@ -101,7 +101,7 @@ if (contains_key(Recipe, inst.operation) && inst.operation >= MAX_PRIMITIVE_RECI // phase 2 of static dispatch vector strictly_matching_shape_shifting_variants(const instruction& inst, vector& variants) { vector result; - for (long long int i = 0; i < SIZE(variants); ++i) { + for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; if (!any_type_ingredient_in_header(variants.at(i))) continue; if (all_concrete_header_reagents_strictly_match(inst, get(Recipe, variants.at(i)))) @@ -119,13 +119,13 @@ bool all_concrete_header_reagents_strictly_match(const instruction& inst, const trace(9993, "transform") << "too few products" << end(); return false; } - for (long long int i = 0; i < SIZE(variant.ingredients); ++i) { + for (int i = 0; i < SIZE(variant.ingredients); ++i) { if (!concrete_type_names_strictly_match(variant.ingredients.at(i), inst.ingredients.at(i))) { trace(9993, "transform") << "concrete-type match failed: ingredient " << i << end(); return false; } } - for (long long int i = 0; i < SIZE(inst.products); ++i) { + for (int i = 0; i < SIZE(inst.products); ++i) { if (is_dummy(inst.products.at(i))) continue; if (!concrete_type_names_strictly_match(variant.products.at(i), inst.products.at(i))) { trace(9993, "transform") << "strict match failed: product " << i << end(); @@ -139,21 +139,21 @@ bool all_concrete_header_reagents_strictly_match(const instruction& inst, const recipe_ordinal best_shape_shifting_variant(const instruction& inst, vector& candidates) { assert(!candidates.empty()); // primary score - long long int max_score = -1; - for (long long int i = 0; i < SIZE(candidates); ++i) { - long long int score = number_of_concrete_type_names(candidates.at(i)); + int max_score = -1; + for (int i = 0; i < SIZE(candidates); ++i) { + int score = number_of_concrete_type_names(candidates.at(i)); assert(score > -1); if (score > max_score) max_score = score; } // break any ties at max_score by a secondary score - long long int min_score2 = 999; - long long int best_index = 0; - for (long long int i = 0; i < SIZE(candidates); ++i) { - long long int score1 = number_of_concrete_type_names(candidates.at(i)); + int min_score2 = 999; + int best_index = 0; + for (int i = 0; i < SIZE(candidates); ++i) { + int score1 = number_of_concrete_type_names(candidates.at(i)); assert(score1 <= max_score); if (score1 != max_score) continue; const recipe& candidate = get(Recipe, candidates.at(i)); - long long int score2 = (SIZE(candidate.products)-SIZE(inst.products)) + int score2 = (SIZE(candidate.products)-SIZE(inst.products)) + (SIZE(inst.ingredients)-SIZE(candidate.ingredients)); assert(score2 < 999); if (score2 < min_score2) { @@ -166,11 +166,11 @@ recipe_ordinal best_shape_shifting_variant(const instruction& inst, vectorname.empty() && !is_type_ingredient_name(type->name)) result++; result += number_of_concrete_type_names(type->left); @@ -269,16 +269,16 @@ recipe_ordinal new_variant(recipe_ordinal exemplar, const instruction& inst, con void compute_type_names(recipe& variant) { trace(9993, "transform") << "compute type names: " << variant.name << end(); map type_names; - for (long long int i = 0; i < SIZE(variant.ingredients); ++i) + for (int i = 0; i < SIZE(variant.ingredients); ++i) save_or_deduce_type_name(variant.ingredients.at(i), type_names, variant); - for (long long int i = 0; i < SIZE(variant.products); ++i) + for (int i = 0; i < SIZE(variant.products); ++i) save_or_deduce_type_name(variant.products.at(i), type_names, variant); - for (long long int i = 0; i < SIZE(variant.steps); ++i) { + for (int i = 0; i < SIZE(variant.steps); ++i) { instruction& inst = variant.steps.at(i); trace(9993, "transform") << " instruction: " << to_string(inst) << end(); - for (long long int in = 0; in < SIZE(inst.ingredients); ++in) + for (int in = 0; in < SIZE(inst.ingredients); ++in) save_or_deduce_type_name(inst.ingredients.at(in), type_names, variant); - for (long long int out = 0; out < SIZE(inst.products); ++out) + for (int out = 0; out < SIZE(inst.products); ++out) save_or_deduce_type_name(inst.products.at(out), type_names, variant); } } @@ -301,8 +301,8 @@ void save_or_deduce_type_name(reagent& x, map& type, const r } void compute_type_ingredient_mappings(const recipe& exemplar, const instruction& inst, map& mappings, const recipe& caller_recipe, bool* error) { - long long int limit = min(SIZE(inst.ingredients), SIZE(exemplar.ingredients)); - for (long long int i = 0; i < limit; ++i) { + int limit = min(SIZE(inst.ingredients), SIZE(exemplar.ingredients)); + for (int i = 0; i < limit; ++i) { const reagent& exemplar_reagent = exemplar.ingredients.at(i); reagent ingredient = inst.ingredients.at(i); canonize_type(ingredient); @@ -310,7 +310,7 @@ void compute_type_ingredient_mappings(const recipe& exemplar, const instruction& accumulate_type_ingredients(exemplar_reagent, ingredient, mappings, exemplar, inst, caller_recipe, error); } limit = min(SIZE(inst.products), SIZE(exemplar.products)); - for (long long int i = 0; i < limit; ++i) { + for (int i = 0; i < limit; ++i) { const reagent& exemplar_reagent = exemplar.products.at(i); reagent product = inst.products.at(i); canonize_type(product); @@ -318,7 +318,7 @@ void compute_type_ingredient_mappings(const recipe& exemplar, const instruction& } } -inline long long int min(long long int a, long long int b) { +inline int min(int a, int b) { return (a < b) ? a : b; } @@ -372,18 +372,18 @@ void replace_type_ingredients(recipe& new_recipe, const mapname != "literal-string") { @@ -516,15 +516,15 @@ void dump_inspect(const type_tree* x, ostream& out) { } void ensure_all_concrete_types(/*const*/ recipe& new_recipe, const recipe& exemplar) { - for (long long int i = 0; i < SIZE(new_recipe.ingredients); ++i) + for (int i = 0; i < SIZE(new_recipe.ingredients); ++i) ensure_all_concrete_types(new_recipe.ingredients.at(i), exemplar); - for (long long int i = 0; i < SIZE(new_recipe.products); ++i) + for (int i = 0; i < SIZE(new_recipe.products); ++i) ensure_all_concrete_types(new_recipe.products.at(i), exemplar); - for (long long int i = 0; i < SIZE(new_recipe.steps); ++i) { + for (int i = 0; i < SIZE(new_recipe.steps); ++i) { instruction& inst = new_recipe.steps.at(i); - for (long long int j = 0; j < SIZE(inst.ingredients); ++j) + for (int j = 0; j < SIZE(inst.ingredients); ++j) ensure_all_concrete_types(inst.ingredients.at(j), exemplar); - for (long long int j = 0; j < SIZE(inst.products); ++j) + for (int j = 0; j < SIZE(inst.products); ++j) ensure_all_concrete_types(inst.products.at(j), exemplar); } } -- cgit 1.4.1-2-gfad0