diff options
48 files changed, 520 insertions, 515 deletions
diff --git a/001help.cc b/001help.cc index 26f17893..06beab82 100644 --- a/001help.cc +++ b/001help.cc @@ -85,8 +85,13 @@ bool is_equal(char* s, const char* lit) { //: unsigned and that'll cause warnings about mixing signed and unsigned, //: yadda-yadda. Instead use this macro below to perform an unsafe cast to //: signed. We'll just give up immediately if a container's ever too large. +//: +//: Addendum to corollary: We're going to uniformly avoid long long int +//: everywhere, since Clang on 32-bit platforms doesn't yet support +//: multiplication over 64-bit integers, and since that seems like a more +//: common situation to end up in than integer overflow. :(before "End Includes") -#define SIZE(X) (assert((X).size() < (1LL<<(sizeof(long long int)*8-2))), static_cast<long long int>((X).size())) +#define SIZE(X) (assert((X).size() < (1LL<<(sizeof(int)*8-2))), static_cast<int>((X).size())) //: //: 5. Integer overflow is still impossible to guard against. Maybe after //: reading http://www.cs.utah.edu/~regehr/papers/overflow12.pdf diff --git a/002test.cc b/002test.cc index bf0611f2..46f07b00 100644 --- a/002test.cc +++ b/002test.cc @@ -88,10 +88,10 @@ bool is_integer(const string& s) { && s.find('-', 1) == string::npos; // '-' only at first position } -long long int to_integer(string n) { +int to_integer(string n) { char* end = NULL; // safe because string.c_str() is guaranteed to be null-terminated - long long int result = strtoll(n.c_str(), &end, /*any base*/0); + int result = strtoll(n.c_str(), &end, /*any base*/0); if (*end != '\0') cerr << "tried to convert " << n << " to number\n"; assert(*end == '\0'); return result; diff --git a/003trace.cc b/003trace.cc index 66da0392..8859ae96 100644 --- a/003trace.cc +++ b/003trace.cc @@ -208,7 +208,7 @@ START_TRACING_UNTIL_END_OF_SCOPE bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) { if (!Trace_stream) return false; vector<string> expected_lines = split(expected, ""); - long long int curr_expected_line = 0; + int curr_expected_line = 0; while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) ++curr_expected_line; if (curr_expected_line == SIZE(expected_lines)) return true; diff --git a/010vm.cc b/010vm.cc index 8ea38229..56148f2a 100644 --- a/010vm.cc +++ b/010vm.cc @@ -11,7 +11,7 @@ recipe_ordinal Next_recipe_ordinal = 1; //: adding two phone numbers is meaningless. Here each recipe does something //: incommensurable with any other recipe. :(after "Types") -typedef long long int recipe_ordinal; +typedef int recipe_ordinal; :(before "End Types") // Recipes are lists of instructions. To perform or 'run' a recipe, the @@ -99,7 +99,7 @@ struct string_tree { :(before "End Globals") // Locations refer to a common 'memory'. Each location can store a number. -map<long long int, double> Memory; +map<int, double> Memory; :(before "End Setup") Memory.clear(); @@ -112,7 +112,7 @@ Memory.clear(); // Unlike most computers today, mu stores types in a single big table, shared // by all the mu programs on the computer. This is useful in providing a // seamless experience to help understand arbitrary mu programs. -typedef long long int type_ordinal; +typedef int type_ordinal; :(before "End Globals") map<string, type_ordinal> Type_ordinal; map<type_ordinal, type_info> Type; @@ -140,7 +140,7 @@ void setup_types() { } void teardown_types() { for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { - for (long long int i = 0; i < SIZE(p->second.elements); ++i) + for (int i = 0; i < SIZE(p->second.elements); ++i) p->second.elements.clear(); } Type_ordinal.clear(); @@ -169,7 +169,7 @@ enum kind_of_type { struct type_info { string name; kind_of_type kind; - long long int size; // only if type is not primitive; primitives and addresses have size 1 (except arrays are dynamic) + int size; // only if type is not primitive; primitives and addresses have size 1 (except arrays are dynamic) vector<reagent> elements; // End type_info Fields type_info() :kind(PRIMITIVE), size(0) {} @@ -283,7 +283,7 @@ reagent::reagent(const reagent& old) { name = old.name; value = old.value; initialized = old.initialized; - for (long long int i = 0; i < SIZE(old.properties); ++i) { + for (int i = 0; i < SIZE(old.properties); ++i) { properties.push_back(pair<string, string_tree*>(old.properties.at(i).first, old.properties.at(i).second ? new string_tree(*old.properties.at(i).second) : NULL)); } @@ -305,10 +305,10 @@ string_tree::string_tree(const string_tree& old) { // :value(old.value) { reagent& reagent::operator=(const reagent& old) { original_string = old.original_string; - for (long long int i = 0; i < SIZE(properties); ++i) + for (int i = 0; i < SIZE(properties); ++i) if (properties.at(i).second) delete properties.at(i).second; properties.clear(); - for (long long int i = 0; i < SIZE(old.properties); ++i) + for (int i = 0; i < SIZE(old.properties); ++i) properties.push_back(pair<string, string_tree*>(old.properties.at(i).first, old.properties.at(i).second ? new string_tree(*old.properties.at(i).second) : NULL)); name = old.name; value = old.value; @@ -323,7 +323,7 @@ reagent::~reagent() { } void reagent::clear() { - for (long long int i = 0; i < SIZE(properties); ++i) { + for (int i = 0; i < SIZE(properties); ++i) { if (properties.at(i).second) { delete properties.at(i).second; properties.at(i).second = NULL; @@ -355,14 +355,14 @@ string slurp_until(istream& in, char delim) { } bool has_property(reagent x, string name) { - for (long long int i = 0; i < SIZE(x.properties); ++i) { + for (int i = 0; i < SIZE(x.properties); ++i) { if (x.properties.at(i).first == name) return true; } return false; } string_tree* property(const reagent& r, const string& name) { - for (long long int p = 0; p != SIZE(r.properties); ++p) { + for (int p = 0; p != SIZE(r.properties); ++p) { if (r.properties.at(p).first == name) return r.properties.at(p).second; } @@ -383,7 +383,7 @@ void skip_whitespace_but_not_newline(istream& in) { } void dump_memory() { - for (map<long long int, double>::iterator p = Memory.begin(); p != Memory.end(); ++p) { + for (map<int, double>::iterator p = Memory.begin(); p != Memory.end(); ++p) { cout << p->first << ": " << no_scientific(p->second) << '\n'; } } @@ -398,7 +398,7 @@ void dump_memory() { string to_string(const recipe& r) { ostringstream out; out << "recipe " << r.name << " [\n"; - for (long long int i = 0; i < SIZE(r.steps); ++i) + for (int i = 0; i < SIZE(r.steps); ++i) out << " " << to_string(r.steps.at(i)) << '\n'; out << "]\n"; return out.str(); @@ -408,14 +408,14 @@ string debug_string(const recipe& x) { ostringstream out; out << "- recipe " << x.name << '\n'; // Begin debug_string(recipe x) - for (long long int index = 0; index < SIZE(x.steps); ++index) { + for (int index = 0; index < SIZE(x.steps); ++index) { const instruction& inst = x.steps.at(index); out << "inst: " << to_string(inst) << '\n'; out << " ingredients\n"; - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) + for (int i = 0; i < SIZE(inst.ingredients); ++i) out << " " << debug_string(inst.ingredients.at(i)) << '\n'; out << " products\n"; - for (long long int i = 0; i < SIZE(inst.products); ++i) + for (int i = 0; i < SIZE(inst.products); ++i) out << " " << debug_string(inst.products.at(i)) << '\n'; } return out.str(); @@ -424,13 +424,13 @@ string debug_string(const recipe& x) { string to_string(const instruction& inst) { if (inst.is_label) return inst.label; ostringstream out; - for (long long int i = 0; i < SIZE(inst.products); ++i) { + for (int i = 0; i < SIZE(inst.products); ++i) { if (i > 0) out << ", "; out << inst.products.at(i).original_string; } if (!inst.products.empty()) out << " <- "; out << inst.name << ' '; - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (i > 0) out << ", "; out << inst.ingredients.at(i).original_string; } @@ -442,7 +442,7 @@ string to_string(const reagent& r) { out << r.name << ": " << names_to_string(r.type); if (!r.properties.empty()) { out << ", {"; - for (long long int i = 0; i < SIZE(r.properties); ++i) { + for (int i = 0; i < SIZE(r.properties); ++i) { if (i > 0) out << ", "; out << "\"" << r.properties.at(i).first << "\": " << to_string(r.properties.at(i).second); } @@ -586,7 +586,7 @@ ostream& operator<<(ostream& os, no_scientific x) { string trim_floating_point(const string& in) { if (in.empty()) return ""; - long long int len = SIZE(in); + int len = SIZE(in); while (len > 1) { if (in.at(len-1) != '0') break; --len; diff --git a/011load.cc b/011load.cc index 35d08881..ee8df684 100644 --- a/011load.cc +++ b/011load.cc @@ -40,7 +40,7 @@ vector<recipe_ordinal> load(istream& in) { return result; } -long long int slurp_recipe(istream& in) { +int slurp_recipe(istream& in) { recipe result; result.name = next_word(in); // End Load Recipe Name @@ -231,12 +231,12 @@ void show_rest_of_stream(istream& in) { //: Have tests clean up any recipes they added. :(before "End Globals") vector<recipe_ordinal> Recently_added_recipes; -long long int Reserved_for_tests = 1000; +int Reserved_for_tests = 1000; :(before "End Setup") clear_recently_added_recipes(); :(code) void clear_recently_added_recipes() { - for (long long int i = 0; i < SIZE(Recently_added_recipes); ++i) { + for (int i = 0; i < SIZE(Recently_added_recipes); ++i) { if (Recently_added_recipes.at(i) >= Reserved_for_tests // don't renumber existing recipes, like 'interactive' && contains_key(Recipe, Recently_added_recipes.at(i))) // in case previous test had duplicate definitions Recipe_ordinal.erase(get(Recipe, Recently_added_recipes.at(i)).name); diff --git a/012transform.cc b/012transform.cc index f1243648..fd3b25ff 100644 --- a/012transform.cc +++ b/012transform.cc @@ -14,7 +14,7 @@ //: relative to those in previous layers to find a better arrangement. :(before "End recipe Fields") -long long int transformed_until; +int transformed_until; :(before "End recipe Constructor") transformed_until = -1; @@ -39,7 +39,7 @@ vector<transform_fn> Transform; :(code) void transform_all() { trace(9990, "transform") << "=== transform_all()" << end(); - for (long long int t = 0; t < SIZE(Transform); ++t) { + for (int t = 0; t < SIZE(Transform); ++t) { //? cerr << "transform " << t << '\n'; for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; @@ -61,12 +61,12 @@ void parse_int_reagents() { for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; if (r.steps.empty()) continue; - for (long long int index = 0; index < SIZE(r.steps); ++index) { + for (int index = 0; index < SIZE(r.steps); ++index) { instruction& inst = r.steps.at(index); - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { populate_value(inst.ingredients.at(i)); } - for (long long int i = 0; i < SIZE(inst.products); ++i) { + for (int i = 0; i < SIZE(inst.products); ++i) { populate_value(inst.products.at(i)); } } diff --git a/013update_operation.cc b/013update_operation.cc index d27b018b..e5039fcd 100644 --- a/013update_operation.cc +++ b/013update_operation.cc @@ -9,7 +9,7 @@ void update_instruction_operations(recipe_ordinal r) { trace(9991, "transform") << "--- compute instruction operations for recipe " << get(Recipe, r).name << end(); recipe& caller = get(Recipe, r); //? cerr << "--- compute instruction operations for recipe " << caller.name << '\n'; - for (long long int index = 0; index < SIZE(caller.steps); ++index) { + for (int index = 0; index < SIZE(caller.steps); ++index) { instruction& inst = caller.steps.at(index); if (inst.is_label) continue; if (!contains_key(Recipe_ordinal, inst.name)) { diff --git a/020run.cc b/020run.cc index aaad7576..81ff91ad 100644 --- a/020run.cc +++ b/020run.cc @@ -37,7 +37,7 @@ def main [ //: Later layers will change this. struct routine { recipe_ordinal running_recipe; - long long int running_step_index; + int running_step_index; routine(recipe_ordinal r) :running_recipe(r), running_step_index(0) {} bool completed() const; const vector<instruction>& steps() const; @@ -45,9 +45,9 @@ struct routine { :(before "End Globals") routine* Current_routine = NULL; -map<string, long long int> Instructions_running; -map<string, long long int> Locations_read; -map<string, long long int> Locations_read_by_instruction; +map<string, int> Instructions_running; +map<string, int> Locations_read; +map<string, int> Locations_read_by_instruction; :(code) void run(recipe_ordinal r) { @@ -70,7 +70,7 @@ void run_current_routine() // read all ingredients from memory, each potentially spanning multiple locations vector<vector<double> > ingredients; if (should_copy_ingredients()) { - for (long long int i = 0; i < SIZE(current_instruction().ingredients); ++i) + for (int i = 0; i < SIZE(current_instruction().ingredients); ++i) ingredients.push_back(read_memory(current_instruction().ingredients.at(i))); } // instructions below will write to 'products' @@ -90,7 +90,7 @@ void run_current_routine() raise << SIZE(products) << " vs " << SIZE(current_instruction().products) << ": failed to write to all products! " << to_string(current_instruction()) << '\n' << end(); } else { - for (long long int i = 0; i < SIZE(current_instruction().products); ++i) { + for (int i = 0; i < SIZE(current_instruction().products); ++i) { write_memory(current_instruction().products.at(i), products.at(i)); } } @@ -109,7 +109,7 @@ bool should_copy_ingredients() { //: We'll need to override these later as we change the definition of routine. //: Important that they return referrences into the routine. -inline long long int& current_step_index() { +inline int& current_step_index() { return Current_routine->running_step_index; } @@ -181,15 +181,15 @@ void run_main(int argc, char* argv[]) { :(code) void dump_profile() { - for (map<string, long long int>::iterator p = Instructions_running.begin(); p != Instructions_running.end(); ++p) { + for (map<string, int>::iterator p = Instructions_running.begin(); p != Instructions_running.end(); ++p) { cerr << p->first << ": " << p->second << '\n'; } cerr << "== locations read\n"; - for (map<string, long long int>::iterator p = Locations_read.begin(); p != Locations_read.end(); ++p) { + for (map<string, int>::iterator p = Locations_read.begin(); p != Locations_read.end(); ++p) { cerr << p->first << ": " << p->second << '\n'; } cerr << "== locations read by instruction\n"; - for (map<string, long long int>::iterator p = Locations_read_by_instruction.begin(); p != Locations_read_by_instruction.end(); ++p) { + for (map<string, int>::iterator p = Locations_read_by_instruction.begin(); p != Locations_read_by_instruction.end(); ++p) { cerr << p->first << ": " << p->second << '\n'; } } @@ -258,8 +258,8 @@ vector<double> read_memory(reagent x) { return result; } // End Preprocess read_memory(x) - long long int size = size_of(x); - for (long long int offset = 0; offset < size; ++offset) { + int size = size_of(x); + for (int offset = 0; offset < size; ++offset) { double val = get_or_insert(Memory, x.value+offset); trace(9999, "mem") << "location " << x.value+offset << " is " << no_scientific(val) << end(); result.push_back(val); @@ -281,7 +281,7 @@ void write_memory(reagent x, const vector<double>& data) { return; } // End write_memory(reagent x) Special-cases - for (long long int offset = 0; offset < SIZE(data); ++offset) { + for (int offset = 0; offset < SIZE(data); ++offset) { assert(x.value+offset > 0); trace(9999, "mem") << "storing " << no_scientific(data.at(offset)) << " in location " << x.value+offset << end(); put(Memory, x.value+offset, data.at(offset)); @@ -289,12 +289,12 @@ void write_memory(reagent x, const vector<double>& data) { } :(code) -long long int size_of(const reagent& r) { +int size_of(const reagent& r) { if (r.type == NULL) return 0; // End size_of(reagent) Cases return size_of(r.type); } -long long int size_of(const type_tree* type) { +int size_of(const type_tree* type) { if (type == NULL) return 0; // End size_of(type) Cases return 1; @@ -318,7 +318,7 @@ inline bool is_literal(const reagent& r) { return r.type->value == 0; } -inline bool scalar(const vector<long long int>& x) { +inline bool scalar(const vector<int>& x) { return SIZE(x) == 1; } inline bool scalar(const vector<double>& x) { diff --git a/021check_instruction.cc b/021check_instruction.cc index 9200e5b8..355b51ab 100644 --- a/021check_instruction.cc +++ b/021check_instruction.cc @@ -16,7 +16,7 @@ void check_instruction(const recipe_ordinal r) { trace(9991, "transform") << "--- perform checks for recipe " << get(Recipe, r).name << end(); //? cerr << "--- perform checks for recipe " << get(Recipe, r).name << '\n'; map<string, vector<type_ordinal> > metadata; - for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { + for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { instruction& inst = get(Recipe, r).steps.at(i); if (inst.is_label) continue; switch (inst.operation) { @@ -26,7 +26,7 @@ void check_instruction(const recipe_ordinal r) { raise << "ingredients and products should match in '" << to_string(inst) << "'\n" << end(); break; } - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!types_coercible(inst.products.at(i), inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "can't copy " << inst.ingredients.at(i).original_string << " to " << inst.products.at(i).original_string << "; types don't match\n" << end(); goto finish_checking_instruction; diff --git a/022arithmetic.cc b/022arithmetic.cc index 89b444ae..f6eca412 100644 --- a/022arithmetic.cc +++ b/022arithmetic.cc @@ -7,7 +7,7 @@ put(Recipe_ordinal, "add", ADD); :(before "End Primitive Recipe Checks") case ADD: { // primary goal of these checks is to forbid address arithmetic - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_number(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'add' requires number ingredients, but got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -26,7 +26,7 @@ case ADD: { :(before "End Primitive Recipe Implementations") case ADD: { double result = 0; - for (long long int i = 0; i < SIZE(ingredients); ++i) { + for (int i = 0; i < SIZE(ingredients); ++i) { result += ingredients.at(i).at(0); } products.resize(1); @@ -78,7 +78,7 @@ case SUBTRACT: { raise << maybe(get(Recipe, r).name) << "'subtract' has no ingredients\n" << end(); break; } - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (is_raw(inst.ingredients.at(i))) continue; // permit address offset computations in tests if (!is_mu_number(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'subtract' requires number ingredients, but got " << inst.ingredients.at(i).original_string << '\n' << end(); @@ -98,7 +98,7 @@ case SUBTRACT: { :(before "End Primitive Recipe Implementations") case SUBTRACT: { double result = ingredients.at(0).at(0); - for (long long int i = 1; i < SIZE(ingredients); ++i) + for (int i = 1; i < SIZE(ingredients); ++i) result -= ingredients.at(i).at(0); products.resize(1); products.at(0).push_back(result); @@ -135,7 +135,7 @@ MULTIPLY, put(Recipe_ordinal, "multiply", MULTIPLY); :(before "End Primitive Recipe Checks") case MULTIPLY: { - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_number(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'multiply' requires number ingredients, but got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -154,7 +154,7 @@ case MULTIPLY: { :(before "End Primitive Recipe Implementations") case MULTIPLY: { double result = 1; - for (long long int i = 0; i < SIZE(ingredients); ++i) { + for (int i = 0; i < SIZE(ingredients); ++i) { result *= ingredients.at(i).at(0); } products.resize(1); @@ -192,7 +192,7 @@ case DIVIDE: { raise << maybe(get(Recipe, r).name) << "'divide' has no ingredients\n" << end(); break; } - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_number(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'divide' requires number ingredients, but got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -211,7 +211,7 @@ case DIVIDE: { :(before "End Primitive Recipe Implementations") case DIVIDE: { double result = ingredients.at(0).at(0); - for (long long int i = 1; i < SIZE(ingredients); ++i) + for (int i = 1; i < SIZE(ingredients); ++i) result /= ingredients.at(i).at(0); products.resize(1); products.at(0).push_back(result); @@ -258,7 +258,7 @@ case DIVIDE_WITH_REMAINDER: { raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' yields two products in '" << to_string(inst) << "'\n" << end(); break; } - 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)) && !is_mu_number(inst.products.at(i))) { raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' should yield a number, but got " << inst.products.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -269,8 +269,8 @@ case DIVIDE_WITH_REMAINDER: { :(before "End Primitive Recipe Implementations") case DIVIDE_WITH_REMAINDER: { products.resize(2); - long long int a = static_cast<long long int>(ingredients.at(0).at(0)); - long long int b = static_cast<long long int>(ingredients.at(1).at(0)); + int a = static_cast<int>(ingredients.at(0).at(0)); + int b = static_cast<int>(ingredients.at(1).at(0)); if (b == 0) { raise << maybe(current_recipe_name()) << "divide by zero in '" << to_string(current_instruction()) << "'\n" << end(); products.resize(2); @@ -278,8 +278,8 @@ case DIVIDE_WITH_REMAINDER: { products.at(1).push_back(0); break; } - long long int quotient = a / b; - long long int remainder = a % b; + int quotient = a / b; + int remainder = a % b; // very large integers will lose precision products.at(0).push_back(quotient); products.at(1).push_back(remainder); @@ -351,8 +351,8 @@ case SHIFT_LEFT: { :(before "End Primitive Recipe Implementations") case SHIFT_LEFT: { // ingredients must be integers - long long int a = static_cast<long long int>(ingredients.at(0).at(0)); - long long int b = static_cast<long long int>(ingredients.at(1).at(0)); + int a = static_cast<int>(ingredients.at(0).at(0)); + int b = static_cast<int>(ingredients.at(1).at(0)); products.resize(1); if (b < 0) { raise << maybe(current_recipe_name()) << "second ingredient can't be negative in '" << to_string(current_instruction()) << "'\n" << end(); @@ -422,8 +422,8 @@ case SHIFT_RIGHT: { :(before "End Primitive Recipe Implementations") case SHIFT_RIGHT: { // ingredients must be integers - long long int a = static_cast<long long int>(ingredients.at(0).at(0)); - long long int b = static_cast<long long int>(ingredients.at(1).at(0)); + int a = static_cast<int>(ingredients.at(0).at(0)); + int b = static_cast<int>(ingredients.at(1).at(0)); products.resize(1); if (b < 0) { raise << maybe(current_recipe_name()) << "second ingredient can't be negative in '" << to_string(current_instruction()) << "'\n" << end(); @@ -493,8 +493,8 @@ case AND_BITS: { :(before "End Primitive Recipe Implementations") case AND_BITS: { // ingredients must be integers - long long int a = static_cast<long long int>(ingredients.at(0).at(0)); - long long int b = static_cast<long long int>(ingredients.at(1).at(0)); + int a = static_cast<int>(ingredients.at(0).at(0)); + int b = static_cast<int>(ingredients.at(1).at(0)); products.resize(1); products.at(0).push_back(a&b); break; @@ -551,8 +551,8 @@ case OR_BITS: { :(before "End Primitive Recipe Implementations") case OR_BITS: { // ingredients must be integers - long long int a = static_cast<long long int>(ingredients.at(0).at(0)); - long long int b = static_cast<long long int>(ingredients.at(1).at(0)); + int a = static_cast<int>(ingredients.at(0).at(0)); + int b = static_cast<int>(ingredients.at(1).at(0)); products.resize(1); products.at(0).push_back(a|b); break; @@ -603,8 +603,8 @@ case XOR_BITS: { :(before "End Primitive Recipe Implementations") case XOR_BITS: { // ingredients must be integers - long long int a = static_cast<long long int>(ingredients.at(0).at(0)); - long long int b = static_cast<long long int>(ingredients.at(1).at(0)); + int a = static_cast<int>(ingredients.at(0).at(0)); + int b = static_cast<int>(ingredients.at(1).at(0)); products.resize(1); products.at(0).push_back(a^b); break; @@ -655,7 +655,7 @@ case FLIP_BITS: { :(before "End Primitive Recipe Implementations") case FLIP_BITS: { // ingredient must be integer - long long int a = static_cast<long long int>(ingredients.at(0).at(0)); + int a = static_cast<int>(ingredients.at(0).at(0)); products.resize(1); products.at(0).push_back(~a); break; diff --git a/023boolean.cc b/023boolean.cc index fc501a79..fdc22fcf 100644 --- a/023boolean.cc +++ b/023boolean.cc @@ -6,7 +6,7 @@ AND, put(Recipe_ordinal, "and", AND); :(before "End Primitive Recipe Checks") case AND: { - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_scalar(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'and' requires boolean ingredients, but got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -25,7 +25,7 @@ case AND: { :(before "End Primitive Recipe Implementations") case AND: { bool result = true; - for (long long int i = 0; i < SIZE(ingredients); ++i) + for (int i = 0; i < SIZE(ingredients); ++i) result = result && ingredients.at(i).at(0); products.resize(1); products.at(0).push_back(result); @@ -64,7 +64,7 @@ OR, put(Recipe_ordinal, "or", OR); :(before "End Primitive Recipe Checks") case OR: { - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_scalar(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'and' requires boolean ingredients, but got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -83,7 +83,7 @@ case OR: { :(before "End Primitive Recipe Implementations") case OR: { bool result = false; - for (long long int i = 0; i < SIZE(ingredients); ++i) + for (int i = 0; i < SIZE(ingredients); ++i) result = result || ingredients.at(i).at(0); products.resize(1); products.at(0).push_back(result); @@ -126,13 +126,13 @@ case NOT: { raise << maybe(get(Recipe, r).name) << "'not' cannot have fewer ingredients than products in '" << to_string(inst) << "'\n" << end(); break; } - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_scalar(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'not' requires boolean ingredients, but got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; } } - 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 (!is_mu_boolean(inst.products.at(i))) { raise << maybe(get(Recipe, r).name) << "'not' should yield a boolean, but got " << inst.products.at(i).original_string << '\n' << end(); @@ -144,7 +144,7 @@ case NOT: { :(before "End Primitive Recipe Implementations") case NOT: { products.resize(SIZE(ingredients)); - for (long long int i = 0; i < SIZE(ingredients); ++i) { + for (int i = 0; i < SIZE(ingredients); ++i) { products.at(i).push_back(!ingredients.at(i).at(0)); } break; diff --git a/025compare.cc b/025compare.cc index 251d8bc6..bb020c3a 100644 --- a/025compare.cc +++ b/025compare.cc @@ -24,7 +24,7 @@ case EQUAL: { case EQUAL: { vector<double>& exemplar = ingredients.at(0); bool result = true; - for (long long int i = 1; i < SIZE(ingredients); ++i) { + for (int i = 1; i < SIZE(ingredients); ++i) { if (!equal(ingredients.at(i).begin(), ingredients.at(i).end(), exemplar.begin())) { result = false; break; @@ -77,7 +77,7 @@ case GREATER_THAN: { raise << maybe(get(Recipe, r).name) << "'greater-than' needs at least two ingredients to compare in '" << to_string(inst) << "'\n" << end(); break; } - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_number(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'greater-than' can only compare numbers; got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -96,7 +96,7 @@ case GREATER_THAN: { :(before "End Primitive Recipe Implementations") case GREATER_THAN: { bool result = true; - for (long long int i = /**/1; i < SIZE(ingredients); ++i) { + for (int i = /**/1; i < SIZE(ingredients); ++i) { if (ingredients.at(i-1).at(0) <= ingredients.at(i).at(0)) { result = false; } @@ -144,7 +144,7 @@ case LESSER_THAN: { raise << maybe(get(Recipe, r).name) << "'lesser-than' needs at least two ingredients to compare in '" << to_string(inst) << "'\n" << end(); break; } - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_number(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'lesser-than' can only compare numbers; got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -163,7 +163,7 @@ case LESSER_THAN: { :(before "End Primitive Recipe Implementations") case LESSER_THAN: { bool result = true; - for (long long int i = /**/1; i < SIZE(ingredients); ++i) { + for (int i = /**/1; i < SIZE(ingredients); ++i) { if (ingredients.at(i-1).at(0) >= ingredients.at(i).at(0)) { result = false; } @@ -211,7 +211,7 @@ case GREATER_OR_EQUAL: { raise << maybe(get(Recipe, r).name) << "'greater-or-equal' needs at least two ingredients to compare in '" << to_string(inst) << "'\n" << end(); break; } - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_number(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'greater-or-equal' can only compare numbers; got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -230,7 +230,7 @@ case GREATER_OR_EQUAL: { :(before "End Primitive Recipe Implementations") case GREATER_OR_EQUAL: { bool result = true; - for (long long int i = /**/1; i < SIZE(ingredients); ++i) { + for (int i = /**/1; i < SIZE(ingredients); ++i) { if (ingredients.at(i-1).at(0) < ingredients.at(i).at(0)) { result = false; } @@ -286,7 +286,7 @@ case LESSER_OR_EQUAL: { raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' needs at least two ingredients to compare in '" << to_string(inst) << "'\n" << end(); break; } - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (!is_mu_number(inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' can only compare numbers; got " << inst.ingredients.at(i).original_string << '\n' << end(); goto finish_checking_instruction; @@ -305,7 +305,7 @@ case LESSER_OR_EQUAL: { :(before "End Primitive Recipe Implementations") case LESSER_OR_EQUAL: { bool result = true; - for (long long int i = /**/1; i < SIZE(ingredients); ++i) { + for (int i = /**/1; i < SIZE(ingredients); ++i) { if (ingredients.at(i-1).at(0) > ingredients.at(i).at(0)) { result = false; } diff --git a/029tools.cc b/029tools.cc index 50d85e55..13c5172a 100644 --- a/029tools.cc +++ b/029tools.cc @@ -28,10 +28,10 @@ case TRACE: { } :(before "End Primitive Recipe Implementations") case TRACE: { - long long int depth = ingredients.at(0).at(0); + int depth = ingredients.at(0).at(0); string label = current_instruction().ingredients.at(1).name; ostringstream out; - for (long long int i = 2; i < SIZE(current_instruction().ingredients); ++i) { + for (int i = 2; i < SIZE(current_instruction().ingredients); ++i) { out << print_mu(current_instruction().ingredients.at(i), ingredients.at(i)); } trace(depth, label) << out.str() << end(); @@ -51,7 +51,7 @@ case STASH: { :(before "End Primitive Recipe Implementations") case STASH: { ostringstream out; - for (long long int i = 0; i < SIZE(current_instruction().ingredients); ++i) { + for (int i = 0; i < SIZE(current_instruction().ingredients); ++i) { out << print_mu(current_instruction().ingredients.at(i), ingredients.at(i)); } trace(2, "app") << out.str() << end(); @@ -232,7 +232,7 @@ case _PRINT: { } :(before "End Primitive Recipe Implementations") case _PRINT: { - for (long long int i = 0; i < SIZE(ingredients); ++i) { + for (int i = 0; i < SIZE(ingredients); ++i) { if (is_literal(current_instruction().ingredients.at(i))) { trace(9998, "run") << "$print: " << current_instruction().ingredients.at(i).name << end(); if (has_property(current_instruction().ingredients.at(i), "newline")) @@ -241,7 +241,7 @@ case _PRINT: { cout << current_instruction().ingredients.at(i).name; } else { - for (long long int j = 0; j < SIZE(ingredients.at(i)); ++j) { + for (int j = 0; j < SIZE(ingredients.at(i)); ++j) { trace(9998, "run") << "$print: " << ingredients.at(i).at(j) << end(); if (j > 0) cout << " "; cout << no_scientific(ingredients.at(i).at(j)); @@ -319,7 +319,7 @@ case _LOG: { :(before "End Primitive Recipe Implementations") case _LOG: { ostringstream out; - for (long long int i = 0; i < SIZE(current_instruction().ingredients); ++i) { + for (int i = 0; i < SIZE(current_instruction().ingredients); ++i) { out << print_mu(current_instruction().ingredients.at(i), ingredients.at(i)); } LOG << out.str() << '\n'; diff --git a/030container.cc b/030container.cc index 3e8f0052..4cc0d58e 100644 --- a/030container.cc +++ b/030container.cc @@ -94,8 +94,8 @@ if (!contains_key(Type, type->value)) { type_info t = get(Type, type->value); if (t.kind == CONTAINER) { // size of a container is the sum of the sizes of its elements - long long int result = 0; - for (long long int i = 0; i < SIZE(t.elements); ++i) { + int result = 0; + for (int i = 0; i < SIZE(t.elements); ++i) { // todo: strengthen assertion to disallow mutual type recursion if (t.elements.at(i).type->value == type->value) { raise << "container " << t.name << " can't include itself as a member\n" << end(); @@ -148,7 +148,7 @@ case GET: { raise << maybe(get(Recipe, r).name) << "second ingredient of 'get' should have type 'offset', but got " << inst.ingredients.at(1).original_string << '\n' << end(); break; } - long long int offset_value = 0; + int offset_value = 0; if (is_integer(offset.name)) // later layers permit non-integer offsets offset_value = to_integer(offset.name); else @@ -171,16 +171,16 @@ case GET: { case GET: { reagent base = current_instruction().ingredients.at(0); // Update GET base in Run - long long int base_address = base.value; + int base_address = base.value; if (base_address == 0) { raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_string(current_instruction()) << "'\n" << end(); break; } type_ordinal base_type = base.type->value; - long long int offset = ingredients.at(1).at(0); + int offset = ingredients.at(1).at(0); if (offset < 0 || offset >= SIZE(get(Type, base_type).elements)) break; // copied from Check above - long long int src = base_address; - for (long long int i = 0; i < offset; ++i) { + int src = base_address; + for (int i = 0; i < offset; ++i) { // End GET field Cases src += size_of(element_type(base, i)); } @@ -193,7 +193,7 @@ case GET: { } :(code) -const reagent element_type(const reagent& canonized_base, long long int offset_value) { +const reagent element_type(const reagent& canonized_base, int offset_value) { assert(offset_value >= 0); assert(contains_key(Type, canonized_base.type->value)); assert(!get(Type, canonized_base.type->value).name.empty()); @@ -285,7 +285,7 @@ case GET_ADDRESS: { raise << maybe(get(Recipe, r).name) << "second ingredient of 'get' should have type 'offset', but got " << inst.ingredients.at(1).original_string << '\n' << end(); break; } - long long int offset_value = 0; + int offset_value = 0; if (is_integer(offset.name)) { // later layers permit non-integer offsets offset_value = to_integer(offset.name); if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type).elements)) { @@ -312,16 +312,16 @@ case GET_ADDRESS: { case GET_ADDRESS: { reagent base = current_instruction().ingredients.at(0); // Update GET_ADDRESS base in Run - long long int base_address = base.value; + int base_address = base.value; if (base_address == 0) { raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_string(current_instruction()) << "'\n" << end(); break; } type_ordinal base_type = base.type->value; - long long int offset = ingredients.at(1).at(0); + int offset = ingredients.at(1).at(0); if (offset < 0 || offset >= SIZE(get(Type, base_type).elements)) break; // copied from Check above - long long int result = base_address; - for (long long int i = 0; i < offset; ++i) { + int result = base_address; + for (int i = 0; i < offset; ++i) { // End GET_ADDRESS field Cases result += size_of(element_type(base, i)); } @@ -481,11 +481,11 @@ vector<type_ordinal> Recently_added_types; :(before "End load_permanently") //: for non-tests Recently_added_types.clear(); :(before "End Setup") //: for tests -for (long long int i = 0; i < SIZE(Recently_added_types); ++i) { +for (int i = 0; i < SIZE(Recently_added_types); ++i) { if (!contains_key(Type, Recently_added_types.at(i))) continue; Type_ordinal.erase(get(Type, Recently_added_types.at(i)).name); // todo: why do I explicitly need to provide this? - for (long long int j = 0; j < SIZE(Type.at(Recently_added_types.at(i)).elements); ++j) + for (int j = 0; j < SIZE(Type.at(Recently_added_types.at(i)).elements); ++j) Type.at(Recently_added_types.at(i)).elements.at(j).clear(); Type.erase(Recently_added_types.at(i)); } @@ -540,11 +540,11 @@ Transform.push_back(check_or_set_invalid_types); // idempotent void check_or_set_invalid_types(const recipe_ordinal r) { recipe& caller = get(Recipe, r); trace(9991, "transform") << "--- check for invalid types in recipe " << caller.name << end(); - for (long long int index = 0; index < SIZE(caller.steps); ++index) { + for (int index = 0; index < SIZE(caller.steps); ++index) { instruction& inst = caller.steps.at(index); - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) + for (int i = 0; i < SIZE(inst.ingredients); ++i) check_or_set_invalid_types(inst.ingredients.at(i).type, maybe(caller.name), "'"+to_string(inst)+"'"); - for (long long int i = 0; i < SIZE(inst.products); ++i) + for (int i = 0; i < SIZE(inst.products); ++i) check_or_set_invalid_types(inst.products.at(i).type, maybe(caller.name), "'"+to_string(inst)+"'"); } // End check_or_set_invalid_types @@ -591,7 +591,7 @@ void check_container_field_types() { for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { const type_info& info = p->second; // Check Container Field Types(info) - for (long long int i = 0; i < SIZE(info.elements); ++i) + for (int i = 0; i < SIZE(info.elements); ++i) check_invalid_types(info.elements.at(i).type, maybe(info.name), info.elements.at(i).name); } } @@ -634,8 +634,8 @@ case MERGE: { :(before "End Primitive Recipe Implementations") case MERGE: { products.resize(1); - for (long long int i = 0; i < SIZE(ingredients); ++i) - for (long long int j = 0; j < SIZE(ingredients.at(i)); ++j) + for (int i = 0; i < SIZE(ingredients); ++i) + for (int j = 0; j < SIZE(ingredients.at(i)); ++j) products.at(0).push_back(ingredients.at(i).at(j)); break; } @@ -704,8 +704,8 @@ def main [ :(before "End Types") struct merge_check_point { reagent container; - long long int container_element_index; - merge_check_point(const reagent& c, long long int i) :container(c), container_element_index(i) {} + int container_element_index; + merge_check_point(const reagent& c, int i) :container(c), container_element_index(i) {} }; struct merge_check_state { @@ -718,7 +718,7 @@ Transform.push_back(check_merge_calls); void check_merge_calls(const recipe_ordinal r) { const recipe& caller = get(Recipe, r); trace(9991, "transform") << "--- type-check merge instructions in recipe " << caller.name << end(); - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& inst = caller.steps.at(i); if (inst.name != "merge") continue; if (SIZE(inst.products) != 1) { @@ -742,7 +742,7 @@ void check_merge_calls(const recipe_ordinal r) { } void check_merge_call(const vector<reagent>& ingredients, const reagent& product, const recipe& caller, const instruction& inst) { - long long int ingredient_index = 0; + int ingredient_index = 0; merge_check_state state; state.data.push(merge_check_point(product, 0)); while (true) { diff --git a/031address.cc b/031address.cc index bdce2fe8..0bbe8ab8 100644 --- a/031address.cc +++ b/031address.cc @@ -219,7 +219,7 @@ case _DUMP: { //: grab an address, and then dump its value at intervals //: useful for tracking down memory corruption (writing to an out-of-bounds address) :(before "End Globals") -long long int foo = -1; +int foo = -1; :(before "End Primitive Recipe Declarations") _FOO, :(before "End Primitive Recipe Numbers") diff --git a/032array.cc b/032array.cc index 5d02b82c..b7fa44b0 100644 --- a/032array.cc +++ b/032array.cc @@ -48,14 +48,14 @@ case CREATE_ARRAY: { case CREATE_ARRAY: { reagent product = current_instruction().products.at(0); canonize(product); - long long int base_address = product.value; - long long int array_size = to_integer(product.type->right->right->name); + int base_address = product.value; + int array_size = to_integer(product.type->right->right->name); // initialize array size, so that size_of will work put(Memory, base_address, array_size); // in array elements - long long int size = size_of(product); // in locations + int size = size_of(product); // in locations trace(9998, "run") << "creating array of size " << size << '\n' << end(); // initialize array - for (long long int i = 1; i <= size_of(product); ++i) { + for (int i = 1; i <= size_of(product); ++i) { put(Memory, base_address+i, 0); } // dummy product; doesn't actually do anything @@ -200,7 +200,7 @@ case INDEX: { case INDEX: { reagent base = current_instruction().ingredients.at(0); canonize(base); - long long int base_address = base.value; + int base_address = base.value; trace(9998, "run") << "base address is " << base_address << end(); if (base_address == 0) { raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_string(current_instruction()) << "'\n" << end(); @@ -214,7 +214,7 @@ case INDEX: { raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(offset_val.at(0)) << '\n' << end(); break; } - long long int src = base_address + 1 + offset_val.at(0)*size_of(element_type); + int src = base_address + 1 + offset_val.at(0)*size_of(element_type); trace(9998, "run") << "address to copy is " << src << end(); trace(9998, "run") << "its type is " << get(Type, element_type->value).name << end(); reagent tmp; @@ -345,7 +345,7 @@ case INDEX_ADDRESS: { case INDEX_ADDRESS: { reagent base = current_instruction().ingredients.at(0); canonize(base); - long long int base_address = base.value; + int base_address = base.value; if (base_address == 0) { raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_string(current_instruction()) << "'\n" << end(); break; @@ -358,7 +358,7 @@ case INDEX_ADDRESS: { raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(offset_val.at(0)) << '\n' << end(); break; } - long long int result = base_address + 1 + offset_val.at(0)*size_of(element_type); + int result = base_address + 1 + offset_val.at(0)*size_of(element_type); products.resize(1); products.at(0).push_back(result); break; diff --git a/033exclusive_container.cc b/033exclusive_container.cc index 18c07f3a..453ed82f 100644 --- a/033exclusive_container.cc +++ b/033exclusive_container.cc @@ -34,11 +34,11 @@ def main [ if (t.kind == EXCLUSIVE_CONTAINER) { // size of an exclusive container is the size of its largest variant // (So like containers, it can't contain arrays.) - long long int result = 0; - for (long long int i = 0; i < t.size; ++i) { + int result = 0; + for (int i = 0; i < t.size; ++i) { reagent tmp; tmp.type = new type_tree(*type); - long long int size = size_of(variant_type(tmp, i)); + int size = size_of(variant_type(tmp, i)); if (size > result) result = size; } // ...+1 for its tag. @@ -115,14 +115,14 @@ case MAYBE_CONVERT: { case MAYBE_CONVERT: { reagent base = current_instruction().ingredients.at(0); canonize(base); - long long int base_address = base.value; + int base_address = base.value; if (base_address == 0) { raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_string(current_instruction()) << "'\n" << end(); break; } - long long int tag = current_instruction().ingredients.at(1).value; - long long int result; - if (tag == static_cast<long long int>(get_or_insert(Memory, base_address))) { + int tag = current_instruction().ingredients.at(1).value; + int result; + if (tag == static_cast<int>(get_or_insert(Memory, base_address))) { result = base_address+1; } else { @@ -134,7 +134,7 @@ case MAYBE_CONVERT: { } :(code) -const reagent variant_type(const reagent& canonized_base, long long int tag) { +const reagent variant_type(const reagent& canonized_base, int tag) { assert(tag >= 0); assert(contains_key(Type, canonized_base.type->value)); assert(!get(Type, canonized_base.type->value).name.empty()); diff --git a/034call.cc b/034call.cc index 111c88df..a878caad 100644 --- a/034call.cc +++ b/034call.cc @@ -35,7 +35,7 @@ def f [ // This requires maintaining a 'stack' of interrupted recipes or 'calls'. struct call { recipe_ordinal running_recipe; - long long int running_step_index; + int running_step_index; // End call Fields call(recipe_ordinal r) { running_recipe = r; @@ -74,8 +74,8 @@ inline call& current_call() { //:: now update routine's helpers -:(replace{} "inline long long int& current_step_index()") -inline long long int& current_step_index() { +:(replace{} "inline int& current_step_index()") +inline int& current_step_index() { assert(!Current_routine->calls.empty()); return current_call().running_step_index; } diff --git a/035call_ingredient.cc b/035call_ingredient.cc index 63fa7a62..10672548 100644 --- a/035call_ingredient.cc +++ b/035call_ingredient.cc @@ -23,12 +23,12 @@ def f [ :(before "End call Fields") vector<vector<double> > ingredient_atoms; vector<reagent> ingredients; -long long int next_ingredient_to_process; +int next_ingredient_to_process; :(before "End call Constructor") next_ingredient_to_process = 0; :(before "End Call Housekeeping") -for (long long int i = 0; i < SIZE(ingredients); ++i) { +for (int i = 0; i < SIZE(ingredients); ++i) { current_call().ingredient_atoms.push_back(ingredients.at(i)); reagent ingredient = call_instruction.ingredients.at(i); canonize_type(ingredient); @@ -76,8 +76,8 @@ case NEXT_INGREDIENT: { if (current_instruction().products.empty()) break; products.resize(2); // pad the first product with sufficient zeros to match its type - long long int size = size_of(current_instruction().products.at(0)); - for (long long int i = 0; i < size; ++i) + int size = size_of(current_instruction().products.at(0)); + for (int i = 0; i < size; ++i) products.at(0).push_back(0); products.at(1).push_back(0); } @@ -152,7 +152,7 @@ case INGREDIENT: { } :(before "End Primitive Recipe Implementations") case INGREDIENT: { - if (static_cast<long long int>(ingredients.at(0).at(0)) < SIZE(current_call().ingredient_atoms)) { + if (static_cast<int>(ingredients.at(0).at(0)) < SIZE(current_call().ingredient_atoms)) { current_call().next_ingredient_to_process = ingredients.at(0).at(0); products.push_back( current_call().ingredient_atoms.at(current_call().next_ingredient_to_process)); diff --git a/036call_reply.cc b/036call_reply.cc index 299abf10..f0f37137 100644 --- a/036call_reply.cc +++ b/036call_reply.cc @@ -36,7 +36,7 @@ case REPLY: { // just in case 'main' returns a value, drop it for now if (Current_routine->calls.empty()) goto stop_running_current_routine; const instruction& caller_instruction = current_instruction(); - for (long long int i = 0; i < SIZE(caller_instruction.products); ++i) + for (int i = 0; i < SIZE(caller_instruction.products); ++i) trace(9998, "run") << "result " << i << " is " << to_string(ingredients.at(i)) << end(); // make reply products available to caller @@ -67,13 +67,13 @@ Transform.push_back(check_types_of_reply_instructions); void check_types_of_reply_instructions(recipe_ordinal r) { const recipe& caller = get(Recipe, r); trace(9991, "transform") << "--- check types of reply instructions in recipe " << caller.name << end(); - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& caller_instruction = caller.steps.at(i); if (caller_instruction.is_label) continue; if (caller_instruction.products.empty()) continue; if (caller_instruction.operation < MAX_PRIMITIVE_RECIPES) continue; const recipe& callee = get(Recipe, caller_instruction.operation); - for (long long int i = 0; i < SIZE(callee.steps); ++i) { + for (int i = 0; i < SIZE(callee.steps); ++i) { const instruction& reply_inst = callee.steps.at(i); if (reply_inst.operation != REPLY) continue; // check types with the caller @@ -81,7 +81,7 @@ void check_types_of_reply_instructions(recipe_ordinal r) { raise << maybe(caller.name) << "too few values replied from " << callee.name << '\n' << end(); break; } - for (long long int i = 0; i < SIZE(caller_instruction.products); ++i) { + for (int i = 0; i < SIZE(caller_instruction.products); ++i) { reagent lhs = reply_inst.ingredients.at(i); canonize_type(lhs); reagent rhs = caller_instruction.products.at(i); @@ -94,14 +94,14 @@ void check_types_of_reply_instructions(recipe_ordinal r) { } // check that any reply ingredients with /same-as-ingredient connect up // the corresponding ingredient and product in the caller. - for (long long int i = 0; i < SIZE(caller_instruction.products); ++i) { + for (int i = 0; i < SIZE(caller_instruction.products); ++i) { if (has_property(reply_inst.ingredients.at(i), "same-as-ingredient")) { string_tree* tmp = property(reply_inst.ingredients.at(i), "same-as-ingredient"); if (!tmp || tmp->right) { raise << maybe(caller.name) << "'same-as-ingredient' metadata should take exactly one value in " << to_string(reply_inst) << '\n' << end(); goto finish_reply_check; } - long long int ingredient_index = to_integer(tmp->value); + int ingredient_index = to_integer(tmp->value); if (ingredient_index >= SIZE(caller_instruction.ingredients)) { raise << maybe(caller.name) << "too few ingredients in '" << to_string(caller_instruction) << "'\n" << end(); goto finish_reply_check; @@ -166,7 +166,7 @@ string to_string(const vector<double>& in) { return out.str(); } out << "["; - for (long long int i = 0; i < SIZE(in); ++i) { + for (int i = 0; i < SIZE(in); ++i) { if (i > 0) out << ", "; out << no_scientific(in.at(i)); } diff --git a/037new.cc b/037new.cc index 671a6aca..d7daa397 100644 --- a/037new.cc +++ b/037new.cc @@ -55,13 +55,13 @@ def main [ +mem: storing 0 in location 3 :(before "End Globals") -long long int Memory_allocated_until = Reserved_for_tests; -long long int Initial_memory_per_routine = 100000; +int Memory_allocated_until = Reserved_for_tests; +int Initial_memory_per_routine = 100000; :(before "End Setup") Memory_allocated_until = Reserved_for_tests; Initial_memory_per_routine = 100000; :(before "End routine Fields") -long long int alloc, alloc_max; +int alloc, alloc_max; :(before "End routine Constructor") alloc = Memory_allocated_until; Memory_allocated_until += Initial_memory_per_routine; @@ -125,7 +125,7 @@ Transform.push_back(transform_new_to_allocate); // idempotent :(code) void transform_new_to_allocate(const recipe_ordinal r) { trace(9991, "transform") << "--- convert 'new' to 'allocate' for recipe " << get(Recipe, r).name << end(); - for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { + for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { instruction& inst = get(Recipe, r).steps.at(i); // Convert 'new' To 'allocate' if (inst.name == "new") { @@ -150,7 +150,7 @@ put(Recipe_ordinal, "allocate", ALLOCATE); :(before "End Primitive Recipe Implementations") case ALLOCATE: { // compute the space we need - long long int size = ingredients.at(0).at(0); + int size = ingredients.at(0).at(0); if (SIZE(ingredients) > 1) { // array trace(9999, "mem") << "array size is " << ingredients.at(1).at(0) << end(); @@ -164,13 +164,13 @@ case ALLOCATE: { // compute the region of memory to return // really crappy at the moment ensure_space(size); - const long long int result = Current_routine->alloc; + const int result = Current_routine->alloc; trace(9999, "mem") << "new alloc: " << result << end(); // save result products.resize(1); products.at(0).push_back(result); // initialize allocated space - for (long long int address = result; address < result+size; ++address) + for (int address = result; address < result+size; ++address) put(Memory, address, 0); // initialize array length if (SIZE(current_instruction().ingredients) > 1) { @@ -199,10 +199,10 @@ case NEW: { } //? :(before "End Globals") -//? long long int Total_alloc = 0; -//? long long int Num_alloc = 0; -//? long long int Total_free = 0; -//? long long int Num_free = 0; +//? int Total_alloc = 0; +//? int Num_alloc = 0; +//? int Total_free = 0; +//? int Num_free = 0; //? :(before "End Setup") //? Total_alloc = Num_alloc = Total_free = Num_free = 0; //? :(before "End Teardown") @@ -211,7 +211,7 @@ case NEW: { //? cerr << SIZE(Memory) << '\n'; :(code) -void ensure_space(long long int size) { +void ensure_space(int size) { if (size > Initial_memory_per_routine) { tb_shutdown(); cerr << "can't allocate " << size << " locations, that's too much compared to " << Initial_memory_per_routine << ".\n"; @@ -289,7 +289,7 @@ def main [ +mem: storing 1 in location 4 :(before "End Globals") -map<long long int, long long int> Free_list; +map<int, int> Free_list; :(before "End Setup") Free_list.clear(); @@ -313,14 +313,14 @@ case ABANDON: { } :(before "End Primitive Recipe Implementations") case ABANDON: { - long long int address = ingredients.at(0).at(0); + int address = ingredients.at(0).at(0); trace(9999, "abandon") << "address to abandon is " << address << end(); reagent types = current_instruction().ingredients.at(0); trace(9999, "abandon") << "value of ingredient is " << types.value << end(); canonize(types); // lookup_memory without drop_one_lookup { trace(9999, "abandon") << "value of ingredient after canonization is " << types.value << end(); - long long int address_location = types.value; + int address_location = types.value; types.set_value(get_or_insert(Memory, types.value)+/*skip refcount*/1); drop_from_type(types, "address"); drop_from_type(types, "shared"); @@ -333,13 +333,13 @@ case ABANDON: { } :(code) -void abandon(long long int address, long long int size) { +void abandon(int address, int size) { trace(9999, "abandon") << "saving in free-list of size " << size << end(); //? Total_free += size; //? Num_free++; //? cerr << "abandon: " << size << '\n'; // clear memory - for (long long int curr = address; curr < address+size; ++curr) + for (int curr = address; curr < address+size; ++curr) put(Memory, curr, 0); // append existing free list to address put(Memory, address, get_or_insert(Free_list, size)); @@ -349,9 +349,9 @@ void abandon(long long int address, long long int size) { :(before "ensure_space(size)" following "case ALLOCATE") if (get_or_insert(Free_list, size)) { trace(9999, "abandon") << "picking up space from free-list of size " << size << end(); - long long int result = get_or_insert(Free_list, size); + int result = get_or_insert(Free_list, size); put(Free_list, size, get_or_insert(Memory, result)); - for (long long int curr = result+1; curr < result+size; ++curr) { + for (int curr = result+1; curr < result+size; ++curr) { if (get_or_insert(Memory, curr) != 0) { raise << maybe(current_recipe_name()) << "memory in free list was not zeroed out: " << curr << '/' << result << "; somebody wrote to us after free!!!\n" << end(); break; // always fatal @@ -422,12 +422,12 @@ if (x.type->value == get(Type_ordinal, "address") && x.type->right && x.type->right->value == get(Type_ordinal, "shared")) { // compute old address of x, as well as new address we want to write in - long long int old_address = get_or_insert(Memory, x.value); + int old_address = get_or_insert(Memory, x.value); assert(scalar(data)); - long long int new_address = data.at(0); + int new_address = data.at(0); // decrement refcount of old address if (old_address) { - long long int old_refcount = get_or_insert(Memory, old_address); + int old_refcount = get_or_insert(Memory, old_address); trace(9999, "mem") << "decrementing refcount of " << old_address << ": " << old_refcount << " -> " << (old_refcount-1) << end(); put(Memory, old_address, old_refcount-1); } @@ -436,7 +436,7 @@ if (x.type->value == get(Type_ordinal, "address") put(Memory, x.value, new_address); // increment refcount of new address if (new_address) { - long long int new_refcount = get_or_insert(Memory, new_address); + int new_refcount = get_or_insert(Memory, new_address); assert(new_refcount >= 0); // == 0 only when new_address == old_address trace(9999, "mem") << "incrementing refcount of " << new_address << ": " << new_refcount << " -> " << (new_refcount+1) << end(); put(Memory, new_address, new_refcount+1); @@ -567,21 +567,21 @@ if (inst.name == "new" && is_literal_string(inst.ingredients.at(0))) continue; } :(code) -long long int new_mu_string(const string& contents) { +int new_mu_string(const string& contents) { // allocate an array just large enough for it - long long int string_length = unicode_length(contents); + int string_length = unicode_length(contents); //? Total_alloc += string_length+1; //? Num_alloc++; ensure_space(string_length+1); // don't forget the extra location for array size // initialize string - long long int result = Current_routine->alloc; + int result = Current_routine->alloc; // initialize refcount put(Memory, Current_routine->alloc++, 0); // store length put(Memory, Current_routine->alloc++, string_length); - long long int curr = 0; + int curr = 0; const char* raw_contents = contents.c_str(); - for (long long int i = 0; i < string_length; ++i) { + for (int i = 0; i < string_length; ++i) { uint32_t curr_character; assert(curr < SIZE(contents)); tb_utf8_char_to_unicode(&curr_character, &raw_contents[curr]); @@ -634,10 +634,10 @@ def main [ //: helpers :(code) -long long int unicode_length(const string& s) { +int unicode_length(const string& s) { const char* in = s.c_str(); - long long int result = 0; - long long int curr = 0; + int result = 0; + int curr = 0; while (curr < SIZE(s)) { // carefully bounds-check on the string // before accessing its raw pointer ++result; @@ -646,13 +646,13 @@ long long int unicode_length(const string& s) { return result; } -string read_mu_string(long long int address) { +string read_mu_string(int address) { if (address == 0) return ""; address++; // skip refcount - long long int size = get_or_insert(Memory, address); + int size = get_or_insert(Memory, address); if (size == 0) return ""; ostringstream tmp; - for (long long int curr = address+1; curr <= address+size; ++curr) { + for (int curr = address+1; curr <= address+size; ++curr) { tmp << to_unicode(static_cast<uint32_t>(get_or_insert(Memory, curr))); } return tmp.str(); diff --git a/038location_array.cc b/038location_array.cc index 2353a79c..543a384d 100644 --- a/038location_array.cc +++ b/038location_array.cc @@ -25,10 +25,10 @@ bool is_shared_address_of_array_of_numbers(reagent product) { } :(before "End Primitive Recipe Implementations") case TO_LOCATION_ARRAY: { - long long int array_size = SIZE(ingredients.at(0)); - long long int allocation_size = array_size + /*refcount*/1 + /*length*/1; + int array_size = SIZE(ingredients.at(0)); + int allocation_size = array_size + /*refcount*/1 + /*length*/1; ensure_space(allocation_size); - const long long int result = Current_routine->alloc; + const int result = Current_routine->alloc; products.resize(1); products.at(0).push_back(result); // initialize array refcount @@ -36,7 +36,7 @@ case TO_LOCATION_ARRAY: { // initialize array length put(Memory, result+1, array_size); // now copy over data - for (long long int i = 0; i < array_size; ++i) + for (int i = 0; i < array_size; ++i) put(Memory, result+2+i, ingredients.at(0).at(i)); break; } diff --git a/040brace.cc b/040brace.cc index d9d60078..2c4598e0 100644 --- a/040brace.cc +++ b/040brace.cc @@ -38,22 +38,22 @@ Transform.push_back(transform_braces); // idempotent void transform_braces(const recipe_ordinal r) { const int OPEN = 0, CLOSE = 1; // use signed integer for step index because we'll be doing arithmetic on it - list<pair<int/*OPEN/CLOSE*/, /*step*/long long int> > braces; + list<pair<int/*OPEN/CLOSE*/, /*step*/int> > braces; trace(9991, "transform") << "--- transform braces for recipe " << get(Recipe, r).name << end(); //? cerr << "--- transform braces for recipe " << get(Recipe, r).name << '\n'; - for (long long int index = 0; index < SIZE(get(Recipe, r).steps); ++index) { + for (int index = 0; index < SIZE(get(Recipe, r).steps); ++index) { const instruction& inst = get(Recipe, r).steps.at(index); if (inst.label == "{") { trace(9993, "transform") << maybe(get(Recipe, r).name) << "push (open, " << index << ")" << end(); - braces.push_back(pair<int,long long int>(OPEN, index)); + braces.push_back(pair<int,int>(OPEN, index)); } if (inst.label == "}") { trace(9993, "transform") << "push (close, " << index << ")" << end(); - braces.push_back(pair<int,long long int>(CLOSE, index)); + braces.push_back(pair<int,int>(CLOSE, index)); } } - stack</*step*/long long int> open_braces; - for (long long int index = 0; index < SIZE(get(Recipe, r).steps); ++index) { + stack</*step*/int> open_braces; + for (int index = 0; index < SIZE(get(Recipe, r).steps); ++index) { instruction& inst = get(Recipe, r).steps.at(index); if (inst.label == "{") { open_braces.push(index); @@ -133,9 +133,9 @@ void transform_braces(const recipe_ordinal r) { // returns a signed integer not just so that we can return -1 but also to // enable future signed arithmetic -long long int matching_brace(long long int index, const list<pair<int, long long int> >& braces, recipe_ordinal r) { +int matching_brace(int index, const list<pair<int, int> >& braces, recipe_ordinal r) { int stacksize = 0; - for (list<pair<int, long long int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) { + for (list<pair<int, int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) { if (p->second < index) continue; stacksize += (p->first ? 1 : -1); if (stacksize == 0) return p->second; diff --git a/041jump_target.cc b/041jump_target.cc index f58ff3d1..1976084d 100644 --- a/041jump_target.cc +++ b/041jump_target.cc @@ -23,8 +23,8 @@ Transform.push_back(transform_labels); // idempotent :(code) void transform_labels(const recipe_ordinal r) { - map<string, long long int> offset; - for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { + map<string, int> offset; + for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { const instruction& inst = get(Recipe, r).steps.at(i); if (!inst.label.empty() && inst.label.at(0) == '+') { if (!contains_key(offset, inst.label)) { @@ -37,7 +37,7 @@ void transform_labels(const recipe_ordinal r) { } } } - for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { + for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { instruction& inst = get(Recipe, r).steps.at(i); if (inst.name == "jump") { if (inst.ingredients.empty()) { @@ -66,7 +66,7 @@ void transform_labels(const recipe_ordinal r) { } :(code) -void replace_offset(reagent& x, /*const*/ map<string, long long int>& offset, const long long int current_offset, const recipe_ordinal r) { +void replace_offset(reagent& x, /*const*/ map<string, int>& offset, const int current_offset, const recipe_ordinal r) { if (!is_literal(x)) { raise << maybe(get(Recipe, r).name) << "jump target must be offset or label but is " << x.original_string << '\n' << end(); x.set_value(0); // no jump by default diff --git a/042name.cc b/042name.cc index 1e386db4..46e3a816 100644 --- a/042name.cc +++ b/042name.cc @@ -22,9 +22,9 @@ def main [ Transform.push_back(transform_names); // idempotent :(before "End Globals") -map<recipe_ordinal, map<string, long long int> > Name; +map<recipe_ordinal, map<string, int> > Name; :(after "Clear Other State For Recently_added_recipes") -for (long long int i = 0; i < SIZE(Recently_added_recipes); ++i) { +for (int i = 0; i < SIZE(Recently_added_recipes); ++i) { Name.erase(Recently_added_recipes.at(i)); } @@ -35,15 +35,15 @@ void transform_names(const recipe_ordinal r) { //? cerr << "--- transform names for recipe " << caller.name << '\n'; bool names_used = false; bool numeric_locations_used = false; - map<string, long long int>& names = Name[r]; + map<string, int>& names = Name[r]; // store the indices 'used' so far in the map - long long int& curr_idx = names[""]; + int& curr_idx = names[""]; ++curr_idx; // avoid using index 0, benign skip in some other cases - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { instruction& inst = caller.steps.at(i); // End transform_names(inst) Special-cases // map names to addresses - for (long long int in = 0; in < SIZE(inst.ingredients); ++in) { + for (int in = 0; in < SIZE(inst.ingredients); ++in) { if (is_disqualified(inst.ingredients.at(in), inst, caller.name)) continue; if (is_numeric_location(inst.ingredients.at(in))) numeric_locations_used = true; if (is_named_location(inst.ingredients.at(in))) names_used = true; @@ -51,7 +51,7 @@ void transform_names(const recipe_ordinal r) { if (!already_transformed(inst.ingredients.at(in), names)) { raise << maybe(caller.name) << "use before set: " << inst.ingredients.at(in).name << '\n' << end(); } - long long int v = lookup_name(inst.ingredients.at(in), r); + int v = lookup_name(inst.ingredients.at(in), r); if (v >= 0) { inst.ingredients.at(in).set_value(v); } @@ -60,7 +60,7 @@ void transform_names(const recipe_ordinal r) { return; } } - for (long long int out = 0; out < SIZE(inst.products); ++out) { + for (int out = 0; out < SIZE(inst.products); ++out) { if (is_disqualified(inst.products.at(out), inst, caller.name)) continue; if (is_numeric_location(inst.products.at(out))) numeric_locations_used = true; if (is_named_location(inst.products.at(out))) names_used = true; @@ -70,7 +70,7 @@ void transform_names(const recipe_ordinal r) { names[inst.products.at(out).name] = curr_idx; curr_idx += size_of(inst.products.at(out)); } - long long int v = lookup_name(inst.products.at(out), r); + int v = lookup_name(inst.products.at(out), r); if (v >= 0) { inst.products.at(out).set_value(v); } @@ -97,11 +97,11 @@ bool is_disqualified(/*mutable*/ reagent& x, const instruction& inst, const stri return false; } -bool already_transformed(const reagent& r, const map<string, long long int>& names) { +bool already_transformed(const reagent& r, const map<string, int>& names) { return contains_key(names, r.name); } -long long int lookup_name(const reagent& r, const recipe_ordinal default_recipe) { +int lookup_name(const reagent& r, const recipe_ordinal default_recipe) { return Name[default_recipe][r.name]; } @@ -118,7 +118,7 @@ type_ordinal skip_addresses(type_tree* type, const string& recipe_name) { int find_element_name(const type_ordinal t, const string& name, const string& recipe_name) { const type_info& container = get(Type, t); - for (long long int i = 0; i < SIZE(container.elements); ++i) + for (int i = 0; i < SIZE(container.elements); ++i) if (container.elements.at(i).name == name) return i; raise << maybe(recipe_name) << "unknown element " << name << " in container " << get(Type, t).name << '\n' << end(); return -1; diff --git a/043space.cc b/043space.cc index cd91bd8d..c65f456f 100644 --- a/043space.cc +++ b/043space.cc @@ -45,7 +45,7 @@ if (s == "default-space") return true; //:: now implement space support :(before "End call Fields") -long long int default_space; +int default_space; :(before "End call Constructor") default_space = 0; @@ -63,15 +63,15 @@ void absolutize(reagent& x) { assert(is_raw(x)); } -long long int space_base(const reagent& x) { +int space_base(const reagent& x) { // temporary stub; will be replaced in a later layer return current_call().default_space ? (current_call().default_space+/*skip refcount*/1) : 0; } -long long int address(long long int offset, long long int base) { +int address(int offset, int base) { assert(offset >= 0); if (base == 0) return offset; // raw - long long int size = get_or_insert(Memory, base); + int size = get_or_insert(Memory, base); if (offset >= size) { // todo: test raise << "location " << offset << " is out of bounds " << size << " at " << base << '\n' << end(); @@ -242,9 +242,9 @@ void try_reclaim_locals() { // reclaim any local variables unless they're being returned vector<double> zero; zero.push_back(0); - for (long long int i = /*leave default space for last*/1; i < SIZE(exiting_recipe.steps); ++i) { + for (int i = /*leave default space for last*/1; i < SIZE(exiting_recipe.steps); ++i) { const instruction& inst = exiting_recipe.steps.at(i); - for (long long int i = 0; i < SIZE(inst.products); ++i) { + for (int i = 0; i < SIZE(inst.products); ++i) { if (!is_mu_address(inst.products.at(i))) continue; // local variables only if (has_property(inst.products.at(i), "space")) continue; @@ -312,7 +312,7 @@ Hide_missing_default_space_errors = false; :(code) bool contains_non_special_name(const recipe_ordinal r) { - for (map<string, long long int>::iterator p = Name[r].begin(); p != Name[r].end(); ++p) { + for (map<string, int>::iterator p = Name[r].begin(); p != Name[r].end(); ++p) { if (p->first.empty()) continue; if (p->first.find("stash_") == 0) continue; // generated by rewrite_stashes_to_text (cross-layer) if (!is_special_name(p->first)) @@ -329,7 +329,7 @@ bool operator==(const reagent& a, const reagent& b) { } bool operator<(const reagent& a, const reagent& b) { - long long int aspace = 0, bspace = 0; + int aspace = 0, bspace = 0; if (has_property(a, "space")) aspace = to_integer(property(a, "space")->value); if (has_property(b, "space")) bspace = to_integer(property(b, "space")->value); if (aspace != bspace) return aspace < bspace; diff --git a/044space_surround.cc b/044space_surround.cc index 7d16bfbd..2231860e 100644 --- a/044space_surround.cc +++ b/044space_surround.cc @@ -32,21 +32,21 @@ def dummy [ # just for the /names: property above //: lifetime, surrounding allows managing shorter lifetimes inside a longer //: one. -:(replace{} "long long int space_base(const reagent& x)") -long long int space_base(const reagent& x) { - long long int base = current_call().default_space ? (current_call().default_space+/*skip refcount*/1) : 0; +:(replace{} "int space_base(const reagent& x)") +int space_base(const reagent& x) { + int base = current_call().default_space ? (current_call().default_space+/*skip refcount*/1) : 0; return space_base(x, space_index(x), base); } -long long int space_base(const reagent& x, long long int space_index, long long int base) { +int space_base(const reagent& x, int space_index, int base) { if (space_index == 0) return base; - long long int result = space_base(x, space_index-1, get_or_insert(Memory, base+/*skip length*/1))+/*skip refcount*/1; + int result = space_base(x, space_index-1, get_or_insert(Memory, base+/*skip length*/1))+/*skip refcount*/1; return result; } -long long int space_index(const reagent& x) { - for (long long int i = 0; i < SIZE(x.properties); ++i) { +int space_index(const reagent& x) { + for (int i = 0; i < SIZE(x.properties); ++i) { if (x.properties.at(i).first == "space") { if (!x.properties.at(i).second || x.properties.at(i).second->right) raise << maybe(current_recipe_name()) << "/space metadata should take exactly one value in " << x.original_string << '\n' << end(); diff --git a/045closure_name.cc b/045closure_name.cc index 33ab8c07..23b10f0c 100644 --- a/045closure_name.cc +++ b/045closure_name.cc @@ -42,10 +42,10 @@ Transform.push_back(collect_surrounding_spaces); // idempotent void collect_surrounding_spaces(const recipe_ordinal r) { trace(9991, "transform") << "--- collect surrounding spaces for recipe " << get(Recipe, r).name << end(); //? cerr << "--- collect surrounding spaces for recipe " << get(Recipe, r).name << '\n'; - for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { + for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { const instruction& inst = get(Recipe, r).steps.at(i); if (inst.is_label) continue; - for (long long int j = 0; j < SIZE(inst.products); ++j) { + for (int j = 0; j < SIZE(inst.products); ++j) { if (is_literal(inst.products.at(j))) continue; if (inst.products.at(j).name != "0") continue; type_tree* type = inst.products.at(j).type; @@ -90,15 +90,15 @@ void collect_surrounding_spaces(const recipe_ordinal r) { //: Once surrounding spaces are available, transform_names uses them to handle //: /space properties. -:(replace{} "long long int lookup_name(const reagent& r, const recipe_ordinal default_recipe)") -long long int lookup_name(const reagent& x, const recipe_ordinal default_recipe) { +:(replace{} "int lookup_name(const reagent& r, const recipe_ordinal default_recipe)") +int lookup_name(const reagent& x, const recipe_ordinal default_recipe) { if (!has_property(x, "space")) { if (Name[default_recipe].empty()) raise << "name not found: " << x.name << '\n' << end(); return Name[default_recipe][x.name]; } string_tree* p = property(x, "space"); if (!p || p->right) raise << "/space property should have exactly one (non-negative integer) value\n" << end(); - long long int n = to_integer(p->value); + int n = to_integer(p->value); assert(n >= 0); recipe_ordinal surrounding_recipe = lookup_surrounding_recipe(default_recipe, n); if (surrounding_recipe == -1) return -1; @@ -109,11 +109,11 @@ long long int lookup_name(const reagent& x, const recipe_ordinal default_recipe) // If the recipe we need to lookup this name in doesn't have names done yet, // recursively call transform_names on it. -long long int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_ordinal>& done, vector<recipe_ordinal>& path) { +int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_ordinal>& done, vector<recipe_ordinal>& path) { if (!Name[r].empty()) return Name[r][x.name]; if (contains_key(done, r)) { raise << "can't compute address of " << to_string(x) << " because " << end(); - for (long long int i = 1; i < SIZE(path); ++i) { + for (int i = 1; i < SIZE(path); ++i) { raise << path.at(i-1) << " requires computing names of " << path.at(i) << '\n' << end(); } raise << path.at(SIZE(path)-1) << " requires computing names of " << r << "..ad infinitum\n" << end(); @@ -126,7 +126,7 @@ long long int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_o return Name[r][x.name]; } -recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, long long int n) { +recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, int n) { if (n == 0) return r; if (!contains_key(Surrounding_space, r)) { raise << "don't know surrounding recipe of " << get(Recipe, r).name << '\n' << end(); @@ -137,8 +137,8 @@ recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, long long int n } //: weaken use-before-set detection just a tad -:(replace{} "bool already_transformed(const reagent& r, const map<string, long long int>& names)") -bool already_transformed(const reagent& r, const map<string, long long int>& names) { +:(replace{} "bool already_transformed(const reagent& r, const map<string, int>& names)") +bool already_transformed(const reagent& r, const map<string, int>& names) { if (has_property(r, "space")) { string_tree* p = property(r, "space"); if (!p || p->right) { diff --git a/046global.cc b/046global.cc index 2bd123ec..0a5878cf 100644 --- a/046global.cc +++ b/046global.cc @@ -37,7 +37,7 @@ if (s == "global-space") return true; //: writes to this variable go to a field in the current routine :(before "End routine Fields") -long long int global_space; +int global_space; :(before "End routine Constructor") global_space = 0; :(after "void write_memory(reagent x, const vector<double>& data)") @@ -61,7 +61,7 @@ global_space = 0; } //: now marking variables as /space:global looks them up inside this field -:(after "long long int space_base(const reagent& x)") +:(after "int space_base(const reagent& x)") if (is_global(x)) { if (!Current_routine->global_space) raise << "routine has no global space\n" << end(); @@ -87,7 +87,7 @@ $error: 0 :(code) bool is_global(const reagent& x) { - for (long long int i = 0; i < SIZE(x.properties); ++i) { + for (int i = 0; i < SIZE(x.properties); ++i) { if (x.properties.at(i).first == "space") return x.properties.at(i).second && x.properties.at(i).second->value == "global"; } diff --git a/047check_type_by_name.cc b/047check_type_by_name.cc index 98214f8a..a1970915 100644 --- a/047check_type_by_name.cc +++ b/047check_type_by_name.cc @@ -22,13 +22,13 @@ void check_or_set_types_by_name(const recipe_ordinal r) { trace(9991, "transform") << "--- deduce types for recipe " << get(Recipe, r).name << end(); recipe& caller = get(Recipe, r); set<reagent> known; - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { instruction& inst = caller.steps.at(i); - for (long long int in = 0; in < SIZE(inst.ingredients); ++in) { + for (int in = 0; in < SIZE(inst.ingredients); ++in) { deduce_missing_type(known, inst.ingredients.at(in)); check_type(known, inst.ingredients.at(in), r); } - for (long long int out = 0; out < SIZE(inst.products); ++out) { + for (int out = 0; out < SIZE(inst.products); ++out) { deduce_missing_type(known, inst.products.at(out)); check_type(known, inst.products.at(out), r); } diff --git a/050scenario.cc b/050scenario.cc index 3257352f..3e69a7a0 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -107,14 +107,14 @@ scenario foo [ //: Treat the text of the scenario as a regular series of instructions. :(before "End Globals") -long long int Num_core_mu_tests = 0; +int Num_core_mu_tests = 0; :(after "Check For .mu Files") Num_core_mu_tests = SIZE(Scenarios); :(before "End Tests") Hide_missing_default_space_errors = false; time_t mu_time; time(&mu_time); cerr << "\nMu tests: " << ctime(&mu_time); -for (long long int i = 0; i < SIZE(Scenarios); ++i) { +for (int i = 0; i < SIZE(Scenarios); ++i) { //? cerr << i << ": " << Scenarios.at(i).name << '\n'; if (i == Num_core_mu_tests) { time(&t); @@ -126,7 +126,7 @@ for (long long int i = 0; i < SIZE(Scenarios); ++i) { //: Convenience: run a single named scenario. :(after "Test Runs") -for (long long int i = 0; i < SIZE(Scenarios); ++i) { +for (int i = 0; i < SIZE(Scenarios); ++i) { if (Scenarios.at(i).name == argv[argc-1]) { run_mu_scenario(Scenarios.at(i)); if (Passed) cerr << ".\n"; @@ -280,7 +280,7 @@ case MEMORY_SHOULD_CONTAIN: { void check_memory(const string& s) { istringstream in(s); in >> std::noskipws; - set<long long int> locations_checked; + set<int> locations_checked; while (true) { skip_whitespace_and_comments(in); if (!has_data(in)) break; @@ -289,7 +289,7 @@ void check_memory(const string& s) { check_type(lhs, in); continue; } - long long int address = to_integer(lhs); + int address = to_integer(lhs); skip_whitespace_and_comments(in); string _assign; in >> _assign; assert(_assign == "<-"); skip_whitespace_and_comments(in); @@ -341,7 +341,7 @@ void check_type(const string& lhs, istream& in) { assert(_assign == "<-"); skip_whitespace_and_comments(in); string literal = next_word(in); - long long int address = x.value; + int address = x.value; // exclude quoting brackets assert(*literal.begin() == '['); literal.erase(literal.begin()); assert(*--literal.end() == ']'); literal.erase(--literal.end()); @@ -352,7 +352,7 @@ void check_type(const string& lhs, istream& in) { raise << "don't know how to check memory for " << lhs << '\n' << end(); } -void check_string(long long int address, const string& literal) { +void check_string(int address, const string& literal) { trace(9999, "run") << "checking string length at " << address << end(); if (get_or_insert(Memory, address) != SIZE(literal)) { if (Current_scenario && !Scenario_testing_scenario) @@ -366,7 +366,7 @@ void check_string(long long int address, const string& literal) { return; } ++address; // now skip length - for (long long int i = 0; i < SIZE(literal); ++i) { + for (int i = 0; i < SIZE(literal); ++i) { trace(9999, "run") << "checking location " << address+i << end(); if (get_or_insert(Memory, address+i) != literal.at(i)) { if (Current_scenario && !Scenario_testing_scenario) { @@ -486,7 +486,7 @@ void check_trace(const string& expected) { Trace_stream->newline(); vector<trace_line> expected_lines = parse_trace(expected); if (expected_lines.empty()) return; - long long int curr_expected_line = 0; + int curr_expected_line = 0; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (expected_lines.at(curr_expected_line).label != p->label) continue; if (expected_lines.at(curr_expected_line).contents != trim(p->contents)) continue; @@ -503,10 +503,10 @@ void check_trace(const string& expected) { vector<trace_line> parse_trace(const string& expected) { vector<string> buf = split(expected, "\n"); vector<trace_line> result; - for (long long int i = 0; i < SIZE(buf); ++i) { + for (int i = 0; i < SIZE(buf); ++i) { buf.at(i) = trim(buf.at(i)); if (buf.at(i).empty()) continue; - long long int delim = buf.at(i).find(": "); + int delim = buf.at(i).find(": "); result.push_back(trace_line(trim(buf.at(i).substr(0, delim)), trim(buf.at(i).substr(delim+2)))); } return result; @@ -577,7 +577,7 @@ case TRACE_SHOULD_NOT_CONTAIN: { bool check_trace_missing(const string& in) { Trace_stream->newline(); vector<trace_line> lines = parse_trace(in); - for (long long int i = 0; i < SIZE(lines); ++i) { + for (int i = 0; i < SIZE(lines); ++i) { if (trace_count(lines.at(i).label, lines.at(i).contents) != 0) { raise << "unexpected [" << lines.at(i).contents << "] in trace with label " << lines.at(i).label << '\n' << end(); Passed = false; @@ -642,9 +642,9 @@ case CHECK_TRACE_COUNT_FOR_LABEL: { :(before "End Primitive Recipe Implementations") case CHECK_TRACE_COUNT_FOR_LABEL: { if (!Passed) break; - long long int expected_count = ingredients.at(0).at(0); + int expected_count = ingredients.at(0).at(0); string label = current_instruction().ingredients.at(1).name; - long long int count = trace_count(label); + int count = trace_count(label); if (count != expected_count) { if (Current_scenario && !Scenario_testing_scenario) { // genuine test in a mu file diff --git a/052tangle.cc b/052tangle.cc index f06ea4c0..9c64bd00 100644 --- a/052tangle.cc +++ b/052tangle.cc @@ -68,12 +68,12 @@ tangle_done = false; :(code) void insert_fragments(const recipe_ordinal r) { bool made_progress = true; - long long int pass = 0; + int pass = 0; while (made_progress) { made_progress = false; // create a new vector because insertions invalidate iterators vector<instruction> result; - for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { + for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { const instruction& inst = get(Recipe, r).steps.at(i); if (!inst.is_label || !is_waypoint(inst.label) || inst.tangle_done) { result.push_back(inst); @@ -105,12 +105,12 @@ void append_fragment(vector<instruction>& base, const vector<instruction>& patch // so we'll keep jump targets local to the specific before/after fragment // that introduces them. set<string> jump_targets; - for (long long int i = 0; i < SIZE(patch); ++i) { + for (int i = 0; i < SIZE(patch); ++i) { const instruction& inst = patch.at(i); if (inst.is_label && is_jump_target(inst.label)) jump_targets.insert(inst.label); } - for (long long int i = 0; i < SIZE(patch); ++i) { + for (int i = 0; i < SIZE(patch); ++i) { instruction inst = patch.at(i); if (inst.is_label) { if (contains_key(jump_targets, inst.label)) @@ -118,7 +118,7 @@ void append_fragment(vector<instruction>& base, const vector<instruction>& patch base.push_back(inst); continue; } - for (long long int j = 0; j < SIZE(inst.ingredients); ++j) { + for (int j = 0; j < SIZE(inst.ingredients); ++j) { reagent& x = inst.ingredients.at(j); if (!is_literal(x)) continue; if (x.type->name == "label" && contains_key(jump_targets, x.name)) diff --git a/053rewrite_stash.cc b/053rewrite_stash.cc index 40cb784f..9ce044a8 100644 --- a/053rewrite_stash.cc +++ b/053rewrite_stash.cc @@ -14,12 +14,12 @@ void rewrite_stashes_to_text(recipe_ordinal r) { } bool contains_named_locations(const recipe& caller) { - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& inst = caller.steps.at(i); - for (long long int in = 0; in < SIZE(inst.ingredients); ++in) + for (int in = 0; in < SIZE(inst.ingredients); ++in) if (is_named_location(inst.ingredients.at(in))) return true; - for (long long int out = 0; out < SIZE(inst.products); ++out) + for (int out = 0; out < SIZE(inst.products); ++out) if (is_named_location(inst.products.at(out))) return true; } @@ -27,12 +27,12 @@ bool contains_named_locations(const recipe& caller) { } void rewrite_stashes_to_text_named(recipe& caller) { - static long long int stash_instruction_idx = 0; + static int stash_instruction_idx = 0; vector<instruction> new_instructions; - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { instruction& inst = caller.steps.at(i); if (inst.name == "stash") { - for (long long int j = 0; j < SIZE(inst.ingredients); ++j) { + for (int j = 0; j < SIZE(inst.ingredients); ++j) { if (is_literal(inst.ingredients.at(j))) continue; if (is_mu_string(inst.ingredients.at(j))) continue; instruction def; diff --git a/054dilated_reagent.cc b/054dilated_reagent.cc index 71554ae2..8e141a43 100644 --- a/054dilated_reagent.cc +++ b/054dilated_reagent.cc @@ -44,7 +44,7 @@ if (start_of_dilated_reagent(in)) // reagents should remain all on one line. bool start_of_dilated_reagent(istream& in) { if (in.peek() != '{') return false; - long long int pos = in.tellg(); + int pos = in.tellg(); in.get(); // slurp '{' skip_whitespace_but_not_newline(in); char next = in.peek(); diff --git a/056recipe_header.cc b/056recipe_header.cc index dfe05167..d6caf76b 100644 --- a/056recipe_header.cc +++ b/056recipe_header.cc @@ -101,10 +101,10 @@ def main # comment :(after "Begin debug_string(recipe x)") out << "ingredients:\n"; -for (long long int i = 0; i < SIZE(x.ingredients); ++i) +for (int i = 0; i < SIZE(x.ingredients); ++i) out << " " << debug_string(x.ingredients.at(i)) << '\n'; out << "products:\n"; -for (long long int i = 0; i < SIZE(x.products); ++i) +for (int i = 0; i < SIZE(x.products); ++i) out << " " << debug_string(x.products.at(i)) << '\n'; //: If a recipe never mentions any ingredients or products, assume it has a header. @@ -118,7 +118,7 @@ def test [ :(before "End Recipe Body(result)") if (!result.has_header) { result.has_header = true; - for (long long int i = 0; i < SIZE(result.steps); ++i) { + for (int i = 0; i < SIZE(result.steps); ++i) { const instruction& inst = result.steps.at(i); if ((inst.name == "reply" && !inst.ingredients.empty()) || (inst.name == "return" && !inst.ingredients.empty()) @@ -140,7 +140,7 @@ if (result.has_header) { if (curr.name == "load-ingredients") { curr.clear(); recipe_ordinal op = get(Recipe_ordinal, "next-ingredient-without-typechecking"); - for (long long int i = 0; i < SIZE(result.ingredients); ++i) { + for (int i = 0; i < SIZE(result.ingredients); ++i) { curr.operation = op; curr.name = "next-ingredient-without-typechecking"; curr.products.push_back(result.ingredients.at(i)); @@ -171,8 +171,8 @@ case NEXT_INGREDIENT_WITHOUT_TYPECHECKING: { else { products.resize(2); // pad the first product with sufficient zeros to match its type - long long int size = size_of(current_instruction().products.at(0)); - for (long long int i = 0; i < size; ++i) + int size = size_of(current_instruction().products.at(0)); + for (int i = 0; i < size; ++i) products.at(0).push_back(0); products.at(1).push_back(0); } @@ -211,7 +211,7 @@ Transform.push_back(check_calls_against_header); // idempotent void check_calls_against_header(const recipe_ordinal r) { trace(9991, "transform") << "--- type-check calls inside recipe " << get(Recipe, r).name << end(); const recipe& caller = get(Recipe, r); - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& inst = caller.steps.at(i); if (inst.operation < MAX_PRIMITIVE_RECIPES) continue; const recipe& callee = get(Recipe, inst.operation); @@ -289,14 +289,14 @@ void check_reply_instructions_against_header(const recipe_ordinal r) { const recipe& caller_recipe = get(Recipe, r); if (!caller_recipe.has_header) return; trace(9991, "transform") << "--- checking reply instructions against header for " << caller_recipe.name << end(); - for (long long int i = 0; i < SIZE(caller_recipe.steps); ++i) { + for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { const instruction& inst = caller_recipe.steps.at(i); if (inst.name != "reply" && inst.name != "return") continue; if (SIZE(caller_recipe.products) != SIZE(inst.ingredients)) { raise << maybe(caller_recipe.name) << "replied with the wrong number of products at '" << to_string(inst) << "'\n" << end(); continue; } - for (long long int i = 0; i < SIZE(caller_recipe.products); ++i) { + for (int i = 0; i < SIZE(caller_recipe.products); ++i) { if (!types_match(caller_recipe.products.at(i), inst.ingredients.at(i))) raise << maybe(caller_recipe.name) << "replied with the wrong type at '" << to_string(inst) << "'\n" << end(); } @@ -334,7 +334,7 @@ void check_header_ingredients(const recipe_ordinal r) { if (caller_recipe.products.empty()) return; caller_recipe.ingredient_index.clear(); trace(9991, "transform") << "--- checking reply instructions against header for " << caller_recipe.name << end(); - for (long long int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { + for (int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { if (contains_key(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name)) raise << maybe(caller_recipe.name) << caller_recipe.ingredients.at(i).name << " can't repeat in the ingredients\n" << end(); put(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name, i); @@ -365,18 +365,18 @@ void deduce_types_from_header(const recipe_ordinal r) { if (caller_recipe.products.empty()) return; trace(9991, "transform") << "--- deduce types from header for " << caller_recipe.name << end(); map<string, const type_tree*> header_type; - for (long long int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { + for (int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { put(header_type, caller_recipe.ingredients.at(i).name, caller_recipe.ingredients.at(i).type); trace(9993, "transform") << "type of " << caller_recipe.ingredients.at(i).name << " is " << names_to_string(caller_recipe.ingredients.at(i).type) << end(); } - for (long long int i = 0; i < SIZE(caller_recipe.products); ++i) { + for (int i = 0; i < SIZE(caller_recipe.products); ++i) { put(header_type, caller_recipe.products.at(i).name, caller_recipe.products.at(i).type); trace(9993, "transform") << "type of " << caller_recipe.products.at(i).name << " is " << names_to_string(caller_recipe.products.at(i).type) << end(); } - for (long long int i = 0; i < SIZE(caller_recipe.steps); ++i) { + for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { instruction& inst = caller_recipe.steps.at(i); trace(9992, "transform") << "instruction: " << to_string(inst) << end(); - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (inst.ingredients.at(i).type) continue; if (header_type.find(inst.ingredients.at(i).name) == header_type.end()) continue; @@ -384,7 +384,7 @@ void deduce_types_from_header(const recipe_ordinal r) { inst.ingredients.at(i).type = new type_tree(*get(header_type, inst.ingredients.at(i).name)); trace(9993, "transform") << "type of " << inst.ingredients.at(i).name << " is " << names_to_string(inst.ingredients.at(i).type) << end(); } - for (long long int i = 0; i < SIZE(inst.products); ++i) { + for (int i = 0; i < SIZE(inst.products); ++i) { trace(9993, "transform") << " product: " << to_string(inst.products.at(i)) << end(); if (inst.products.at(i).type) continue; if (header_type.find(inst.products.at(i).name) == header_type.end()) @@ -419,7 +419,7 @@ void fill_in_reply_ingredients(recipe_ordinal r) { recipe& caller_recipe = get(Recipe, r); if (!caller_recipe.has_header) return; trace(9991, "transform") << "--- fill in reply ingredients from header for recipe " << caller_recipe.name << end(); - for (long long int i = 0; i < SIZE(caller_recipe.steps); ++i) { + for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { instruction& inst = caller_recipe.steps.at(i); if (inst.name == "reply" || inst.name == "return") add_header_products(inst, caller_recipe); @@ -437,7 +437,7 @@ void fill_in_reply_ingredients(recipe_ordinal r) { void add_header_products(instruction& inst, const recipe& caller_recipe) { assert(inst.name == "reply" || inst.name == "return"); // collect any products with the same names as ingredients - for (long long int i = 0; i < SIZE(caller_recipe.products); ++i) { + for (int i = 0; i < SIZE(caller_recipe.products); ++i) { // if the ingredient is missing, add it from the header if (SIZE(inst.ingredients) == i) inst.ingredients.push_back(caller_recipe.products.at(i)); diff --git a/057static_dispatch.cc b/057static_dispatch.cc index c160394d..da97ea80 100644 --- a/057static_dispatch.cc +++ b/057static_dispatch.cc @@ -23,7 +23,7 @@ map<string, vector<recipe_ordinal> > Recipe_variants; put(Recipe_variants, "main", vector<recipe_ordinal>()); // since we manually added main to Recipe_ordinal :(before "Clear Other State For Recently_added_recipes") for (map<string, vector<recipe_ordinal> >::iterator p = Recipe_variants.begin(); p != Recipe_variants.end(); ++p) { - for (long long int i = 0; i < SIZE(p->second); ++i) { + for (int i = 0; i < SIZE(p->second); ++i) { if (find(Recently_added_recipes.begin(), Recently_added_recipes.end(), p->second.at(i)) != Recently_added_recipes.end()) p->second.at(i) = -1; // just leave a ghost } @@ -54,7 +54,7 @@ else { :(code) string matching_variant_name(const recipe& rr) { const vector<recipe_ordinal>& variants = get_or_insert(Recipe_variants, rr.name); - for (long long 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; @@ -66,12 +66,12 @@ 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 (long long int i = 0; i < SIZE(r1.ingredients); ++i) { + for (int i = 0; i < SIZE(r1.ingredients); ++i) { if (!deeply_equal_type_names(r1.ingredients.at(i), r2.ingredients.at(i))) { return false; } } - for (long long int i = 0; i < SIZE(r1.products); ++i) { + for (int i = 0; i < SIZE(r1.products); ++i) { if (!deeply_equal_type_names(r1.products.at(i), r2.products.at(i))) { return false; } @@ -103,7 +103,7 @@ bool deeply_equal_type_names(const type_tree* a, const type_tree* b) { } string next_unused_recipe_name(const string& recipe_name) { - for (long long int i = 2; ; ++i) { + for (int i = 2; ; ++i) { ostringstream out; out << recipe_name << '_' << i; if (!contains_key(Recipe_ordinal, out.str())) @@ -128,9 +128,9 @@ def test a:number, b:number -> z:number [ //: support recipe headers in a previous transform to fill in missing types :(before "End check_or_set_invalid_types") -for (long long 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 (long long 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) @@ -150,7 +150,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 (long long 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; @@ -213,7 +213,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 (long long 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)))) @@ -223,13 +223,13 @@ vector<recipe_ordinal> strictly_matching_variants(const instruction& inst, vecto } bool all_header_reagents_strictly_match(const instruction& inst, const recipe& variant) { - for (long long 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 (long long 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(); @@ -242,7 +242,7 @@ bool all_header_reagents_strictly_match(const instruction& inst, const recipe& v // phase 3 vector<recipe_ordinal> strictly_matching_variants_except_literal_against_boolean(const instruction& inst, vector<recipe_ordinal>& variants) { vector<recipe_ordinal> 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; trace(9992, "transform") << "checking variant (strict except literals-against-booleans) " << i << ": " << header_label(variants.at(i)) << end(); if (all_header_reagents_strictly_match_except_literal_against_boolean(inst, get(Recipe, variants.at(i)))) @@ -252,13 +252,13 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_against_boolean } bool all_header_reagents_strictly_match_except_literal_against_boolean(const instruction& inst, const recipe& variant) { - for (long long 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_boolean(variant.ingredients.at(i), inst.ingredients.at(i))) { trace(9993, "transform") << "strict match failed: ingredient " << i << end(); return false; } } - for (long long 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_boolean(variant.products.at(i), inst.products.at(i))) { trace(9993, "transform") << "strict match failed: product " << i << end(); @@ -271,7 +271,7 @@ bool all_header_reagents_strictly_match_except_literal_against_boolean(const ins // phase 4 vector<recipe_ordinal> matching_variants(const instruction& inst, vector<recipe_ordinal>& variants) { vector<recipe_ordinal> 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; trace(9992, "transform") << "checking variant " << i << ": " << header_label(variants.at(i)) << end(); if (all_header_reagents_match(inst, get(Recipe, variants.at(i)))) @@ -281,13 +281,13 @@ vector<recipe_ordinal> matching_variants(const instruction& inst, vector<recipe_ } bool all_header_reagents_match(const instruction& inst, const recipe& variant) { - for (long long 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") << "strict match failed: ingredient " << i << end(); return false; } } - for (long long 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") << "strict match failed: product " << i << end(); @@ -300,11 +300,11 @@ bool all_header_reagents_match(const instruction& inst, const recipe& variant) { // tie-breaker for each phase const recipe& best_variant(const instruction& inst, vector<recipe_ordinal>& candidates) { assert(!candidates.empty()); - long long int min_score = 999; - long long int min_index = 0; - for (long long int i = 0; i < SIZE(candidates); ++i) { + int min_score = 999; + int min_index = 0; + for (int i = 0; i < SIZE(candidates); ++i) { const recipe& candidate = get(Recipe, candidates.at(i)); - long long int score = abs(SIZE(candidate.products)-SIZE(inst.products)) + int score = abs(SIZE(candidate.products)-SIZE(inst.products)) + abs(SIZE(candidate.ingredients)-SIZE(inst.ingredients)); assert(score < 999); if (score < min_score) { @@ -315,16 +315,16 @@ const recipe& best_variant(const instruction& inst, vector<recipe_ordinal>& cand return get(Recipe, candidates.at(min_index)); } -long long int non_ghost_size(vector<recipe_ordinal>& variants) { - long long int result = 0; - for (long long int i = 0; i < SIZE(variants); ++i) +int non_ghost_size(vector<recipe_ordinal>& variants) { + int result = 0; + for (int i = 0; i < SIZE(variants); ++i) if (variants.at(i) != -1) ++result; return result; } bool next_stash(const call& c, instruction* stash_inst) { const recipe& specializer_recipe = get(Recipe, c.running_recipe); - long long int index = c.running_step_index; + int index = c.running_step_index; for (++index; index < SIZE(specializer_recipe.steps); ++index) { const instruction& inst = specializer_recipe.steps.at(index); if (inst.name == "stash") { @@ -514,10 +514,10 @@ string header_label(recipe_ordinal r) { const recipe& caller = get(Recipe, r); ostringstream out; out << "recipe " << caller.name; - for (long long 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 (long long 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(); } diff --git a/058shape_shifting_container.cc b/058shape_shifting_container.cc index d8f3b001..1a458bb7 100644 --- a/058shape_shifting_container.cc +++ b/058shape_shifting_container.cc @@ -81,7 +81,7 @@ void read_type_ingredients(string& name) { if (!contains_key(Type_ordinal, name) || get(Type_ordinal, name) == 0) put(Type_ordinal, name, Next_type_ordinal++); type_info& info = get_or_insert(Type, get(Type_ordinal, name)); - long long int next_type_ordinal = START_TYPE_INGREDIENTS; + int next_type_ordinal = START_TYPE_INGREDIENTS; while (has_data(in)) { string curr = slurp_until(in, ':'); if (info.type_ingredient_names.find(curr) != info.type_ingredient_names.end()) { @@ -128,16 +128,16 @@ $mem: 7 :(code) // shape-shifting version of size_of -long long int size_of_type_ingredient(const type_tree* element_template, const type_tree* rest_of_use) { +int size_of_type_ingredient(const type_tree* element_template, const type_tree* rest_of_use) { type_tree* element_type = type_ingredient(element_template, rest_of_use); if (!element_type) return 0; - long long int result = size_of(element_type); + int result = size_of(element_type); delete element_type; return result; } type_tree* type_ingredient(const type_tree* element_template, const type_tree* rest_of_use) { - long long int type_ingredient_index = element_template->value - START_TYPE_INGREDIENTS; + int type_ingredient_index = element_template->value - START_TYPE_INGREDIENTS; const type_tree* curr = rest_of_use; if (!curr) return NULL; while (type_ingredient_index > 0) { @@ -166,7 +166,7 @@ def main [ :(before "End GET field Cases") const type_tree* type = get(Type, base_type).elements.at(i).type; if (type->value >= START_TYPE_INGREDIENTS) { - long long int size = size_of_type_ingredient(type, base.type->right); + int size = size_of_type_ingredient(type, base.type->right); if (!size) raise << "illegal field type '" << to_string(type) << "' seems to be missing a type ingredient or three\n" << end(); src += size; @@ -253,7 +253,7 @@ void replace_type_ingredients(type_tree* element_type, const type_tree* callsite replace_type_ingredients(element_type->right, callsite_type, container_info); if (element_type->value < START_TYPE_INGREDIENTS) return; - const long long int type_ingredient_index = element_type->value-START_TYPE_INGREDIENTS; + const int type_ingredient_index = element_type->value-START_TYPE_INGREDIENTS; if (!has_nth_type(callsite_type, type_ingredient_index)) { raise << "illegal type " << names_to_string(callsite_type) << " seems to be missing a type ingredient or three\n" << end(); return; @@ -265,7 +265,7 @@ void replace_type_ingredients(type_tree* element_type, const type_tree* callsite bool zig_left = false; { const type_tree* curr = callsite_type; - for (long long int i = 0; i < type_ingredient_index; ++i) + for (int i = 0; i < type_ingredient_index; ++i) curr = curr->right; if (curr && curr->left) { replacement = curr->left; @@ -299,7 +299,7 @@ void replace_type_ingredients(type_tree* element_type, const type_tree* callsite } } -bool final_type_ingredient(long long int type_ingredient_index, const type_info& container_info) { +bool final_type_ingredient(int type_ingredient_index, const type_info& container_info) { for (map<string, type_ordinal>::const_iterator p = container_info.type_ingredient_names.begin(); p != container_info.type_ingredient_names.end(); ++p) { @@ -475,7 +475,7 @@ void test_replace_middle_type_ingredient_with_multiple3() { CHECK(!element.type->right->right->right->right->right->right); } -bool has_nth_type(const type_tree* base, long long int n) { +bool has_nth_type(const type_tree* base, int n) { assert(n >= 0); if (base == NULL) return false; if (n == 0) return true; @@ -510,7 +510,7 @@ def main [ :(before "End GET_ADDRESS field Cases") const type_tree* type = get(Type, base_type).elements.at(i).type; if (type->value >= START_TYPE_INGREDIENTS) { - long long int size = size_of_type_ingredient(type, base.type->right); + int size = size_of_type_ingredient(type, base.type->right); if (!size) raise << "illegal type '" << to_string(type) << "' seems to be missing a type ingredient or three\n" << end(); result += size; 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<recipe_ordinal> strictly_matching_shape_shifting_variants(const instruction& inst, vector<recipe_ordinal>& variants) { vector<recipe_ordinal> 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<recipe_ordinal>& 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, vector<recip bool any_type_ingredient_in_header(recipe_ordinal variant) { const recipe& caller = get(Recipe, variant); - for (long long int i = 0; i < SIZE(caller.ingredients); ++i) { + for (int i = 0; i < SIZE(caller.ingredients); ++i) { if (contains_type_ingredient_name(caller.ingredients.at(i))) return true; } - for (long long int i = 0; i < SIZE(caller.products); ++i) { + for (int i = 0; i < SIZE(caller.products); ++i) { if (contains_type_ingredient_name(caller.products.at(i))) return true; } @@ -183,23 +183,23 @@ bool concrete_type_names_strictly_match(reagent to, reagent from) { return concrete_type_names_strictly_match(to.type, from.type, from); } -long long int number_of_concrete_type_names(recipe_ordinal r) { +int number_of_concrete_type_names(recipe_ordinal r) { const recipe& caller = get(Recipe, r); - long long int result = 0; - for (long long int i = 0; i < SIZE(caller.ingredients); ++i) + int result = 0; + for (int i = 0; i < SIZE(caller.ingredients); ++i) result += number_of_concrete_type_names(caller.ingredients.at(i)); - for (long long int i = 0; i < SIZE(caller.products); ++i) + for (int i = 0; i < SIZE(caller.products); ++i) result += number_of_concrete_type_names(caller.products.at(i)); return result; } -long long int number_of_concrete_type_names(const reagent& r) { +int number_of_concrete_type_names(const reagent& r) { return number_of_concrete_type_names(r.type); } -long long int number_of_concrete_type_names(const type_tree* type) { +int number_of_concrete_type_names(const type_tree* type) { if (!type) return 0; - long long int result = 0; + int result = 0; if (!type->name.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<string, type_tree*> 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<string, type_tree*>& type, const r } void compute_type_ingredient_mappings(const recipe& exemplar, const instruction& inst, map<string, const type_tree*>& 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 map<string, const type_t // update its header if (mappings.empty()) return; trace(9993, "transform") << "replacing in recipe header ingredients" << end(); - for (long long int i = 0; i < SIZE(new_recipe.ingredients); ++i) + for (int i = 0; i < SIZE(new_recipe.ingredients); ++i) replace_type_ingredients(new_recipe.ingredients.at(i), mappings, new_recipe); trace(9993, "transform") << "replacing in recipe header products" << end(); - for (long long int i = 0; i < SIZE(new_recipe.products); ++i) + for (int i = 0; i < SIZE(new_recipe.products); ++i) replace_type_ingredients(new_recipe.products.at(i), mappings, new_recipe); // update its body - 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); trace(9993, "transform") << "replacing in instruction '" << to_string(inst) << "'" << end(); - for (long long int j = 0; j < SIZE(inst.ingredients); ++j) + for (int j = 0; j < SIZE(inst.ingredients); ++j) replace_type_ingredients(inst.ingredients.at(j), mappings, new_recipe); - for (long long int j = 0; j < SIZE(inst.products); ++j) + for (int j = 0; j < SIZE(inst.products); ++j) replace_type_ingredients(inst.products.at(j), mappings, new_recipe); // special-case for new: replace type ingredient in first ingredient *value* if (inst.name == "new" && inst.ingredients.at(0).type->name != "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); } } diff --git a/060immutable.cc b/060immutable.cc index 5d56622f..a936797a 100644 --- a/060immutable.cc +++ b/060immutable.cc @@ -267,14 +267,14 @@ void check_immutable_ingredients(recipe_ordinal r) { const recipe& caller = get(Recipe, r); trace(9991, "transform") << "--- check mutability of ingredients in recipe " << caller.name << end(); if (!caller.has_header) return; // skip check for old-style recipes calling next-ingredient directly - for (long long int i = 0; i < SIZE(caller.ingredients); ++i) { + for (int i = 0; i < SIZE(caller.ingredients); ++i) { const reagent& current_ingredient = caller.ingredients.at(i); if (!is_mu_address(current_ingredient)) continue; // will be copied if (is_present_in_products(caller, current_ingredient.name)) continue; // not expected to be immutable // End Immutable Ingredients Special-cases set<reagent> immutable_vars; immutable_vars.insert(current_ingredient); - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& inst = caller.steps.at(i); check_immutable_ingredient_in_instruction(inst, immutable_vars, current_ingredient.name, caller); update_aliases(inst, immutable_vars); @@ -283,12 +283,12 @@ void check_immutable_ingredients(recipe_ordinal r) { } void update_aliases(const instruction& inst, set<reagent>& current_ingredient_and_aliases) { - set<long long int> current_ingredient_indices = ingredient_indices(inst, current_ingredient_and_aliases); + set<int> current_ingredient_indices = ingredient_indices(inst, current_ingredient_and_aliases); if (!contains_key(Recipe, inst.operation)) { // primitive recipe switch (inst.operation) { case COPY: - for (set<long long int>::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) + for (set<int>::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) current_ingredient_and_aliases.insert(inst.products.at(*p).name); break; case GET: @@ -304,23 +304,23 @@ void update_aliases(const instruction& inst, set<reagent>& current_ingredient_an } else { // defined recipe - set<long long int> contained_in_product_indices = scan_contained_in_product_indices(inst, current_ingredient_indices); - for (set<long long int>::iterator p = contained_in_product_indices.begin(); p != contained_in_product_indices.end(); ++p) { + set<int> contained_in_product_indices = scan_contained_in_product_indices(inst, current_ingredient_indices); + for (set<int>::iterator p = contained_in_product_indices.begin(); p != contained_in_product_indices.end(); ++p) { if (*p < SIZE(inst.products)) current_ingredient_and_aliases.insert(inst.products.at(*p)); } } } -set<long long int> scan_contained_in_product_indices(const instruction& inst, set<long long int>& ingredient_indices) { +set<int> scan_contained_in_product_indices(const instruction& inst, set<int>& ingredient_indices) { set<reagent> selected_ingredients; const recipe& callee = get(Recipe, inst.operation); - for (set<long long int>::iterator p = ingredient_indices.begin(); p != ingredient_indices.end(); ++p) { + for (set<int>::iterator p = ingredient_indices.begin(); p != ingredient_indices.end(); ++p) { if (*p >= SIZE(callee.ingredients)) continue; // optional immutable ingredient selected_ingredients.insert(callee.ingredients.at(*p)); } - set<long long int> result; - for (long long int i = 0; i < SIZE(callee.products); ++i) { + set<int> result; + for (int i = 0; i < SIZE(callee.products); ++i) { const reagent& current_product = callee.products.at(i); // TODO const string_tree* contained_in_name = property(current_product, "contained-in"); @@ -357,7 +357,7 @@ def test-next x:address:shared:test-list -> y:address:shared:test-list/contained :(code) void check_immutable_ingredient_in_instruction(const instruction& inst, const set<reagent>& current_ingredient_and_aliases, const string& original_ingredient_name, const recipe& caller) { // first check if the instruction is directly modifying something it shouldn't - for (long long int i = 0; i < SIZE(inst.products); ++i) { + for (int i = 0; i < SIZE(inst.products); ++i) { if (has_property(inst.products.at(i), "lookup") && current_ingredient_and_aliases.find(inst.products.at(i)) != current_ingredient_and_aliases.end()) { raise << maybe(caller.name) << "cannot modify " << inst.products.at(i).name << " in instruction '" << to_string(inst) << "' because it's not also a product of " << caller.name << '\n' << end(); @@ -365,10 +365,10 @@ void check_immutable_ingredient_in_instruction(const instruction& inst, const se } } // check if there's any indirect modification going on - set<long long int> current_ingredient_indices = ingredient_indices(inst, current_ingredient_and_aliases); + set<int> current_ingredient_indices = ingredient_indices(inst, current_ingredient_and_aliases); if (current_ingredient_indices.empty()) return; // ingredient not found in call - for (set<long long int>::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) { - const long long int current_ingredient_index = *p; + for (set<int>::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) { + const int current_ingredient_index = *p; reagent current_ingredient = inst.ingredients.at(current_ingredient_index); canonize_type(current_ingredient); const string& current_ingredient_name = current_ingredient.name; @@ -395,7 +395,7 @@ void check_immutable_ingredient_in_instruction(const instruction& inst, const se } } -bool is_modified_in_recipe(recipe_ordinal r, long long int ingredient_index, const recipe& caller) { +bool is_modified_in_recipe(recipe_ordinal r, int ingredient_index, const recipe& caller) { const recipe& callee = get(Recipe, r); if (!callee.has_header) { raise << maybe(caller.name) << "can't check mutability of ingredients in " << callee.name << " because it uses 'next-ingredient' directly, rather than a recipe header.\n" << end(); @@ -406,7 +406,7 @@ bool is_modified_in_recipe(recipe_ordinal r, long long int ingredient_index, con } bool is_present_in_products(const recipe& callee, const string& ingredient_name) { - for (long long int i = 0; i < SIZE(callee.products); ++i) { + for (int i = 0; i < SIZE(callee.products); ++i) { if (callee.products.at(i).name == ingredient_name) return true; } @@ -414,16 +414,16 @@ bool is_present_in_products(const recipe& callee, const string& ingredient_name) } bool is_present_in_ingredients(const recipe& callee, const string& ingredient_name) { - for (long long int i = 0; i < SIZE(callee.ingredients); ++i) { + for (int i = 0; i < SIZE(callee.ingredients); ++i) { if (callee.ingredients.at(i).name == ingredient_name) return true; } return false; } -set<long long int> ingredient_indices(const instruction& inst, const set<reagent>& ingredient_names) { - set<long long int> result; - for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { +set<int> ingredient_indices(const instruction& inst, const set<reagent>& ingredient_names) { + set<int> result; + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (is_literal(inst.ingredients.at(i))) continue; if (ingredient_names.find(inst.ingredients.at(i)) != ingredient_names.end()) result.insert(i); diff --git a/061recipe.cc b/061recipe.cc index dffd53a2..73f9444b 100644 --- a/061recipe.cc +++ b/061recipe.cc @@ -106,7 +106,7 @@ Transform.push_back(check_indirect_calls_against_header); // idempotent void check_indirect_calls_against_header(const recipe_ordinal r) { trace(9991, "transform") << "--- type-check 'call' instructions inside recipe " << get(Recipe, r).name << end(); const recipe& caller = get(Recipe, r); - for (long long int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& inst = caller.steps.at(i); if (inst.operation != CALL) continue; if (inst.ingredients.empty()) continue; // error raised above diff --git a/062scheduler.cc b/062scheduler.cc index 10a4d46a..d7b554b0 100644 --- a/062scheduler.cc +++ b/062scheduler.cc @@ -18,9 +18,9 @@ def f2 [ //: first, add a deadline to run(routine) //: these changes are ugly and brittle; just close your nose and get through the next few lines :(replace "void run_current_routine()") -void run_current_routine(long long int time_slice) -:(replace "while (!Current_routine->completed())" following "void run_current_routine(long long int time_slice)") -long long int ninstrs = 0; +void run_current_routine(int time_slice) +:(replace "while (!Current_routine->completed())" following "void run_current_routine(int time_slice)") +int ninstrs = 0; while (Current_routine->state == RUNNING && ninstrs < time_slice) :(after "Running One Instruction") ninstrs++; @@ -40,8 +40,8 @@ state = RUNNING; :(before "End Globals") vector<routine*> Routines; -long long int Current_routine_index = 0; -long long int Scheduling_interval = 500; +int Current_routine_index = 0; +int Scheduling_interval = 500; :(before "End Setup") Scheduling_interval = 500; Routines.clear(); @@ -71,7 +71,7 @@ void run(routine* rr) { } bool all_routines_done() { - for (long long int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state == RUNNING) { return false; } @@ -83,7 +83,7 @@ bool all_routines_done() { void skip_to_next_routine() { assert(!Routines.empty()); assert(Current_routine_index < SIZE(Routines)); - for (long long int i = (Current_routine_index+1)%SIZE(Routines); i != Current_routine_index; i = (i+1)%SIZE(Routines)) { + for (int i = (Current_routine_index+1)%SIZE(Routines); i != Current_routine_index; i = (i+1)%SIZE(Routines)) { if (Routines.at(i)->state == RUNNING) { Current_routine_index = i; Current_routine = Routines.at(i); @@ -103,7 +103,7 @@ string current_routine_label() { } :(before "End Teardown") -for (long long int i = 0; i < SIZE(Routines); ++i) +for (int i = 0; i < SIZE(Routines); ++i) delete Routines.at(i); Routines.clear(); Current_routine = NULL; @@ -117,7 +117,7 @@ void run_main(int argc, char* argv[]) { // pass in commandline args as ingredients to main // todo: test this Current_routine = main_routine; - for (long long int i = 1; i < argc; ++i) { + for (int i = 1; i < argc; ++i) { vector<double> arg; arg.push_back(new_mu_string(argv[i])); current_call().ingredient_atoms.push_back(arg); @@ -130,9 +130,9 @@ void run_main(int argc, char* argv[]) { //: 'start-running' will return a unique id for the routine that was created. //: routine id is a number, but don't do any arithmetic on it :(before "End routine Fields") -long long int id; +int id; :(before "End Globals") -long long int Next_routine_id = 1; +int Next_routine_id = 1; :(before "End Setup") Next_routine_id = 1; :(before "End routine Constructor") @@ -142,7 +142,7 @@ Next_routine_id++; //: routines save the routine that spawned them :(before "End routine Fields") // todo: really should be routine_id, but that's less efficient. -long long int parent_index; // only < 0 if there's no parent_index +int parent_index; // only < 0 if there's no parent_index :(before "End routine Constructor") parent_index = -1; @@ -167,7 +167,7 @@ case START_RUNNING: { routine* new_routine = new routine(ingredients.at(0).at(0)); new_routine->parent_index = Current_routine_index; // populate ingredients - for (long long int i = 1; i < SIZE(current_instruction().ingredients); ++i) { + for (int i = 1; i < SIZE(current_instruction().ingredients); ++i) { new_routine->calls.front().ingredient_atoms.push_back(ingredients.at(i)); reagent ingredient = current_instruction().ingredients.at(i); canonize_type(ingredient); @@ -302,7 +302,7 @@ def f1 [ -schedule: f1 :(before "End Scheduler Cleanup") -for (long long int i = 0; i < SIZE(Routines); ++i) { +for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state == COMPLETED) continue; if (Routines.at(i)->parent_index < 0) continue; // root thread if (has_completed_parent(i)) { @@ -311,8 +311,8 @@ for (long long int i = 0; i < SIZE(Routines); ++i) { } :(code) -bool has_completed_parent(long long int routine_index) { - for (long long int j = routine_index; j >= 0; j = Routines.at(j)->parent_index) { +bool has_completed_parent(int routine_index) { + for (int j = routine_index; j >= 0; j = Routines.at(j)->parent_index) { if (Routines.at(j)->state == COMPLETED) return true; } @@ -354,9 +354,9 @@ case ROUTINE_STATE: { } :(before "End Primitive Recipe Implementations") case ROUTINE_STATE: { - long long int id = ingredients.at(0).at(0); - long long int result = -1; - for (long long int i = 0; i < SIZE(Routines); ++i) { + int id = ingredients.at(0).at(0); + int result = -1; + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { result = Routines.at(i)->state; break; @@ -387,8 +387,8 @@ case RESTART: { } :(before "End Primitive Recipe Implementations") case RESTART: { - long long int id = ingredients.at(0).at(0); - for (long long int i = 0; i < SIZE(Routines); ++i) { + int id = ingredients.at(0).at(0); + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { Routines.at(i)->state = RUNNING; break; @@ -415,8 +415,8 @@ case STOP: { } :(before "End Primitive Recipe Implementations") case STOP: { - long long int id = ingredients.at(0).at(0); - for (long long int i = 0; i < SIZE(Routines); ++i) { + int id = ingredients.at(0).at(0); + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { Routines.at(i)->state = COMPLETED; break; @@ -435,7 +435,7 @@ case _DUMP_ROUTINES: { } :(before "End Primitive Recipe Implementations") case _DUMP_ROUTINES: { - for (long long int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { cerr << i << ": " << Routines.at(i)->id << ' ' << Routines.at(i)->state << ' ' << Routines.at(i)->parent_index << '\n'; } break; @@ -475,7 +475,7 @@ if (Current_routine->limit >= 0) { } :(before "End routine Fields") -long long int limit; +int limit; :(before "End routine Constructor") limit = -1; /* no limit */ @@ -501,8 +501,8 @@ case LIMIT_TIME: { } :(before "End Primitive Recipe Implementations") case LIMIT_TIME: { - long long int id = ingredients.at(0).at(0); - for (long long int i = 0; i < SIZE(Routines); ++i) { + int id = ingredients.at(0).at(0); + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { Routines.at(i)->limit = ingredients.at(1).at(0); break; diff --git a/063wait.cc b/063wait.cc index 2d0e2d8d..072a73ca 100644 --- a/063wait.cc +++ b/063wait.cc @@ -23,7 +23,7 @@ def f2 [ WAITING, :(before "End routine Fields") // only if state == WAITING -long long int waiting_on_location; +int waiting_on_location; int old_value_of_waiting_location; :(before "End routine Constructor") waiting_on_location = old_value_of_waiting_location = 0; @@ -52,7 +52,7 @@ case WAIT_FOR_LOCATION: { //: scheduler tweak to get routines out of that state :(before "End Scheduler State Transitions") -for (long long int i = 0; i < SIZE(Routines); ++i) { +for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state != WAITING) continue; if (Routines.at(i)->waiting_on_location && get_or_insert(Memory, Routines.at(i)->waiting_on_location) != Routines.at(i)->old_value_of_waiting_location) { @@ -85,7 +85,7 @@ def f2 [ :(before "End routine Fields") // only if state == WAITING -long long int waiting_on_routine; +int waiting_on_routine; :(before "End routine Constructor") waiting_on_routine = 0; @@ -121,12 +121,12 @@ case WAIT_FOR_ROUTINE: { // Wake up any routines waiting for other routines to go to sleep. // Important: this must come after the scheduler loop above giving routines // waiting for locations to change a chance to wake up. -for (long long int i = 0; i < SIZE(Routines); ++i) { +for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state != WAITING) continue; if (!Routines.at(i)->waiting_on_routine) continue; - long long int id = Routines.at(i)->waiting_on_routine; + int id = Routines.at(i)->waiting_on_routine; assert(id != Routines.at(i)->id); // routine can't wait on itself - for (long long int j = 0; j < SIZE(Routines); ++j) { + for (int j = 0; j < SIZE(Routines); ++j) { if (Routines.at(j)->id == id && Routines.at(j)->state != RUNNING) { trace(9999, "schedule") << "waking up routine " << Routines.at(i)->id << end(); Routines.at(i)->state = RUNNING; @@ -145,7 +145,7 @@ case SWITCH: { } :(before "End Primitive Recipe Implementations") case SWITCH: { - long long int id = some_other_running_routine(); + int id = some_other_running_routine(); if (id) { assert(id != Current_routine->id); Current_routine->state = WAITING; @@ -155,8 +155,8 @@ case SWITCH: { } :(code) -long long int some_other_running_routine() { - for (long long int i = 0; i < SIZE(Routines); ++i) { +int some_other_running_routine() { + for (int i = 0; i < SIZE(Routines); ++i) { if (i == Current_routine_index) continue; assert(Routines.at(i) != Current_routine); assert(Routines.at(i)->id != Current_routine->id); diff --git a/077hash.cc b/077hash.cc index 62c02eca..f8003cbe 100644 --- a/077hash.cc +++ b/077hash.cc @@ -66,7 +66,7 @@ size_t hash_mu_address(size_t h, reagent& r) { size_t hash_mu_string(size_t h, const reagent& r) { string input = read_mu_string(get_or_insert(Memory, r.value)); - for (long long int i = 0; i < SIZE(input); ++i) { + for (int i = 0; i < SIZE(input); ++i) { h = hash_iter(h, static_cast<size_t>(input.at(i))); //? cerr << i << ": " << h << '\n'; } @@ -74,11 +74,11 @@ size_t hash_mu_string(size_t h, const reagent& r) { } size_t hash_mu_array(size_t h, const reagent& r) { - long long int size = get_or_insert(Memory, r.value); + int size = get_or_insert(Memory, r.value); reagent elem = r; delete elem.type; elem.type = new type_tree(*array_element(r.type)); - for (long long int i=0, address = r.value+1; i < size; ++i, address += size_of(elem)) { + for (int i=0, address = r.value+1; i < size; ++i, address += size_of(elem)) { reagent tmp = elem; tmp.value = address; h = hash(h, tmp); @@ -96,9 +96,9 @@ bool is_mu_container(const reagent& r) { size_t hash_mu_container(size_t h, const reagent& r) { assert(r.type->value); type_info& info = get(Type, r.type->value); - long long int address = r.value; - long long int offset = 0; - for (long long int i = 0; i < SIZE(info.elements); ++i) { + int address = r.value; + int offset = 0; + for (int i = 0; i < SIZE(info.elements); ++i) { reagent element = element_type(r, i); if (has_property(element, "ignore-for-hash")) continue; element.set_value(address+offset); @@ -117,7 +117,7 @@ bool is_mu_exclusive_container(const reagent& r) { size_t hash_mu_exclusive_container(size_t h, const reagent& r) { assert(r.type->value); - long long int tag = get(Memory, r.value); + int tag = get(Memory, r.value); reagent variant = variant_type(r, tag); // todo: move this error to container definition time if (has_property(variant, "ignore-for-hash")) @@ -376,7 +376,7 @@ case HASH_OLD: { string input = read_mu_string(ingredients.at(0).at(0)); size_t h = 0 ; - for (long long int i = 0; i < SIZE(input); ++i) { + for (int i = 0; i < SIZE(input); ++i) { h += static_cast<size_t>(input.at(i)); h += (h<<10); h ^= (h>>6); diff --git a/080display.cc b/080display.cc index 92f9aa80..39bc90cf 100644 --- a/080display.cc +++ b/080display.cc @@ -3,7 +3,7 @@ //:: Display management :(before "End Globals") -long long int Display_row = 0, Display_column = 0; +int Display_row = 0, Display_column = 0; bool Autodisplay = true; :(before "End Primitive Recipe Declarations") @@ -18,8 +18,8 @@ case OPEN_CONSOLE: { case OPEN_CONSOLE: { tb_init(); Display_row = Display_column = 0; - long long int width = tb_width(); - long long int height = tb_height(); + int width = tb_width(); + int height = tb_height(); if (width > 222 || height > 222) tb_shutdown(); if (width > 222) raise << "sorry, mu doesn't support windows wider than 222 characters. Please resize your window.\n" << end(); @@ -84,8 +84,8 @@ case CLEAR_LINE_ON_DISPLAY: { } :(before "End Primitive Recipe Implementations") case CLEAR_LINE_ON_DISPLAY: { - long long int width = tb_width(); - for (long long int x = Display_column; x < width; ++x) { + int width = tb_width(); + for (int x = Display_column; x < width; ++x) { tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_BLACK); } tb_set_cursor(Display_column, Display_row); @@ -124,9 +124,9 @@ case PRINT_CHARACTER_TO_DISPLAY: { :(before "End Primitive Recipe Implementations") case PRINT_CHARACTER_TO_DISPLAY: { int h=tb_height(), w=tb_width(); - long long int height = (h >= 0) ? h : 0; - long long int width = (w >= 0) ? w : 0; - long long int c = ingredients.at(0).at(0); + int height = (h >= 0) ? h : 0; + int width = (w >= 0) ? w : 0; + int c = ingredients.at(0).at(0); int color = TB_BLACK; if (SIZE(ingredients) > 1) { color = ingredients.at(1).at(0); @@ -219,7 +219,7 @@ case MOVE_CURSOR_DOWN_ON_DISPLAY: { :(before "End Primitive Recipe Implementations") case MOVE_CURSOR_DOWN_ON_DISPLAY: { int h=tb_height(); - long long int height = (h >= 0) ? h : 0; + int height = (h >= 0) ? h : 0; if (Display_row < height-1) { Display_row++; tb_set_cursor(Display_column, Display_row); @@ -257,7 +257,7 @@ case MOVE_CURSOR_RIGHT_ON_DISPLAY: { :(before "End Primitive Recipe Implementations") case MOVE_CURSOR_RIGHT_ON_DISPLAY: { int w=tb_width(); - long long int width = (w >= 0) ? w : 0; + int width = (w >= 0) ? w : 0; if (Display_column < width-1) { Display_column++; tb_set_cursor(Display_column, Display_row); diff --git a/082scenario_screen.cc b/082scenario_screen.cc index 560d0079..65cf4199 100644 --- a/082scenario_screen.cc +++ b/082scenario_screen.cc @@ -126,8 +126,8 @@ $error: 0 // Scenarios may not define default-space, so they should fit within the // initial area of memory reserved for tests. We'll put the predefined // variables available to them at the end of that region. -const long long int Max_variables_in_scenarios = Reserved_for_tests-100; -long long int Next_predefined_global_for_scenarios = Max_variables_in_scenarios; +const int Max_variables_in_scenarios = Reserved_for_tests-100; +int Next_predefined_global_for_scenarios = Max_variables_in_scenarios; :(before "End Setup") assert(Next_predefined_global_for_scenarios < Reserved_for_tests); :(after "transform_all()" following "case RUN:") @@ -138,7 +138,7 @@ assert(Name[tmp_recipe.at(0)][""] < Max_variables_in_scenarios); :(before "End Globals") // Scenario Globals. -const long long int SCREEN = Next_predefined_global_for_scenarios++; +const int SCREEN = Next_predefined_global_for_scenarios++; // End Scenario Globals. :(before "End Special Scenario Variable Names(r)") Name[r]["screen"] = SCREEN; @@ -190,8 +190,8 @@ case SCREEN_SHOULD_CONTAIN_IN_COLOR: { :(before "End Types") // scan an array of characters in a unicode-aware, bounds-checked manner struct raw_string_stream { - long long int index; - const long long int max; + int index; + const int max; const char* buf; raw_string_stream(const string&); @@ -204,23 +204,23 @@ struct raw_string_stream { :(code) void check_screen(const string& expected_contents, const int color) { assert(!current_call().default_space); // not supported - long long int screen_location = get_or_insert(Memory, SCREEN)+/*skip refcount*/1; + int screen_location = get_or_insert(Memory, SCREEN)+/*skip refcount*/1; int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); - long long int screen_data_location = screen_location+data_offset; // type: address:shared:array:character - long long int screen_data_start = get_or_insert(Memory, screen_data_location) + /*skip refcount*/1; // type: array:character + int screen_data_location = screen_location+data_offset; // type: address:shared:array:character + int screen_data_start = get_or_insert(Memory, screen_data_location) + /*skip refcount*/1; // type: array:character int width_offset = find_element_name(get(Type_ordinal, "screen"), "num-columns", ""); - long long int screen_width = get_or_insert(Memory, screen_location+width_offset); + int screen_width = get_or_insert(Memory, screen_location+width_offset); int height_offset = find_element_name(get(Type_ordinal, "screen"), "num-rows", ""); - long long int screen_height = get_or_insert(Memory, screen_location+height_offset); + int screen_height = get_or_insert(Memory, screen_location+height_offset); raw_string_stream cursor(expected_contents); // todo: too-long expected_contents should fail - long long int addr = screen_data_start+/*skip length*/1; - for (long long int row = 0; row < screen_height; ++row) { + int addr = screen_data_start+/*skip length*/1; + for (int row = 0; row < screen_height; ++row) { cursor.skip_whitespace_and_comments(); if (cursor.at_end()) break; assert(cursor.get() == '.'); - for (long long int column = 0; column < screen_width; ++column, addr+= /*size of screen-cell*/2) { + for (int column = 0; column < screen_width; ++column, addr+= /*size of screen-cell*/2) { const int cell_color_offset = 1; uint32_t curr = cursor.get(); if (get_or_insert(Memory, addr) == 0 && isspace(curr)) continue; @@ -339,20 +339,20 @@ case _DUMP_SCREEN: { :(code) void dump_screen() { assert(!current_call().default_space); // not supported - long long int screen_location = get_or_insert(Memory, SCREEN) + /*skip refcount*/1; + int screen_location = get_or_insert(Memory, SCREEN) + /*skip refcount*/1; int width_offset = find_element_name(get(Type_ordinal, "screen"), "num-columns", ""); int screen_width = get_or_insert(Memory, screen_location+width_offset); int height_offset = find_element_name(get(Type_ordinal, "screen"), "num-rows", ""); int screen_height = get_or_insert(Memory, screen_location+height_offset); int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); - long long int screen_data_location = screen_location+data_offset; // type: address:shared:array:character - long long int screen_data_start = get_or_insert(Memory, screen_data_location) + /*skip refcount*/1; // type: array:character + int screen_data_location = screen_location+data_offset; // type: address:shared:array:character + int screen_data_start = get_or_insert(Memory, screen_data_location) + /*skip refcount*/1; // type: array:character assert(get_or_insert(Memory, screen_data_start) == screen_width*screen_height); - long long int curr = screen_data_start+1; // skip length - for (long long int row = 0; row < screen_height; ++row) { + int curr = screen_data_start+1; // skip length + for (int row = 0; row < screen_height; ++row) { cerr << '.'; - for (long long int col = 0; col < screen_width; ++col) { + for (int col = 0; col < screen_width; ++col) { if (get_or_insert(Memory, curr)) cerr << to_unicode(static_cast<uint32_t>(get_or_insert(Memory, curr))); else diff --git a/085scenario_console.cc b/085scenario_console.cc index 99b044fa..d91d3ce4 100644 --- a/085scenario_console.cc +++ b/085scenario_console.cc @@ -30,7 +30,7 @@ scenario keyboard-in-scenario [ ] :(before "End Scenario Globals") -const long long int CONSOLE = Next_predefined_global_for_scenarios++; +const int CONSOLE = Next_predefined_global_for_scenarios++; :(before "End Special Scenario Variable Names(r)") Name[r]["console"] = CONSOLE; @@ -54,13 +54,13 @@ case ASSUME_CONSOLE: { slurp_body(in, r); int num_events = count_events(r); // initialize the events like in new-fake-console - long long int size = /*space for refcount*/1 + /*space for length*/1 + num_events*size_of_event(); + int size = /*space for refcount*/1 + /*space for length*/1 + num_events*size_of_event(); ensure_space(size); - long long int event_data_address = Current_routine->alloc; + int event_data_address = Current_routine->alloc; // store length put(Memory, Current_routine->alloc+/*skip refcount*/1, num_events); Current_routine->alloc += /*skip refcount and length*/2; - for (long long int i = 0; i < SIZE(r.steps); ++i) { + for (int i = 0; i < SIZE(r.steps); ++i) { const instruction& curr = r.steps.at(i); if (curr.name == "left-click") { trace(9999, "mem") << "storing 'left-click' event starting at " << Current_routine->alloc << end(); @@ -95,9 +95,9 @@ case ASSUME_CONSOLE: { trace(9999, "mem") << "storing 'type' event starting at " << Current_routine->alloc << end(); const string& contents = curr.ingredients.at(0).name; const char* raw_contents = contents.c_str(); - long long int num_keyboard_events = unicode_length(contents); - long long int curr = 0; - for (long long int i = 0; i < num_keyboard_events; ++i) { + int num_keyboard_events = unicode_length(contents); + int curr = 0; + for (int i = 0; i < num_keyboard_events; ++i) { trace(9999, "mem") << "storing 'text' tag at " << Current_routine->alloc << end(); put(Memory, Current_routine->alloc, /*tag for 'text' variant of 'event' exclusive-container*/0); uint32_t curr_character; @@ -116,7 +116,7 @@ case ASSUME_CONSOLE: { put(Memory, CONSOLE, Current_routine->alloc); trace(9999, "mem") << "storing console in " << Current_routine->alloc << end(); Current_routine->alloc += size_of_console(); - long long int console_address = get_or_insert(Memory, CONSOLE); + int console_address = get_or_insert(Memory, CONSOLE); trace(9999, "mem") << "storing console data in " << console_address+2 << end(); put(Memory, console_address+/*skip refcount*/1+/*offset of 'data' in container 'events'*/1, event_data_address); // increment refcount for event data @@ -125,7 +125,7 @@ case ASSUME_CONSOLE: { } :(before "End Globals") -map<string, long long int> Key; +map<string, int> Key; :(before "End One-time Setup") initialize_key_names(); :(code) @@ -250,22 +250,22 @@ case REPLACE_IN_CONSOLE: { raise << "console not initialized\n" << end(); break; } - long long int console_address = get_or_insert(Memory, CONSOLE); - long long int console_data = get_or_insert(Memory, console_address+1); - long long int size = get_or_insert(Memory, console_data); // array size - for (long long int i = 0, curr = console_data+1; i < size; ++i, curr+=size_of_event()) { + int console_address = get_or_insert(Memory, CONSOLE); + int console_data = get_or_insert(Memory, console_address+1); + int size = get_or_insert(Memory, console_data); // array size + for (int i = 0, curr = console_data+1; i < size; ++i, curr+=size_of_event()) { if (get_or_insert(Memory, curr) != /*text*/0) continue; if (get_or_insert(Memory, curr+1) != ingredients.at(0).at(0)) continue; - for (long long int n = 0; n < size_of_event(); ++n) + for (int n = 0; n < size_of_event(); ++n) put(Memory, curr+n, ingredients.at(1).at(n)); } break; } :(code) -long long int count_events(const recipe& r) { - long long int result = 0; - for (long long int i = 0; i < SIZE(r.steps); ++i) { +int count_events(const recipe& r) { + int result = 0; + for (int i = 0; i < SIZE(r.steps); ++i) { const instruction& curr = r.steps.at(i); if (curr.name == "type") result += unicode_length(curr.ingredients.at(0).name); @@ -275,9 +275,9 @@ long long int count_events(const recipe& r) { return result; } -long long int size_of_event() { +int size_of_event() { // memoize result if already computed - static long long int result = 0; + static int result = 0; if (result) return result; type_tree* type = new type_tree("event", get(Type_ordinal, "event")); result = size_of(type); @@ -285,9 +285,9 @@ long long int size_of_event() { return result; } -long long int size_of_console() { +int size_of_console() { // memoize result if already computed - static long long int result = 0; + static int result = 0; if (result) return result; assert(get(Type_ordinal, "console")); type_tree* type = new type_tree("console", get(Type_ordinal, "console")); diff --git a/090trace_browser.cc b/090trace_browser.cc index 8c2610a4..8024ab1f 100644 --- a/090trace_browser.cc +++ b/090trace_browser.cc @@ -24,23 +24,23 @@ if (argc == 3 && is_equal(argv[1], "browse-trace")) { } :(before "End Globals") -set<long long int> Visible; -long long int Top_of_screen = 0; -long long int Last_printed_row = 0; -map<int, long long int> Trace_index; // screen row -> trace index +set<int> Visible; +int Top_of_screen = 0; +int Last_printed_row = 0; +map<int, int> Trace_index; // screen row -> trace index :(code) void start_trace_browser() { if (!Trace_stream) return; cerr << "computing min depth to display\n"; - long long int min_depth = 9999; - for (long long int i = 0; i < SIZE(Trace_stream->past_lines); ++i) { + int min_depth = 9999; + for (int i = 0; i < SIZE(Trace_stream->past_lines); ++i) { trace_line& curr_line = Trace_stream->past_lines.at(i); if (curr_line.depth < min_depth) min_depth = curr_line.depth; } cerr << "min depth is " << min_depth << '\n'; cerr << "computing lines to display\n"; - for (long long int i = 0; i < SIZE(Trace_stream->past_lines); ++i) { + for (int i = 0; i < SIZE(Trace_stream->past_lines); ++i) { if (Trace_stream->past_lines.at(i).depth == min_depth) Visible.insert(i); } @@ -54,7 +54,7 @@ void start_trace_browser() { do { tb_poll_event(&event); } while (event.type != TB_EVENT_KEY); - long long int key = event.key ? event.key : event.ch; + int key = event.key ? event.key : event.ch; if (key == 'q' || key == 'Q') break; if (key == 'j' || key == TB_KEY_ARROW_DOWN) { // move cursor one line down @@ -111,8 +111,8 @@ void start_trace_browser() { if (key == TB_KEY_CARRIAGE_RETURN) { // expand lines under current by one level assert(contains_key(Trace_index, Display_row)); - long long int start_index = get(Trace_index, Display_row); - long long int index = 0; + int start_index = get(Trace_index, Display_row); + int index = 0; // simultaneously compute end_index and min_depth int min_depth = 9999; for (index = start_index+1; index < SIZE(Trace_stream->past_lines); ++index) { @@ -121,7 +121,7 @@ void start_trace_browser() { assert(curr_line.depth > Trace_stream->past_lines.at(start_index).depth); if (curr_line.depth < min_depth) min_depth = curr_line.depth; } - long long int end_index = index; + int end_index = index; // mark as visible all intervening indices at min_depth for (index = start_index; index < end_index; ++index) { trace_line& curr_line = Trace_stream->past_lines.at(index); @@ -134,8 +134,8 @@ void start_trace_browser() { if (key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2) { // collapse all lines under current assert(contains_key(Trace_index, Display_row)); - long long int start_index = get(Trace_index, Display_row); - long long int index = 0; + int start_index = get(Trace_index, Display_row); + int index = 0; // end_index is the next line at a depth same as or lower than start_index int initial_depth = Trace_stream->past_lines.at(start_index).depth; for (index = start_index+1; index < SIZE(Trace_stream->past_lines); ++index) { @@ -143,7 +143,7 @@ void start_trace_browser() { trace_line& curr_line = Trace_stream->past_lines.at(index); if (curr_line.depth <= initial_depth) break; } - long long int end_index = index; + int end_index = index; // mark as visible all intervening indices at min_depth for (index = start_index+1; index < end_index; ++index) { Visible.erase(index); @@ -156,7 +156,7 @@ void start_trace_browser() { // update Trace_indices for each screen_row on the basis of Top_of_screen and Visible void refresh_screen_rows() { - long long int screen_row = 0, index = 0; + int screen_row = 0, index = 0; Trace_index.clear(); for (screen_row = 0, index = Top_of_screen; screen_row < tb_height() && index < SIZE(Trace_stream->past_lines); ++screen_row, ++index) { // skip lines without depth for now @@ -171,14 +171,14 @@ done:; } void render() { - long long int screen_row = 0; + int screen_row = 0; for (screen_row = 0; screen_row < tb_height(); ++screen_row) { if (!contains_key(Trace_index, screen_row)) break; trace_line& curr_line = Trace_stream->past_lines.at(get(Trace_index, screen_row)); ostringstream out; out << std::setw(4) << curr_line.depth << ' ' << curr_line.label << ": " << curr_line.contents; if (screen_row < tb_height()-1) { - long long int delta = lines_hidden(screen_row); + int delta = lines_hidden(screen_row); // home-brew escape sequence for red if (delta > 999) out << "{"; out << " (" << delta << ")"; @@ -196,7 +196,7 @@ void render() { tb_present(); } -long long int lines_hidden(long long int screen_row) { +int lines_hidden(int screen_row) { assert(contains_key(Trace_index, screen_row)); if (!contains_key(Trace_index, screen_row+1)) return SIZE(Trace_stream->past_lines) - get(Trace_index, screen_row); @@ -205,7 +205,7 @@ long long int lines_hidden(long long int screen_row) { } void render_line(int screen_row, const string& s) { - long long int col = 0; + int col = 0; int color = TB_WHITE; for (col = 0; col < tb_width() && col < SIZE(s); ++col) { char c = s.at(col); // todo: unicode diff --git a/091run_interactive.cc b/091run_interactive.cc index 6bebfd31..70929a91 100644 --- a/091run_interactive.cc +++ b/091run_interactive.cc @@ -70,12 +70,12 @@ Track_most_recent_products = false; // reads a string, tries to call it as code (treating it as a test), saving // all errors. // returns true if successfully called (no errors found during load and transform) -bool run_interactive(long long int address) { +bool run_interactive(int address) { assert(contains_key(Recipe_ordinal, "interactive") && get(Recipe_ordinal, "interactive") != 0); // try to sandbox the run as best you can // todo: test this if (!Current_scenario) { - for (long long int i = 1; i < Reserved_for_tests; ++i) + for (int i = 1; i < Reserved_for_tests; ++i) Memory.erase(i); } string command = trim(strip_comments(read_mu_string(address))); @@ -335,7 +335,7 @@ void test_run_interactive_cleans_up_any_created_specializations() { CHECK_EQ(variant_count("foo"), 1); } -long long int variant_count(string recipe_name) { +int variant_count(string recipe_name) { if (!contains_key(Recipe_variants, recipe_name)) return 0; return non_ghost_size(get(Recipe_variants, recipe_name)); } @@ -351,7 +351,7 @@ if (Track_most_recent_products) { :(code) void track_most_recent_products(const instruction& instruction, const vector<vector<double> >& products) { ostringstream out; - for (long long int i = 0; i < SIZE(products); ++i) { + for (int i = 0; i < SIZE(products); ++i) { // string if (i < SIZE(instruction.products)) { if (is_mu_string(instruction.products.at(i))) { @@ -359,7 +359,7 @@ void track_most_recent_products(const instruction& instruction, const vector<vec tb_shutdown(); cerr << read_mu_string(trace_error_contents()) << '\n'; cerr << SIZE(products.at(i)) << ": "; - for (long long int j = 0; j < SIZE(products.at(i)); ++j) + for (int j = 0; j < SIZE(products.at(i)); ++j) cerr << no_scientific(products.at(i).at(j)) << ' '; cerr << '\n'; } @@ -369,7 +369,7 @@ void track_most_recent_products(const instruction& instruction, const vector<vec } // End Record Product Special-cases } - for (long long int j = 0; j < SIZE(products.at(i)); ++j) + for (int j = 0; j < SIZE(products.at(i)); ++j) out << no_scientific(products.at(i).at(j)) << ' '; out << '\n'; } @@ -379,7 +379,7 @@ void track_most_recent_products(const instruction& instruction, const vector<vec :(code) string strip_comments(string in) { ostringstream result; - for (long long int i = 0; i < SIZE(in); ++i) { + for (int i = 0; i < SIZE(in); ++i) { if (in.at(i) != '#') { result << in.at(i); } @@ -391,14 +391,14 @@ string strip_comments(string in) { return result.str(); } -long long int stringified_value_of_location(long long int address) { +int stringified_value_of_location(int address) { // convert to string ostringstream out; out << no_scientific(get_or_insert(Memory, address)); return new_mu_string(out.str()); } -long long int trace_error_contents() { +int trace_error_contents() { if (!Trace_stream) return 0; ostringstream out; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { @@ -412,7 +412,7 @@ long long int trace_error_contents() { return new_mu_string(result); } -long long int trace_app_contents() { +int trace_app_contents() { if (!Trace_stream) return 0; ostringstream out; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { @@ -457,20 +457,20 @@ case RELOAD: { :(before "End Primitive Recipe Implementations") case RELOAD: { // clear any containers in advance - for (long long int i = 0; i < SIZE(Recently_added_types); ++i) { + for (int i = 0; i < SIZE(Recently_added_types); ++i) { if (!contains_key(Type, Recently_added_types.at(i))) continue; Type_ordinal.erase(get(Type, Recently_added_types.at(i)).name); Type.erase(Recently_added_types.at(i)); } for (map<string, vector<recipe_ordinal> >::iterator p = Recipe_variants.begin(); p != Recipe_variants.end(); ++p) { vector<recipe_ordinal>& variants = p->second; - for (long long int i = 0; i < SIZE(p->second); ++i) { + for (int i = 0; i < SIZE(p->second); ++i) { if (variants.at(i) == -1) continue; if (find(Recently_added_shape_shifting_recipes.begin(), Recently_added_shape_shifting_recipes.end(), variants.at(i)) != Recently_added_shape_shifting_recipes.end()) variants.at(i) = -1; // ghost } } - for (long long int i = 0; i < SIZE(Recently_added_shape_shifting_recipes); ++i) { + for (int i = 0; i < SIZE(Recently_added_shape_shifting_recipes); ++i) { Recipe_ordinal.erase(get(Recipe, Recently_added_shape_shifting_recipes.at(i)).name); Recipe.erase(Recently_added_shape_shifting_recipes.at(i)); } @@ -482,7 +482,7 @@ case RELOAD: { vector<recipe_ordinal> recipes_reloaded = load(code); // clear a few things from previous runs // ad hoc list; we've probably missed a few - for (long long int i = 0; i < SIZE(recipes_reloaded); ++i) + for (int i = 0; i < SIZE(recipes_reloaded); ++i) Name.erase(recipes_reloaded.at(i)); transform_all(); Trace_stream->newline(); // flush trace |