From 6c96a437cef5140197660a0903309f11c364bf78 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 19 Oct 2016 22:10:35 -0700 Subject: 3522 --- 001help.cc | 4 +-- 002test.cc | 4 +-- 003trace.cc | 10 +++---- 010vm.cc | 40 ++++++++++++------------- 011load.cc | 8 ++--- 012transform.cc | 12 ++++---- 013update_operation.cc | 2 +- 018type_abbreviations.cc | 10 +++---- 020run.cc | 18 ++++++------ 021check_instruction.cc | 4 +-- 022arithmetic.cc | 20 ++++++------- 023boolean.cc | 14 ++++----- 025compare.cc | 28 +++++++++--------- 027call_ingredient.cc | 4 +-- 028call_reply.cc | 12 ++++---- 029tools.cc | 12 ++++---- 030container.cc | 32 ++++++++++---------- 031merge.cc | 6 ++-- 032array.cc | 4 +-- 033exclusive_container.cc | 4 +-- 034address.cc | 4 +-- 035lookup.cc | 2 +- 036refcount.cc | 26 ++++++++-------- 037abandon.cc | 6 ++-- 038new_text.cc | 4 +-- 039location_array.cc | 2 +- 040brace.cc | 6 ++-- 041jump_target.cc | 4 +-- 042name.cc | 8 ++--- 043space.cc | 8 ++--- 044space_surround.cc | 2 +- 045closure_name.cc | 6 ++-- 047check_type_by_name.cc | 6 ++-- 050scenario.cc | 16 +++++----- 052tangle.cc | 12 ++++---- 053recipe_header.cc | 40 ++++++++++++------------- 054static_dispatch.cc | 50 +++++++++++++++---------------- 055shape_shifting_container.cc | 4 +-- 056shape_shifting_recipe.cc | 62 +++++++++++++++++++-------------------- 057immutable.cc | 22 +++++++------- 060rewrite_literal_string.cc | 10 +++---- 062convert_ingredients_to_text.cc | 8 ++--- 069hash.cc | 8 ++--- 071recipe.cc | 22 +++++++------- 072scheduler.cc | 26 ++++++++-------- 073wait.cc | 18 ++++++------ 074deep_copy.cc | 4 +-- 080display.cc | 6 ++-- 082scenario_screen.cc | 6 ++-- 085scenario_console.cc | 10 +++---- 089scenario_filesystem.cc | 4 +-- 091socket.cc | 2 +- 52 files changed, 331 insertions(+), 331 deletions(-) diff --git a/001help.cc b/001help.cc index 0f5147e8..0f60bf09 100644 --- a/001help.cc +++ b/001help.cc @@ -48,7 +48,7 @@ while (argc > 1 && starts_with(*arg, "--")) { // End Commandline Options(*arg) else cerr << "skipping unknown option " << *arg << '\n'; - --argc; ++argv; ++arg; + --argc; ++argv; ++arg; } //:: Helper function used by the above fragment of code (and later layers too, @@ -67,7 +67,7 @@ bool is_equal(char* s, const char* lit) { bool starts_with(const string& s, const string& pat) { string::const_iterator a=s.begin(), b=pat.begin(); - for (/*nada*/; a!=s.end() && b!=pat.end(); ++a, ++b) + for (/*nada*/; a!=s.end() && b!=pat.end(); ++a, ++b) if (*a != *b) return false; return b == pat.end(); } diff --git a/002test.cc b/002test.cc index 9ec5e64d..eeea02a3 100644 --- a/002test.cc +++ b/002test.cc @@ -53,9 +53,9 @@ if (Run_tests) { // we run some tests and then exit; assume no state need be maintained afterward // End Test Run Initialization - time_t t; time(&t); + time_t t; time(&t); cerr << "C tests: " << ctime(&t); - for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { + for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { //? cerr << i << '\n'; run_test(i); } diff --git a/003trace.cc b/003trace.cc index e7bb56cf..6c4bbabf 100644 --- a/003trace.cc +++ b/003trace.cc @@ -149,7 +149,7 @@ void trace_stream::newline() { string trace_stream::readable_contents(string label) { ostringstream output; label = trim(label); - for (vector::iterator p = past_lines.begin(); p != past_lines.end(); ++p) + for (vector::iterator p = past_lines.begin(); p != past_lines.end(); ++p) if (label.empty() || label == p->label) { output << std::setw(4) << p->depth << ' ' << p->label << ": " << p->contents << '\n'; } @@ -250,7 +250,7 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expecte if (curr_expected_line == SIZE(expected_lines)) return true; string label, contents; split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); - for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { + for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (label != p->label) continue; if (contents != trim(p->contents)) continue; ++curr_expected_line; @@ -287,7 +287,7 @@ void split_label_contents(const string& s, string* label, string* contents) { } bool line_exists_anywhere(const string& label, const string& contents) { - for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { + for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (label != p->label) continue; if (contents == trim(p->contents)) return true; } @@ -301,7 +301,7 @@ int trace_count(string label) { int trace_count(string label, string line) { if (!Trace_stream) return 0; long result = 0; - for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { + for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (label == p->label) { if (line == "" || trim(line) == trim(p->contents)) ++result; @@ -313,7 +313,7 @@ int trace_count(string label, string line) { int trace_count_prefix(string label, string prefix) { if (!Trace_stream) return 0; long result = 0; - for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { + for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (label == p->label) { if (starts_with(trim(p->contents), trim(prefix))) ++result; diff --git a/010vm.cc b/010vm.cc index 21f81d20..d57f7fb2 100644 --- a/010vm.cc +++ b/010vm.cc @@ -63,7 +63,7 @@ struct reagent { void clear(); reagent(const reagent& old); reagent& operator=(const reagent& old); - void set_value(double v) { value = v; initialized = true; } + void set_value(double v) { value = v; initialized = true; } }; :(before "struct reagent") @@ -148,8 +148,8 @@ void setup_types() { // End Mu Types Initialization } void teardown_types() { - for (map::iterator p = Type.begin(); p != Type.end(); ++p) { - for (int i = 0; i < SIZE(p->second.elements); ++i) + for (map::iterator p = Type.begin(); p != Type.end(); ++p) { + for (int i = 0; i < SIZE(p->second.elements); ++i) p->second.elements.clear(); } Type_ordinal.clear(); @@ -262,7 +262,7 @@ recipe::recipe() { instruction::instruction() :is_label(false), operation(IDLE) { // End instruction Constructor } -void instruction::clear() { is_label=false; label.clear(); name.clear(); old_name.clear(); operation=IDLE; ingredients.clear(); products.clear(); original_string.clear(); } +void instruction::clear() { is_label=false; label.clear(); name.clear(); old_name.clear(); operation=IDLE; ingredients.clear(); products.clear(); original_string.clear(); } bool instruction::is_empty() { return !is_label && name.empty(); } // Reagents have the form :::...///... @@ -333,7 +333,7 @@ reagent::reagent(const reagent& other) { name = other.name; value = other.value; initialized = other.initialized; - for (int i = 0; i < SIZE(other.properties); ++i) { + for (int i = 0; i < SIZE(other.properties); ++i) { properties.push_back(pair(other.properties.at(i).first, other.properties.at(i).second ? new string_tree(*other.properties.at(i).second) : NULL)); } @@ -446,10 +446,10 @@ string_tree::string_tree(const string_tree& old) { reagent& reagent::operator=(const reagent& other) { original_string = other.original_string; - for (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 (int i = 0; i < SIZE(other.properties); ++i) + for (int i = 0; i < SIZE(other.properties); ++i) properties.push_back(pair(other.properties.at(i).first, other.properties.at(i).second ? new string_tree(*other.properties.at(i).second) : NULL)); name = other.name; value = other.value; @@ -465,7 +465,7 @@ reagent::~reagent() { } void reagent::clear() { - for (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; @@ -517,14 +517,14 @@ string slurp_until(istream& in, char delim) { } bool has_property(const reagent& x, const string& name) { - for (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 (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; } @@ -545,7 +545,7 @@ void skip_whitespace_but_not_newline(istream& in) { } void dump_memory() { - for (map::iterator p = Memory.begin(); p != Memory.end(); ++p) { + for (map::iterator p = Memory.begin(); p != Memory.end(); ++p) { cout << p->first << ": " << no_scientific(p->second) << '\n'; } } @@ -559,7 +559,7 @@ void dump_memory() { string to_string(const recipe& r) { ostringstream out; out << "recipe " << r.name << " [\n"; - for (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(); @@ -569,14 +569,14 @@ string debug_string(const recipe& x) { ostringstream out; out << "- recipe " << x.name << '\n'; // Begin debug_string(recipe x) - for (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 (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 (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(); @@ -585,13 +585,13 @@ string debug_string(const recipe& x) { string to_original_string(const instruction& inst) { if (inst.is_label) return inst.label; ostringstream out; - for (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 (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; } @@ -601,13 +601,13 @@ string to_original_string(const instruction& inst) { string to_string(const instruction& inst) { if (inst.is_label) return inst.label; ostringstream out; - for (int i = 0; i < SIZE(inst.products); ++i) { + for (int i = 0; i < SIZE(inst.products); ++i) { if (i > 0) out << ", "; out << to_string(inst.products.at(i)); } if (!inst.products.empty()) out << " <- "; out << inst.name << ' '; - for (int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (i > 0) out << ", "; out << to_string(inst.ingredients.at(i)); } @@ -620,7 +620,7 @@ string to_string(const reagent& r) { out << "{"; out << r.name << ": " << names_to_string(r.type); if (!r.properties.empty()) { - for (int i = 0; i < SIZE(r.properties); ++i) + for (int i = 0; i < SIZE(r.properties); ++i) out << ", \"" << r.properties.at(i).first << "\": " << to_string(r.properties.at(i).second); } out << "}"; diff --git a/011load.cc b/011load.cc index ab8973e4..9dc54922 100644 --- a/011load.cc +++ b/011load.cc @@ -121,7 +121,7 @@ bool next_instruction(istream& in, instruction* curr) { vector::iterator p = words.begin(); if (find(words.begin(), words.end(), "<-") != words.end()) { - for (; *p != "<-"; ++p) + for (; *p != "<-"; ++p) curr->products.push_back(reagent(*p)); ++p; // skip <- } @@ -133,14 +133,14 @@ bool next_instruction(istream& in, instruction* curr) { curr->old_name = curr->name = *p; ++p; // curr->operation will be set in a later layer - for (; p != words.end(); ++p) + for (; p != words.end(); ++p) curr->ingredients.push_back(reagent(*p)); trace(9993, "parse") << "instruction: " << curr->name << end(); trace(9993, "parse") << " number of ingredients: " << SIZE(curr->ingredients) << end(); - for (vector::iterator p = curr->ingredients.begin(); p != curr->ingredients.end(); ++p) + for (vector::iterator p = curr->ingredients.begin(); p != curr->ingredients.end(); ++p) trace(9993, "parse") << " ingredient: " << to_string(*p) << end(); - for (vector::iterator p = curr->products.begin(); p != curr->products.end(); ++p) + for (vector::iterator p = curr->products.begin(); p != curr->products.end(); ++p) trace(9993, "parse") << " product: " << to_string(*p) << end(); if (!has_data(in)) { raise << "9: unbalanced '[' for recipe\n" << end(); diff --git a/012transform.cc b/012transform.cc index 7b29d326..e121865d 100644 --- a/012transform.cc +++ b/012transform.cc @@ -45,8 +45,8 @@ void initialize_transforms() { void transform_all() { trace(9990, "transform") << "=== transform_all()" << end(); - for (int t = 0; t < SIZE(Transform); ++t) { - for (map::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { + for (int t = 0; t < SIZE(Transform); ++t) { + for (map::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; if (r.transformed_until != t-1) continue; // End Transform Checks @@ -72,15 +72,15 @@ int Num_calls_to_transform_all = 0; :(code) void parse_int_reagents() { trace(9991, "transform") << "--- parsing any uninitialized reagents as integers" << end(); - for (map::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { + for (map::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; if (r.steps.empty()) continue; - for (int index = 0; index < SIZE(r.steps); ++index) { + for (int index = 0; index < SIZE(r.steps); ++index) { instruction& inst = r.steps.at(index); - for (int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { populate_value(inst.ingredients.at(i)); } - for (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 7ee7ff13..64cd66f8 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 (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/018type_abbreviations.cc b/018type_abbreviations.cc index 1f33a5a6..1e487633 100644 --- a/018type_abbreviations.cc +++ b/018type_abbreviations.cc @@ -107,7 +107,7 @@ restore_type_abbreviations(); atexit(clear_type_abbreviations); :(code) void restore_type_abbreviations() { - for (map::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) { + for (map::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) { if (!contains_key(Type_abbreviations_snapshot, p->first)) delete p->second; } @@ -115,7 +115,7 @@ void restore_type_abbreviations() { Type_abbreviations = Type_abbreviations_snapshot; } void clear_type_abbreviations() { - for (map::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) + for (map::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) delete p->second; Type_abbreviations.clear(); } @@ -169,14 +169,14 @@ void expand_type_abbreviations(const recipe_ordinal r) { void expand_type_abbreviations(const recipe& caller) { trace(9991, "transform") << "--- expand type abbreviations in recipe '" << caller.name << "'" << end(); - for (int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& inst = caller.steps.at(i); trace(9991, "transform") << "instruction '" << inst.original_string << end(); - for (long int i = 0; i < SIZE(inst.ingredients); ++i) { + for (long int i = 0; i < SIZE(inst.ingredients); ++i) { expand_type_abbreviations(inst.ingredients.at(i).type); trace(9992, "transform") << "ingredient type after expanding abbreviations: " << names_to_string(inst.ingredients.at(i).type) << end(); } - for (long int i = 0; i < SIZE(inst.products); ++i) { + for (long int i = 0; i < SIZE(inst.products); ++i) { expand_type_abbreviations(inst.products.at(i).type); trace(9992, "transform") << "product type after expanding abbreviations: " << names_to_string(inst.products.at(i).type) << end(); } diff --git a/020run.cc b/020run.cc index 4be4b30d..70db6015 100644 --- a/020run.cc +++ b/020run.cc @@ -62,7 +62,7 @@ void run(recipe_ordinal r) { void run_current_routine() { while (should_continue_running(Current_routine)) { // beware: later layers modify Current_routine here // Running One Instruction - if (current_instruction().is_label) { ++current_step_index(); continue; } + if (current_instruction().is_label) { ++current_step_index(); continue; } trace(Initial_callstack_depth + Trace_stream->callstack_depth, "run") << to_string(current_instruction()) << end(); if (get_or_insert(Memory, 0) != 0) { raise << "something wrote to location 0; this should never happen\n" << end(); @@ -71,7 +71,7 @@ void run_current_routine() { // read all ingredients from memory, each potentially spanning multiple locations vector > ingredients; if (should_copy_ingredients()) { - for (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' @@ -92,7 +92,7 @@ void run_current_routine() { raise << SIZE(products) << " vs " << SIZE(current_instruction().products) << ": failed to write to all products! " << to_original_string(current_instruction()) << '\n' << end(); } else { - for (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)); } // End Write Products of Instruction @@ -207,15 +207,15 @@ else if (is_equal(*arg, "--trace")) { :(code) void dump_profile() { - for (map::iterator p = Instructions_running.begin(); p != Instructions_running.end(); ++p) { + for (map::iterator p = Instructions_running.begin(); p != Instructions_running.end(); ++p) { cerr << p->first << ": " << p->second << '\n'; } cerr << "== locations read\n"; - for (map::iterator p = Locations_read.begin(); p != Locations_read.end(); ++p) { + for (map::iterator p = Locations_read.begin(); p != Locations_read.end(); ++p) { cerr << p->first << ": " << p->second << '\n'; } cerr << "== locations read by instruction\n"; - for (map::iterator p = Locations_read_by_instruction.begin(); p != Locations_read_by_instruction.end(); ++p) { + for (map::iterator p = Locations_read_by_instruction.begin(); p != Locations_read_by_instruction.end(); ++p) { cerr << p->first << ": " << p->second << '\n'; } } @@ -259,7 +259,7 @@ bool is_directory(string path) { void load_all(string dir) { dirent** files; int num_files = scandir(dir.c_str(), &files, NULL, alphasort); - for (int i = 0; i < num_files; ++i) { + for (int i = 0; i < num_files; ++i) { string curr_file = files[i]->d_name; if (isdigit(curr_file.at(0))) load_file_or_directory(dir+'/'+curr_file); @@ -284,7 +284,7 @@ vector read_memory(reagent/*copy*/ x) { } // End Preprocess read_memory(x) int size = size_of(x); - for (int offset = 0; offset < size; ++offset) { + 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); @@ -311,7 +311,7 @@ void write_memory(reagent/*copy*/ x, const vector& data) { return; } // End write_memory(x) Special-cases - for (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)); diff --git a/021check_instruction.cc b/021check_instruction.cc index ac065abe..c049d619 100644 --- a/021check_instruction.cc +++ b/021check_instruction.cc @@ -15,7 +15,7 @@ Transform.push_back(check_instruction); // idempotent void check_instruction(const recipe_ordinal r) { trace(9991, "transform") << "--- perform checks for recipe " << get(Recipe, r).name << end(); map > metadata; - for (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) { @@ -25,7 +25,7 @@ void check_instruction(const recipe_ordinal r) { raise << maybe(get(Recipe, r).name) << "ingredients and products should match in '" << inst.original_string << "'\n" << end(); break; } - for (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 a56d2b72..f46666f1 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 (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 (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 (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 (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 (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 (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 (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 (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 '" << inst.original_string << "'\n" << end(); break; } - for (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; @@ -741,7 +741,7 @@ case CHARACTER_TO_CODE: { :(before "End Primitive Recipe Implementations") case CHARACTER_TO_CODE: { double result = 0; - for (int i = 0; i < SIZE(ingredients); ++i) { + for (int i = 0; i < SIZE(ingredients); ++i) { result += ingredients.at(i).at(0); } products.resize(1); diff --git a/023boolean.cc b/023boolean.cc index 72037b1d..89dfc8a5 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 (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 (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 (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 (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 << "ingredients and products should match in '" << inst.original_string << "'\n" << end(); break; } - for (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 (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 (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 a57aab88..0c398655 100644 --- a/025compare.cc +++ b/025compare.cc @@ -11,7 +11,7 @@ case EQUAL: { break; } const reagent& exemplar = inst.ingredients.at(0); - for (int i = /*skip exemplar*/1; i < SIZE(inst.ingredients); ++i) { + for (int i = /*skip exemplar*/1; i < SIZE(inst.ingredients); ++i) { if (!types_match(inst.ingredients.at(i), exemplar) && !types_match(exemplar, inst.ingredients.at(i))) { raise << maybe(get(Recipe, r).name) << "'equal' expects ingredients to be all of the same type, but got '" << inst.original_string << "'\n" << end(); goto finish_checking_instruction; @@ -31,7 +31,7 @@ case EQUAL: { case EQUAL: { vector& exemplar = ingredients.at(0); bool result = true; - for (int i = /*skip exemplar*/1; i < SIZE(ingredients); ++i) { + for (int i = /*skip exemplar*/1; i < SIZE(ingredients); ++i) { if (!equal(ingredients.at(i).begin(), ingredients.at(i).end(), exemplar.begin())) { result = false; break; @@ -138,7 +138,7 @@ case GREATER_THAN: { raise << maybe(get(Recipe, r).name) << "'greater-than' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); break; } - for (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; @@ -157,7 +157,7 @@ case GREATER_THAN: { :(before "End Primitive Recipe Implementations") case GREATER_THAN: { bool result = true; - for (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; } @@ -205,7 +205,7 @@ case LESSER_THAN: { raise << maybe(get(Recipe, r).name) << "'lesser-than' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); break; } - for (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; @@ -224,7 +224,7 @@ case LESSER_THAN: { :(before "End Primitive Recipe Implementations") case LESSER_THAN: { bool result = true; - for (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; } @@ -272,7 +272,7 @@ case GREATER_OR_EQUAL: { raise << maybe(get(Recipe, r).name) << "'greater-or-equal' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); break; } - for (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; @@ -291,7 +291,7 @@ case GREATER_OR_EQUAL: { :(before "End Primitive Recipe Implementations") case GREATER_OR_EQUAL: { bool result = true; - for (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; } @@ -347,7 +347,7 @@ case LESSER_OR_EQUAL: { raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); break; } - for (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; @@ -366,7 +366,7 @@ case LESSER_OR_EQUAL: { :(before "End Primitive Recipe Implementations") case LESSER_OR_EQUAL: { bool result = true; - for (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; } @@ -422,7 +422,7 @@ case MAX: { raise << maybe(get(Recipe, r).name) << "'max' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); break; } - for (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) << "'max' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); goto finish_checking_instruction; @@ -441,7 +441,7 @@ case MAX: { :(before "End Primitive Recipe Implementations") case MAX: { int result = ingredients.at(0).at(0); - for (int i = /**/1; i < SIZE(ingredients); ++i) { + for (int i = /**/1; i < SIZE(ingredients); ++i) { if (ingredients.at(i).at(0) > result) { result = ingredients.at(i).at(0); } @@ -461,7 +461,7 @@ case MIN: { raise << maybe(get(Recipe, r).name) << "'min' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); break; } - for (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) << "'min' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); goto finish_checking_instruction; @@ -480,7 +480,7 @@ case MIN: { :(before "End Primitive Recipe Implementations") case MIN: { int result = ingredients.at(0).at(0); - for (int i = /**/1; i < SIZE(ingredients); ++i) { + for (int i = /**/1; i < SIZE(ingredients); ++i) { if (ingredients.at(i).at(0) < result) { result = ingredients.at(i).at(0); } diff --git a/027call_ingredient.cc b/027call_ingredient.cc index 20dc3a36..50348093 100644 --- a/027call_ingredient.cc +++ b/027call_ingredient.cc @@ -28,7 +28,7 @@ int next_ingredient_to_process; next_ingredient_to_process = 0; :(before "End Call Housekeeping") -for (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/*copy*/ ingredient = call_instruction.ingredients.at(i); // End Compute Call Ingredient @@ -78,7 +78,7 @@ case NEXT_INGREDIENT: { products.resize(2); // pad the first product with sufficient zeros to match its type int size = size_of(current_instruction().products.at(0)); - for (int i = 0; i < size; ++i) + for (int i = 0; i < size; ++i) products.at(0).push_back(0); products.at(1).push_back(0); } diff --git a/028call_reply.cc b/028call_reply.cc index 67ca81b3..200c9f9d 100644 --- a/028call_reply.cc +++ b/028call_reply.cc @@ -35,7 +35,7 @@ case RETURN: { Current_routine->calls.pop_front(); // just in case 'main' returns a value, drop it for now if (Current_routine->calls.empty()) goto stop_running_current_routine; - for (int i = 0; i < SIZE(ingredients); ++i) + for (int i = 0; i < SIZE(ingredients); ++i) trace(9998, "run") << "result " << i << " is " << to_string(ingredients.at(i)) << end(); // make reply products available to caller copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin())); @@ -51,13 +51,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 (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 (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 != RETURN) continue; // check types with the caller @@ -65,7 +65,7 @@ void check_types_of_reply_instructions(recipe_ordinal r) { raise << maybe(caller.name) << "too few values returned from " << callee.name << '\n' << end(); break; } - for (int i = 0; i < SIZE(caller_instruction.products); ++i) { + for (int i = 0; i < SIZE(caller_instruction.products); ++i) { reagent/*copy*/ lhs = reply_inst.ingredients.at(i); reagent/*copy*/ rhs = caller_instruction.products.at(i); // End Check RETURN Copy(lhs, rhs) @@ -77,7 +77,7 @@ 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 (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->atom) { @@ -149,7 +149,7 @@ string to_string(const vector& in) { return out.str(); } out << "["; - for (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/029tools.cc b/029tools.cc index b794de21..12a1fdea 100644 --- a/029tools.cc +++ b/029tools.cc @@ -31,7 +31,7 @@ case TRACE: { int depth = ingredients.at(0).at(0); string label = current_instruction().ingredients.at(1).name; ostringstream out; - for (int i = 2; i < SIZE(current_instruction().ingredients); ++i) { + for (int i = 2; i < SIZE(current_instruction().ingredients); ++i) { if (i > 2) out << ' '; out << print_mu(current_instruction().ingredients.at(i), ingredients.at(i)); } @@ -52,7 +52,7 @@ case STASH: { :(before "End Primitive Recipe Implementations") case STASH: { ostringstream out; - for (int i = 0; i < SIZE(current_instruction().ingredients); ++i) { + for (int i = 0; i < SIZE(current_instruction().ingredients); ++i) { if (i) out << ' '; out << print_mu(current_instruction().ingredients.at(i), ingredients.at(i)); } @@ -85,7 +85,7 @@ string print_mu(const reagent& r, const vector& data) { return r.name; // End print Special-cases(r, data) ostringstream out; - for (long long i = 0; i < SIZE(data); ++i) { + for (long long i = 0; i < SIZE(data); ++i) { if (i) out << ' '; out << no_scientific(data.at(i)); } @@ -236,7 +236,7 @@ case _PRINT: { } :(before "End Primitive Recipe Implementations") case _PRINT: { - for (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")) { @@ -249,7 +249,7 @@ case _PRINT: { } } else { - for (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)); @@ -330,7 +330,7 @@ case _LOG: { :(before "End Primitive Recipe Implementations") case _LOG: { ostringstream out; - for (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 3ad38fda..110a8970 100644 --- a/030container.cc +++ b/030container.cc @@ -122,7 +122,7 @@ atexit(clear_container_metadata); :(code) // invariant: Container_metadata always contains a superset of Container_metadata_snapshot void restore_container_metadata() { - for (int i = 0; i < SIZE(Container_metadata); ++i) { + for (int i = 0; i < SIZE(Container_metadata); ++i) { assert(Container_metadata.at(i).first); if (i < SIZE(Container_metadata_snapshot)) { assert(Container_metadata.at(i).first == Container_metadata_snapshot.at(i).first); @@ -135,7 +135,7 @@ void restore_container_metadata() { } void clear_container_metadata() { Container_metadata_snapshot.clear(); - for (int i = 0; i < SIZE(Container_metadata); ++i) { + for (int i = 0; i < SIZE(Container_metadata); ++i) { delete Container_metadata.at(i).first; Container_metadata.at(i).first = NULL; } @@ -180,12 +180,12 @@ Transform.push_back(compute_container_sizes); void compute_container_sizes(recipe_ordinal r) { recipe& caller = get(Recipe, r); trace(9992, "transform") << "--- compute container sizes for " << caller.name << end(); - for (int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { instruction& inst = caller.steps.at(i); trace(9993, "transform") << "- compute container sizes for " << to_string(inst) << end(); - for (int i = 0; i < SIZE(inst.ingredients); ++i) + for (int i = 0; i < SIZE(inst.ingredients); ++i) compute_container_sizes(inst.ingredients.at(i)); - for (int i = 0; i < SIZE(inst.products); ++i) + for (int i = 0; i < SIZE(inst.products); ++i) compute_container_sizes(inst.products.at(i)); } } @@ -237,7 +237,7 @@ void compute_container_sizes(const type_info& container_info, const type_tree* f // (So it can only contain arrays if they're static and include their // length in the type.) container_metadata metadata; - for (int i = 0; i < SIZE(container_info.elements); ++i) { + for (int i = 0; i < SIZE(container_info.elements); ++i) { reagent/*copy*/ element = container_info.elements.at(i); // Compute Container Size(element, full_type) compute_container_sizes(element.type, pending_metadata); @@ -248,7 +248,7 @@ void compute_container_sizes(const type_info& container_info, const type_tree* f } container_metadata& get(vector >& all, const type_tree* key) { - for (int i = 0; i < SIZE(all); ++i) { + for (int i = 0; i < SIZE(all); ++i) { if (matches(all.at(i).first, key)) return all.at(i).second; } @@ -258,7 +258,7 @@ container_metadata& get(vector >& all, cons } bool contains_key(const vector >& all, const type_tree* key) { - for (int i = 0; i < SIZE(all); ++i) { + for (int i = 0; i < SIZE(all); ++i) { if (matches(all.at(i).first, key)) return true; } @@ -635,7 +635,7 @@ case PUT: { // optimization: directly write the element rather than updating 'product' // and writing the entire container // Write Memory in PUT in Run - for (int i = 0; i < SIZE(ingredients.at(2)); ++i) { + for (int i = 0; i < SIZE(ingredients.at(2)); ++i) { trace(9999, "mem") << "storing " << no_scientific(ingredients.at(2).at(i)) << " in location " << address+i << end(); put(Memory, address+i, ingredients.at(2).at(i)); } @@ -815,8 +815,8 @@ Transform.push_back(expand_type_abbreviations_in_containers); // extremely inefficient; we process all types over and over again, once for every single recipe // but it doesn't seem to cause any noticeable slowdown void expand_type_abbreviations_in_containers(unused const recipe_ordinal r) { - for (map::iterator p = Type.begin(); p != Type.end(); ++p) { - for (int i = 0; i < SIZE(p->second.elements); ++i) + for (map::iterator p = Type.begin(); p != Type.end(); ++p) { + for (int i = 0; i < SIZE(p->second.elements); ++i) expand_type_abbreviations(p->second.elements.at(i).type); } } @@ -871,11 +871,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 (int index = 0; index < SIZE(caller.steps); ++index) { + for (int index = 0; index < SIZE(caller.steps); ++index) { instruction& inst = caller.steps.at(index); - for (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), caller, inst); - for (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), caller, inst); } // End check_or_set_invalid_types @@ -933,10 +933,10 @@ check_container_field_types(); :(code) void check_container_field_types() { - for (map::iterator p = Type.begin(); p != Type.end(); ++p) { + for (map::iterator p = Type.begin(); p != Type.end(); ++p) { const type_info& info = p->second; // Check Container Field Types(info) - for (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); } } diff --git a/031merge.cc b/031merge.cc index 9897ebb7..396a3160 100644 --- a/031merge.cc +++ b/031merge.cc @@ -23,8 +23,8 @@ case MERGE: { :(before "End Primitive Recipe Implementations") case MERGE: { products.resize(1); - for (int i = 0; i < SIZE(ingredients); ++i) - for (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; } @@ -115,7 +115,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 (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) { diff --git a/032array.cc b/032array.cc index f92bd113..c2598d91 100644 --- a/032array.cc +++ b/032array.cc @@ -62,7 +62,7 @@ case CREATE_ARRAY: { int size = size_of(product); // in locations trace(9998, "run") << "creating array of size " << size << end(); // initialize array - for (int i = 1; i <= size_of(product); ++i) { + for (int i = 1; i <= size_of(product); ++i) { put(Memory, base_address+i, 0); } // no need to update product @@ -434,7 +434,7 @@ case PUT_INDEX: { // and writing the entire array vector value = read_memory(current_instruction().ingredients.at(2)); // Write Memory in PUT_INDEX in Run - for (int i = 0; i < SIZE(value); ++i) { + for (int i = 0; i < SIZE(value); ++i) { trace(9999, "mem") << "storing " << no_scientific(value.at(i)) << " in location " << address+i << end(); put(Memory, address+i, value.at(i)); } diff --git a/033exclusive_container.cc b/033exclusive_container.cc index d3852d61..a88e684d 100644 --- a/033exclusive_container.cc +++ b/033exclusive_container.cc @@ -46,7 +46,7 @@ void compute_exclusive_container_sizes(const type_info& exclusive_container_info // (So, like containers, it can only contain arrays if they're static and // include their length in the type.) container_metadata metadata; - for (int i = 0; i < SIZE(exclusive_container_info.elements); ++i) { + for (int i = 0; i < SIZE(exclusive_container_info.elements); ++i) { reagent/*copy*/ element = exclusive_container_info.elements.at(i); // Compute Exclusive Container Size(element, full_type) compute_container_sizes(element.type, pending_metadata); @@ -166,7 +166,7 @@ case MAYBE_CONVERT: { put(Memory, status.value, 1); if (!is_dummy(product)) { // Write Memory in Successful MAYBE_CONVERT in Run - for (int i = 0; i < size_of(variant); ++i) { + for (int i = 0; i < size_of(variant); ++i) { double val = get_or_insert(Memory, base_address+/*skip tag*/1+i); trace(9999, "mem") << "storing " << no_scientific(val) << " in location " << product.value+i << end(); put(Memory, product.value+i, val); diff --git a/034address.cc b/034address.cc index dc08d0c3..337ed98e 100644 --- a/034address.cc +++ b/034address.cc @@ -229,7 +229,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 (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") { @@ -299,7 +299,7 @@ int allocate(int size) { const int result = Current_routine->alloc; trace(9999, "mem") << "new alloc: " << result << end(); // initialize allocated space - for (int address = result; address < result+size; ++address) { + for (int address = result; address < result+size; ++address) { trace(9999, "mem") << "storing 0 in location " << address << end(); put(Memory, address, 0); } diff --git a/035lookup.cc b/035lookup.cc index d37a8a35..d6dd86d2 100644 --- a/035lookup.cc +++ b/035lookup.cc @@ -168,7 +168,7 @@ bool canonize_type(reagent& r) { } void drop_one_lookup(reagent& r) { - for (vector >::iterator p = r.properties.begin(); p != r.properties.end(); ++p) { + for (vector >::iterator p = r.properties.begin(); p != r.properties.end(); ++p) { if (p->first == "lookup") { r.properties.erase(p); return; diff --git a/036refcount.cc b/036refcount.cc index 7622232f..5deaa675 100644 --- a/036refcount.cc +++ b/036refcount.cc @@ -182,7 +182,7 @@ def main [ :(after "Write Memory in Successful MAYBE_CONVERT") // TODO: double-check data here as well vector data; -for (int i = 0; i < size_of(product); ++i) +for (int i = 0; i < size_of(product); ++i) data.push_back(get_or_insert(Memory, base_address+/*skip tag*/1+i)); update_any_refcounts(product, data); @@ -286,12 +286,12 @@ Transform.push_back(compute_container_address_offsets); void compute_container_address_offsets(const recipe_ordinal r) { recipe& caller = get(Recipe, r); trace(9992, "transform") << "--- compute address offsets for " << caller.name << end(); - for (int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { instruction& inst = caller.steps.at(i); trace(9993, "transform") << "- compute address offsets for " << to_string(inst) << end(); - for (int i = 0; i < SIZE(inst.ingredients); ++i) + for (int i = 0; i < SIZE(inst.ingredients); ++i) compute_container_address_offsets(inst.ingredients.at(i)); - for (int i = 0; i < SIZE(inst.products); ++i) + for (int i = 0; i < SIZE(inst.products); ++i) compute_container_address_offsets(inst.products.at(i)); } } @@ -341,7 +341,7 @@ void compute_container_address_offsets(const type_info& container_info, const ty void compute_exclusive_container_address_offsets(const type_info& exclusive_container_info, const type_tree* full_type) { container_metadata& metadata = get(Container_metadata, full_type); trace(9994, "transform") << "compute address offsets for exclusive container " << exclusive_container_info.name << end(); - for (int tag = 0; tag < SIZE(exclusive_container_info.elements); ++tag) { + for (int tag = 0; tag < SIZE(exclusive_container_info.elements); ++tag) { set key; key.insert(tag_condition_info(/*tag is at offset*/0, tag)); append_addresses(/*skip tag offset*/1, variant_type(full_type, tag).type, metadata.address, key); @@ -356,7 +356,7 @@ void append_addresses(int base_offset, const type_tree* type, mapvalue); if (info.kind == CONTAINER) { - for (int curr_index = 0, curr_offset = base_offset; curr_index < SIZE(info.elements); ++curr_index) { + for (int curr_index = 0, curr_offset = base_offset; curr_index < SIZE(info.elements); ++curr_index) { trace(9993, "transform") << "checking container " << root->name << ", element " << curr_index << end(); reagent/*copy*/ element = element_type(type, curr_index); // not root // Compute Container Address Offset(element) @@ -372,7 +372,7 @@ void append_addresses(int base_offset, const type_tree* type, mapvalue); - for (int tag = 0; tag < SIZE(element_info.elements); ++tag) { + for (int tag = 0; tag < SIZE(element_info.elements); ++tag) { set new_key = key; new_key.insert(tag_condition_info(curr_offset, tag)); if (!contains_key(out, new_key)) @@ -387,7 +387,7 @@ void append_addresses(int base_offset, const type_tree* type, map new_key = key; new_key.insert(tag_condition_info(base_offset, tag)); if (!contains_key(out, new_key)) @@ -682,9 +682,9 @@ void test_container_address_offsets_from_repeated_address_and_array_types() { :(before "End Increment Refcounts(canonized_x)") if (is_mu_container(canonized_x) || is_mu_exclusive_container(canonized_x)) { const container_metadata& metadata = get(Container_metadata, canonized_x.type); - for (map, set >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { + for (map, set >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { if (!all_match(data, p->first)) continue; - for (set::const_iterator info = p->second.begin(); info != p->second.end(); ++info) + for (set::const_iterator info = p->second.begin(); info != p->second.end(); ++info) increment_refcount(data.at(info->offset)); } } @@ -699,16 +699,16 @@ if (is_mu_container(canonized_x) || is_mu_exclusive_container(canonized_x)) { vector data = read_memory(tmp); trace(9999, "mem") << "done reading old value of '" << to_string(canonized_x) << "'" << end(); const container_metadata& metadata = get(Container_metadata, canonized_x.type); - for (map, set >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { + for (map, set >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { if (!all_match(data, p->first)) continue; - for (set::const_iterator info = p->second.begin(); info != p->second.end(); ++info) + for (set::const_iterator info = p->second.begin(); info != p->second.end(); ++info) decrement_refcount(get_or_insert(Memory, canonized_x.value + info->offset), info->payload_type, size_of(info->payload_type)+/*refcount*/1); } } :(code) bool all_match(const vector& data, const set& conditions) { - for (set::const_iterator p = conditions.begin(); p != conditions.end(); ++p) { + for (set::const_iterator p = conditions.begin(); p != conditions.end(); ++p) { if (data.at(p->offset) != p->tag) return false; } diff --git a/037abandon.cc b/037abandon.cc index c6e7607f..567e7e97 100644 --- a/037abandon.cc +++ b/037abandon.cc @@ -37,7 +37,7 @@ void abandon(int address, const type_tree* payload_type, int payload_size) { int array_length = get_or_insert(Memory, address+/*skip refcount*/1); assert(element.type->name != "array"); int element_size = size_of(element); - for (int i = 0; i < array_length; ++i) { + for (int i = 0; i < array_length; ++i) { element.set_value(address + /*skip refcount and length*/2 + i*element_size); decrement_any_refcounts(element); } @@ -49,7 +49,7 @@ void abandon(int address, const type_tree* payload_type, int payload_size) { decrement_any_refcounts(tmp); } // clear memory - for (int curr = address; curr < address+payload_size; ++curr) + for (int curr = address; curr < address+payload_size; ++curr) put(Memory, curr, 0); // append existing free list to address trace(9999, "abandon") << "saving " << address << " in free-list of size " << payload_size << end(); @@ -64,7 +64,7 @@ if (get_or_insert(Current_routine->free_list, size)) { trace(9999, "mem") << "new alloc from free list: " << result << end(); put(Current_routine->free_list, size, get_or_insert(Memory, result)); put(Memory, result, 0); - for (int curr = result; curr < result+size; ++curr) { + for (int curr = result; 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 diff --git a/038new_text.cc b/038new_text.cc index d5ae7fc0..3283e994 100644 --- a/038new_text.cc +++ b/038new_text.cc @@ -49,7 +49,7 @@ int new_mu_text(const string& contents) { ++curr_address; // skip length int curr = 0; const char* raw_contents = contents.c_str(); - for (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]); @@ -132,7 +132,7 @@ string read_mu_text(int address) { int size = get_or_insert(Memory, address); if (size == 0) return ""; ostringstream tmp; - for (int curr = address+1; curr <= address+size; ++curr) { + for (int curr = address+1; curr <= address+size; ++curr) { tmp << to_unicode(static_cast(get_or_insert(Memory, curr))); } return tmp.str(); diff --git a/039location_array.cc b/039location_array.cc index e43717a5..648ebad6 100644 --- a/039location_array.cc +++ b/039location_array.cc @@ -40,7 +40,7 @@ case TO_LOCATION_ARRAY: { // initialize array length put(Memory, result+1, array_size); // now copy over data - for (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 bfabe5da..bc66749c 100644 --- a/040brace.cc +++ b/040brace.cc @@ -40,7 +40,7 @@ void transform_braces(const recipe_ordinal r) { // use signed integer for step index because we'll be doing arithmetic on it list > braces; trace(9991, "transform") << "--- transform braces for recipe " << get(Recipe, r).name << end(); - for (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(); @@ -52,7 +52,7 @@ void transform_braces(const recipe_ordinal r) { } } stack open_braces; - for (int index = 0; index < SIZE(get(Recipe, r).steps); ++index) { + 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); @@ -134,7 +134,7 @@ void transform_braces(const recipe_ordinal r) { // enable future signed arithmetic int matching_brace(int index, const list >& braces, recipe_ordinal r) { int stacksize = 0; - for (list >::const_iterator p = braces.begin(); p != braces.end(); ++p) { + for (list >::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 d8974398..fc22c659 100644 --- a/041jump_target.cc +++ b/041jump_target.cc @@ -24,7 +24,7 @@ Transform.push_back(transform_labels); // idempotent :(code) void transform_labels(const recipe_ordinal r) { map offset; - for (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 (starts_with(inst.label, "+")) { if (!contains_key(offset, inst.label)) { @@ -37,7 +37,7 @@ void transform_labels(const recipe_ordinal r) { } } } - for (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()) { diff --git a/042name.cc b/042name.cc index 784e7d90..35849997 100644 --- a/042name.cc +++ b/042name.cc @@ -43,11 +43,11 @@ void transform_names(const recipe_ordinal r) { // store the indices 'used' so far in the map int& curr_idx = names[""]; ++curr_idx; // avoid using index 0, benign skip in some other cases - for (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 (int in = 0; in < SIZE(inst.ingredients); ++in) { + for (int in = 0; in < SIZE(inst.ingredients); ++in) { reagent& ingredient = inst.ingredients.at(in); // Begin transform_names Ingredient Special-cases(ingredient, inst, caller) if (is_disqualified(ingredient, inst, caller.name)) continue; @@ -68,7 +68,7 @@ void transform_names(const recipe_ordinal r) { return; } } - for (int out = 0; out < SIZE(inst.products); ++out) { + for (int out = 0; out < SIZE(inst.products); ++out) { reagent& product = inst.products.at(out); // Begin transform_names Product Special-cases(product, inst, caller) if (is_disqualified(product, inst, caller.name)) continue; @@ -124,7 +124,7 @@ type_ordinal skip_addresses(type_tree* type) { int find_element_name(const type_ordinal t, const string& name, const string& recipe_name) { const type_info& container = get(Type, t); - for (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 211d7630..35f01391 100644 --- a/043space.cc +++ b/043space.cc @@ -238,9 +238,9 @@ void try_reclaim_locals() { if (inst.old_name != "local-scope") return; // reclaim any local variables unless they're being returned vector zeros; - for (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 (int i = 0; i < SIZE(inst.products); ++i) { + for (int i = 0; i < SIZE(inst.products); ++i) { const reagent& product = inst.products.at(i); // local variables only if (has_property(product, "lookup")) continue; @@ -265,7 +265,7 @@ bool escaping(const reagent& r) { assert(Current_routine); // run-time only // nothing escapes when you fall through past end of recipe if (current_step_index() >= SIZE(Current_routine->steps())) return false; - for (long long i = 0; i < SIZE(current_instruction().ingredients); ++i) { + for (long long i = 0; i < SIZE(current_instruction().ingredients); ++i) { if (r == current_instruction().ingredients.at(i)) { if (caller_uses_product(i)) return true; @@ -412,7 +412,7 @@ Hide_missing_default_space_errors = false; :(code) bool contains_non_special_name(const recipe_ordinal r) { - for (map::iterator p = Name[r].begin(); p != Name[r].end(); ++p) { + for (map::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)) diff --git a/044space_surround.cc b/044space_surround.cc index b25a2c09..8f05b80c 100644 --- a/044space_surround.cc +++ b/044space_surround.cc @@ -49,7 +49,7 @@ int space_base(const reagent& x, int space_index, int base) { } int space_index(const reagent& x) { - for (int i = 0; i < SIZE(x.properties); ++i) { + 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 4c813d4b..7852b92e 100644 --- a/045closure_name.cc +++ b/045closure_name.cc @@ -38,10 +38,10 @@ Transform.push_back(collect_surrounding_spaces); // idempotent :(code) void collect_surrounding_spaces(const recipe_ordinal r) { trace(9991, "transform") << "--- collect surrounding spaces for recipe " << get(Recipe, r).name << end(); - for (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 (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; if (!is_space(inst.products.at(j))) { @@ -100,7 +100,7 @@ int lookup_name(const reagent& x, const recipe_ordinal r, set& d if (!Name[r].empty()) return Name[r][x.name]; if (contains_key(done, r)) { raise << "can't compute address of '" << to_string(x) << "' because\n" << end(); - for (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(); diff --git a/047check_type_by_name.cc b/047check_type_by_name.cc index b10f657c..62a6107c 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 known; - for (int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { instruction& inst = caller.steps.at(i); - for (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), caller); } - for (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), caller); } diff --git a/050scenario.cc b/050scenario.cc index aa914163..cb16482d 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -119,7 +119,7 @@ Hide_missing_default_space_errors = false; if (Num_core_mu_scenarios) { time(&t); cerr << "Mu tests: " << ctime(&t); - for (int i = 0; i < Num_core_mu_scenarios; ++i) { + for (int i = 0; i < Num_core_mu_scenarios; ++i) { //? cerr << '\n' << i << ": " << Scenarios.at(i).name; run_mu_scenario(Scenarios.at(i)); if (Passed) cerr << "."; @@ -130,7 +130,7 @@ run_app_scenarios: if (Num_core_mu_scenarios != SIZE(Scenarios)) { time(&t); cerr << "App tests: " << ctime(&t); - for (int i = Num_core_mu_scenarios; i < SIZE(Scenarios); ++i) { + for (int i = Num_core_mu_scenarios; i < SIZE(Scenarios); ++i) { //? cerr << '\n' << i << ": " << Scenarios.at(i).name; run_mu_scenario(Scenarios.at(i)); if (Passed) cerr << "."; @@ -153,7 +153,7 @@ if (Test_only_app && Num_core_mu_scenarios < SIZE(Scenarios)) { //: Convenience: run a single named scenario. :(after "Test Runs") -for (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"; @@ -401,7 +401,7 @@ void check_string(int address, const string& literal) { return; } ++address; // now skip length - for (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) { @@ -518,7 +518,7 @@ void check_trace(const string& expected) { vector expected_lines = parse_trace(expected); if (expected_lines.empty()) return; int curr_expected_line = 0; - for (vector::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { + for (vector::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; // match @@ -539,7 +539,7 @@ void check_trace(const string& expected) { vector parse_trace(const string& expected) { vector buf = split(expected, "\n"); vector result; - for (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; int delim = buf.at(i).find(": "); @@ -618,7 +618,7 @@ case TRACE_SHOULD_NOT_CONTAIN: { bool check_trace_missing(const string& in) { Trace_stream->newline(); vector lines = parse_trace(in); - for (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; @@ -736,7 +736,7 @@ void mark_autogenerated(recipe_ordinal r) { } :(after "void transform_all()") - for (map::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { + for (map::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { const recipe& r = p->second; if (r.name.find('_') == string::npos) continue; if (r.is_autogenerated) continue; // created by previous call to transform_all() diff --git a/052tangle.cc b/052tangle.cc index b60105fa..50c74076 100644 --- a/052tangle.cc +++ b/052tangle.cc @@ -79,7 +79,7 @@ void insert_fragments(recipe& r) { made_progress = false; // create a new vector because insertions invalidate iterators vector result; - for (int i = 0; i < SIZE(r.steps); ++i) { + for (int i = 0; i < SIZE(r.steps); ++i) { const instruction& inst = r.steps.at(i); if (!inst.is_label || !is_waypoint(inst.label) || inst.tangle_done) { result.push_back(inst); @@ -115,12 +115,12 @@ void append_fragment(vector& base, const vector& patch // so we'll keep jump targets local to the specific before/after fragment // that introduces them. set jump_targets; - for (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 (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)) @@ -128,7 +128,7 @@ void append_fragment(vector& base, const vector& patch base.push_back(inst); continue; } - for (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)) @@ -152,11 +152,11 @@ bool is_waypoint(string label) { check_insert_fragments(); :(code) void check_insert_fragments() { - for (map::iterator p = Before_fragments.begin(); p != Before_fragments.end(); ++p) { + for (map::iterator p = Before_fragments.begin(); p != Before_fragments.end(); ++p) { if (!contains_key(Fragments_used, p->first)) raise << "could not locate insert before label " << p->first << '\n' << end(); } - for (map::iterator p = After_fragments.begin(); p != After_fragments.end(); ++p) { + for (map::iterator p = After_fragments.begin(); p != After_fragments.end(); ++p) { if (!contains_key(Fragments_used, p->first)) raise << "could not locate insert after label " << p->first << '\n' << end(); } diff --git a/053recipe_header.cc b/053recipe_header.cc index c521eb69..b23614c8 100644 --- a/053recipe_header.cc +++ b/053recipe_header.cc @@ -109,10 +109,10 @@ def main # comment :(after "Begin debug_string(recipe x)") out << "ingredients:\n"; -for (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 (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. @@ -126,7 +126,7 @@ def test [ :(before "End Recipe Body(result)") if (!result.has_header) { result.has_header = true; - for (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()) @@ -158,9 +158,9 @@ def foo -> a:text [ # 'text' is an abbreviation +mem: storing 97 in location 1 :(before "End Expand Type Abbreviations(caller)") -for (long int i = 0; i < SIZE(caller.ingredients); ++i) +for (long int i = 0; i < SIZE(caller.ingredients); ++i) expand_type_abbreviations(caller.ingredients.at(i).type); -for (long int i = 0; i < SIZE(caller.products); ++i) +for (long int i = 0; i < SIZE(caller.products); ++i) expand_type_abbreviations(caller.products.at(i).type); //: Rewrite 'load-ingredients' to instructions to create all reagents in the header. @@ -169,7 +169,7 @@ for (long int i = 0; i < SIZE(caller.products); ++i) if (curr.name == "load-ingredients") { curr.clear(); recipe_ordinal op = get(Recipe_ordinal, "next-ingredient-without-typechecking"); - for (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)); @@ -205,7 +205,7 @@ case NEXT_INGREDIENT_WITHOUT_TYPECHECKING: { products.resize(2); // pad the first product with sufficient zeros to match its type int size = size_of(current_instruction().products.at(0)); - for (int i = 0; i < size; ++i) + for (int i = 0; i < size; ++i) products.at(0).push_back(0); products.at(1).push_back(0); } @@ -244,17 +244,17 @@ Transform.push_back(check_calls_against_header); // idempotent void check_calls_against_header(const recipe_ordinal r) { const recipe& caller = get(Recipe, r); trace(9991, "transform") << "--- type-check calls inside recipe " << caller.name << end(); - for (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); if (!callee.has_header) continue; - for (long int i = 0; i < min(SIZE(inst.ingredients), SIZE(callee.ingredients)); ++i) { + for (long int i = 0; i < min(SIZE(inst.ingredients), SIZE(callee.ingredients)); ++i) { // ingredients coerced from call to callee if (!types_coercible(callee.ingredients.at(i), inst.ingredients.at(i))) raise << maybe(caller.name) << "ingredient " << i << " has the wrong type at '" << inst.original_string << "'\n" << end(); } - for (long int i = 0; i < min(SIZE(inst.products), SIZE(callee.products)); ++i) { + for (long int i = 0; i < min(SIZE(inst.products), SIZE(callee.products)); ++i) { if (is_dummy(inst.products.at(i))) continue; // products coerced from callee to call if (!types_coercible(inst.products.at(i), callee.products.at(i))) @@ -284,14 +284,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 (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 '" << inst.original_string << "'\n" << end(); continue; } - for (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 '" << inst.original_string << "'\n" << end(); } @@ -329,7 +329,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 (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); @@ -360,20 +360,20 @@ 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 header_type; - for (int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { + for (int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { if (!caller_recipe.ingredients.at(i).type) continue; // error handled elsewhere 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 (int i = 0; i < SIZE(caller_recipe.products); ++i) { + for (int i = 0; i < SIZE(caller_recipe.products); ++i) { if (!caller_recipe.products.at(i).type) continue; // error handled elsewhere 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 (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 (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; @@ -381,7 +381,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 (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()) @@ -416,7 +416,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 (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); @@ -435,7 +435,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 (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/054static_dispatch.cc b/054static_dispatch.cc index a2cbe17a..79537a7c 100644 --- a/054static_dispatch.cc +++ b/054static_dispatch.cc @@ -55,7 +55,7 @@ else { :(code) string matching_variant_name(const recipe& rr) { const vector& variants = get_or_insert(Recipe_variants, rr.name); - for (int i = 0; i < SIZE(variants); ++i) { + for (int i = 0; i < SIZE(variants); ++i) { if (!contains_key(Recipe, variants.at(i))) continue; const recipe& candidate = get(Recipe, variants.at(i)); if (!all_reagents_match(rr, candidate)) continue; @@ -67,13 +67,13 @@ string matching_variant_name(const recipe& rr) { bool all_reagents_match(const recipe& r1, const recipe& r2) { if (SIZE(r1.ingredients) != SIZE(r2.ingredients)) return false; if (SIZE(r1.products) != SIZE(r2.products)) return false; - for (int i = 0; i < SIZE(r1.ingredients); ++i) { + for (int i = 0; i < SIZE(r1.ingredients); ++i) { expand_type_abbreviations(r1.ingredients.at(i).type); expand_type_abbreviations(r2.ingredients.at(i).type); if (!deeply_equal_type_names(r1.ingredients.at(i), r2.ingredients.at(i))) return false; } - for (int i = 0; i < SIZE(r1.products); ++i) { + for (int i = 0; i < SIZE(r1.products); ++i) { expand_type_abbreviations(r1.products.at(i).type); expand_type_abbreviations(r2.products.at(i).type); if (!deeply_equal_type_names(r1.products.at(i), r2.products.at(i))) @@ -106,7 +106,7 @@ bool deeply_equal_type_names(const type_tree* a, const type_tree* b) { } string next_unused_recipe_name(const string& recipe_name) { - for (int i = 2; ; ++i) { + for (int i = 2; /*forever*/; ++i) { ostringstream out; out << recipe_name << '_' << i; if (!contains_key(Recipe_ordinal, out.str())) @@ -131,9 +131,9 @@ def test a:num, b:num -> z:num [ //: support recipe headers in a previous transform to fill in missing types :(before "End check_or_set_invalid_types") -for (int i = 0; i < SIZE(caller.ingredients); ++i) +for (int i = 0; i < SIZE(caller.ingredients); ++i) check_or_set_invalid_types(caller.ingredients.at(i).type, maybe(caller.name), "recipe header ingredient"); -for (int i = 0; i < SIZE(caller.products); ++i) +for (int i = 0; i < SIZE(caller.products); ++i) check_or_set_invalid_types(caller.products.at(i).type, maybe(caller.name), "recipe header product"); //: after filling in all missing types (because we'll be introducing 'blank' types in this transform in a later layer, for shape-shifting recipes) @@ -153,7 +153,7 @@ list resolve_stack; void resolve_ambiguous_calls(recipe_ordinal r) { recipe& caller_recipe = get(Recipe, r); trace(9991, "transform") << "--- resolve ambiguous calls for recipe " << caller_recipe.name << end(); - for (int index = 0; index < SIZE(caller_recipe.steps); ++index) { + for (int index = 0; index < SIZE(caller_recipe.steps); ++index) { instruction& inst = caller_recipe.steps.at(index); if (inst.is_label) continue; if (non_ghost_size(get_or_insert(Recipe_variants, inst.name)) == 0) continue; @@ -196,7 +196,7 @@ string best_variant(instruction& inst, const recipe& caller_recipe) { // error messages if (get(Recipe_ordinal, inst.name) >= MAX_PRIMITIVE_RECIPES) { // we currently don't check types for primitive variants raise << maybe(caller_recipe.name) << "failed to find a matching call for '" << inst.original_string << "'\n" << end(); - for (list::iterator p = /*skip*/++resolve_stack.begin(); p != resolve_stack.end(); ++p) { + for (list::iterator p = /*skip*/++resolve_stack.begin(); p != resolve_stack.end(); ++p) { const recipe& specializer_recipe = get(Recipe, p->running_recipe); const instruction& specializer_inst = specializer_recipe.steps.at(p->running_step_index); if (specializer_recipe.name != "interactive") @@ -221,7 +221,7 @@ string best_variant(instruction& inst, const recipe& caller_recipe) { // phase 1 vector strictly_matching_variants(const instruction& inst, vector& variants) { vector result; - for (int i = 0; i < SIZE(variants); ++i) { + for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; trace(9992, "transform") << "checking variant (strict) " << i << ": " << header_label(variants.at(i)) << end(); if (all_header_reagents_strictly_match(inst, get(Recipe, variants.at(i)))) @@ -231,13 +231,13 @@ vector strictly_matching_variants(const instruction& inst, vecto } bool all_header_reagents_strictly_match(const instruction& inst, const recipe& variant) { - for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { + for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { if (!types_strictly_match(variant.ingredients.at(i), inst.ingredients.at(i))) { trace(9993, "transform") << "strict match failed: ingredient " << i << end(); return false; } } - for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.products)); ++i) { + for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.products)); ++i) { if (is_dummy(inst.products.at(i))) continue; if (!types_strictly_match(variant.products.at(i), inst.products.at(i))) { trace(9993, "transform") << "strict match failed: product " << i << end(); @@ -250,7 +250,7 @@ bool all_header_reagents_strictly_match(const instruction& inst, const recipe& v // phase 2 vector strictly_matching_variants_except_literal_zero_against_address(const instruction& inst, vector& variants) { vector result; - for (int i = 0; i < SIZE(variants); ++i) { + for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; trace(9992, "transform") << "checking variant (strict except literal-zero-against-address) " << i << ": " << header_label(variants.at(i)) << end(); if (all_header_reagents_strictly_match_except_literal_zero_against_address(inst, get(Recipe, variants.at(i)))) @@ -260,13 +260,13 @@ vector strictly_matching_variants_except_literal_zero_against_ad } bool all_header_reagents_strictly_match_except_literal_zero_against_address(const instruction& inst, const recipe& variant) { - for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { + for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { if (!types_strictly_match_except_literal_zero_against_address(variant.ingredients.at(i), inst.ingredients.at(i))) { trace(9993, "transform") << "match failed: ingredient " << i << end(); return false; } } - for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.products)); ++i) { + for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.products)); ++i) { if (is_dummy(inst.products.at(i))) continue; if (!types_strictly_match(variant.products.at(i), inst.products.at(i))) { trace(9993, "transform") << "match failed: product " << i << end(); @@ -285,7 +285,7 @@ bool types_strictly_match_except_literal_zero_against_address(const reagent& to, // phase 4 vector strictly_matching_variants_except_literal_against_address_or_boolean(const instruction& inst, vector& variants) { vector result; - for (int i = 0; i < SIZE(variants); ++i) { + for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; trace(9992, "transform") << "checking variant (strict except literal-against-boolean) " << i << ": " << header_label(variants.at(i)) << end(); if (all_header_reagents_strictly_match_except_literal_against_address_or_boolean(inst, get(Recipe, variants.at(i)))) @@ -295,13 +295,13 @@ vector strictly_matching_variants_except_literal_against_address } bool all_header_reagents_strictly_match_except_literal_against_address_or_boolean(const instruction& inst, const recipe& variant) { - for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { + for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { if (!types_strictly_match_except_literal_against_address_or_boolean(variant.ingredients.at(i), inst.ingredients.at(i))) { trace(9993, "transform") << "match failed: ingredient " << i << end(); return false; } } - for (int i = 0; i < min(SIZE(variant.products), SIZE(inst.products)); ++i) { + for (int i = 0; i < min(SIZE(variant.products), SIZE(inst.products)); ++i) { if (is_dummy(inst.products.at(i))) continue; if (!types_strictly_match_except_literal_against_address_or_boolean(variant.products.at(i), inst.products.at(i))) { trace(9993, "transform") << "match failed: product " << i << end(); @@ -320,7 +320,7 @@ bool types_strictly_match_except_literal_against_address_or_boolean(const reagen // phase 5 vector matching_variants(const instruction& inst, vector& variants) { vector result; - for (int i = 0; i < SIZE(variants); ++i) { + for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; trace(9992, "transform") << "checking variant " << i << ": " << header_label(variants.at(i)) << end(); if (all_header_reagents_match(inst, get(Recipe, variants.at(i)))) @@ -330,13 +330,13 @@ vector matching_variants(const instruction& inst, vector& cand assert(!candidates.empty()); int min_score = 999; int min_index = 0; - for (int i = 0; i < SIZE(candidates); ++i) { + for (int i = 0; i < SIZE(candidates); ++i) { const recipe& candidate = get(Recipe, candidates.at(i)); int score = abs(SIZE(candidate.products)-SIZE(inst.products)) + abs(SIZE(candidate.ingredients)-SIZE(inst.ingredients)); @@ -366,7 +366,7 @@ const recipe& best_variant(const instruction& inst, vector& cand int non_ghost_size(vector& variants) { int result = 0; - for (int i = 0; i < SIZE(variants); ++i) + for (int i = 0; i < SIZE(variants); ++i) if (variants.at(i) != -1) ++result; return result; } @@ -374,7 +374,7 @@ int non_ghost_size(vector& variants) { bool next_stash(const call& c, instruction* stash_inst) { const recipe& specializer_recipe = get(Recipe, c.running_recipe); int index = c.running_step_index; - for (++index; index < SIZE(specializer_recipe.steps); ++index) { + for (++index; index < SIZE(specializer_recipe.steps); ++index) { const instruction& inst = specializer_recipe.steps.at(index); if (inst.name == "stash") { *stash_inst = inst; @@ -564,10 +564,10 @@ string header_label(recipe_ordinal r) { string header_label(const recipe& caller) { ostringstream out; out << "recipe " << caller.name; - for (int i = 0; i < SIZE(caller.ingredients); ++i) + for (int i = 0; i < SIZE(caller.ingredients); ++i) out << ' ' << to_string(caller.ingredients.at(i)); if (!caller.products.empty()) out << " ->"; - for (int i = 0; i < SIZE(caller.products); ++i) + for (int i = 0; i < SIZE(caller.products); ++i) out << ' ' << to_string(caller.products.at(i)); return out.str(); } diff --git a/055shape_shifting_container.cc b/055shape_shifting_container.cc index f0a3924f..33746c46 100644 --- a/055shape_shifting_container.cc +++ b/055shape_shifting_container.cc @@ -177,7 +177,7 @@ bool slurp_type_ingredients(istream& in, map& out, const s bool type_ingredients_match(const map& a, const map& b) { if (SIZE(a) != SIZE(b)) return false; - for (map::const_iterator p = a.begin(); p != a.end(); ++p) { + for (map::const_iterator p = a.begin(); p != a.end(); ++p) { if (!contains_key(b, p->first)) return false; if (p->second != get(b, p->first)) return false; } @@ -341,7 +341,7 @@ void replace_type_ingredients(type_tree* element_type, const type_tree* callsite const type_tree* nth_type_ingredient(const type_tree* callsite_type, int type_ingredient_index, const type_info& container_info) { bool final = final_type_ingredient(type_ingredient_index, container_info); const type_tree* curr = callsite_type; - for (int i = 0; i < type_ingredient_index; ++i) { + for (int i = 0; i < type_ingredient_index; ++i) { assert(curr); assert(!curr->atom); //? cerr << "type ingredient " << i << " is " << to_string(curr->left) << '\n'; diff --git a/056shape_shifting_recipe.cc b/056shape_shifting_recipe.cc index 5fe78b22..ac4c426c 100644 --- a/056shape_shifting_recipe.cc +++ b/056shape_shifting_recipe.cc @@ -65,7 +65,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 (int t = 0; t < SIZE(Transform); ++t) { + for (int t = 0; t < SIZE(Transform); ++t) { // one exception: skip tangle, which would have already occurred inside new_variant above if (Transform.at(t) == /*disambiguate overloading*/static_cast(insert_fragments)) continue; @@ -99,7 +99,7 @@ bool types_strictly_match_except_literal_zero_against_address(const reagent& to, // phase 3 of static dispatch vector strictly_matching_shape_shifting_variants(const instruction& inst, vector& variants) { vector result; - for (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)))) continue; @@ -109,13 +109,13 @@ vector strictly_matching_shape_shifting_variants(const instructi } bool all_concrete_header_reagents_strictly_match(const instruction& inst, const recipe& variant) { - for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { + for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { if (!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 (int i = 0; i < min(SIZE(inst.products), SIZE(variant.ingredients)); ++i) { + for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.ingredients)); ++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(); @@ -130,7 +130,7 @@ recipe_ordinal best_shape_shifting_variant(const instruction& inst, vector -1); if (score > max_score) max_score = score; @@ -138,7 +138,7 @@ recipe_ordinal best_shape_shifting_variant(const instruction& inst, vector::iterator p = mappings.begin(); p != mappings.end(); ++p) + for (map::iterator p = mappings.begin(); p != mappings.end(); ++p) delete p->second; if (error) return 0; } @@ -264,16 +264,16 @@ recipe_ordinal new_variant(recipe_ordinal exemplar, const instruction& inst, con void compute_type_names(recipe& variant) { trace(9993, "transform") << "-- compute type names: " << variant.name << end(); map type_names; - for (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 (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 (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 (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, " in '" + inst.original_string + "'"); - for (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, " in '" + inst.original_string + "'"); } } @@ -297,7 +297,7 @@ void save_or_deduce_type_name(reagent& x, map& type, const r void compute_type_ingredient_mappings(const recipe& exemplar, const instruction& inst, map& mappings, const recipe& caller_recipe, bool* error) { int limit = min(SIZE(inst.ingredients), SIZE(exemplar.ingredients)); - for (int i = 0; i < limit; ++i) { + for (int i = 0; i < limit; ++i) { const reagent& exemplar_reagent = exemplar.ingredients.at(i); reagent/*copy*/ ingredient = inst.ingredients.at(i); canonize_type(ingredient); @@ -305,7 +305,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 (int i = 0; i < limit; ++i) { + for (int i = 0; i < limit; ++i) { const reagent& exemplar_reagent = exemplar.products.at(i); reagent/*copy*/ product = inst.products.at(i); if (is_dummy(product)) continue; @@ -363,18 +363,18 @@ void replace_type_ingredients(recipe& new_recipe, const mapname != "literal-string") { @@ -425,9 +425,9 @@ void replace_type_ingredients(type_tree* type, const map type_ingredients; - for (int i = 0; i < SIZE(caller.ingredients); ++i) + for (int i = 0; i < SIZE(caller.ingredients); ++i) accumulate_type_ingredients(caller.ingredients.at(i).type, type_ingredients); - for (int i = 0; i < SIZE(caller.products); ++i) + for (int i = 0; i < SIZE(caller.products); ++i) accumulate_type_ingredients(caller.products.at(i).type, type_ingredients); return SIZE(type_ingredients); } @@ -458,7 +458,7 @@ void dump_inspect(const type_tree* x, ostream& out) { return; } out << '('; - for (const type_tree* curr = x; curr; curr = curr->right) { + for (const type_tree* curr = x; curr; curr = curr->right) { if (curr != x) out << ' '; if (curr->left) dump_inspect(curr->left, out); @@ -470,15 +470,15 @@ void dump_inspect(const type_tree* x, ostream& out) { void ensure_all_concrete_types(/*const*/ recipe& new_recipe, const recipe& exemplar) { trace(9993, "transform") << "-- ensure all concrete types in recipe " << new_recipe.name << end(); - for (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 (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 (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 (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 (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/057immutable.cc b/057immutable.cc index 6a5d97d6..7cd06f6f 100644 --- a/057immutable.cc +++ b/057immutable.cc @@ -345,13 +345,13 @@ 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 (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_present_in_products(caller, current_ingredient.name)) continue; // not expected to be immutable // End Immutable Ingredients Special-cases set immutable_vars; immutable_vars.insert(current_ingredient); - for (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); if (inst.operation == INDEX && inst.ingredients.at(1).name == current_ingredient.name) continue; @@ -366,7 +366,7 @@ void update_aliases(const instruction& inst, set& current_ingredient_an // primitive recipe switch (inst.operation) { case COPY: - for (set::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) + for (set::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: @@ -384,7 +384,7 @@ void update_aliases(const instruction& inst, set& current_ingredient_an else { // defined recipe set contained_in_product_indices = scan_contained_in_product_indices(inst, current_ingredient_indices); - for (set::iterator p = contained_in_product_indices.begin(); p != contained_in_product_indices.end(); ++p) { + for (set::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)); } @@ -394,12 +394,12 @@ void update_aliases(const instruction& inst, set& current_ingredient_an set scan_contained_in_product_indices(const instruction& inst, set& ingredient_indices) { set selected_ingredients; const recipe& callee = get(Recipe, inst.operation); - for (set::iterator p = ingredient_indices.begin(); p != ingredient_indices.end(); ++p) { + for (set::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 result; - for (int i = 0; i < SIZE(callee.products); ++i) { + 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"); @@ -437,7 +437,7 @@ def test-next x:&:test-list -> y:&:test-list/contained-in:x [ :(code) void check_immutable_ingredient_in_instruction(const instruction& inst, const set& 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 (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()) { string current_product_name = inst.products.at(i).name; @@ -451,7 +451,7 @@ void check_immutable_ingredient_in_instruction(const instruction& inst, const se // check if there's any indirect modification going on set current_ingredient_indices = ingredient_indices(inst, current_ingredient_and_aliases); if (current_ingredient_indices.empty()) return; // ingredient not found in call - for (set::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) { + for (set::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); @@ -494,7 +494,7 @@ bool is_modified_in_recipe(recipe_ordinal r, int ingredient_index, const recipe& } bool is_present_in_products(const recipe& callee, const string& ingredient_name) { - for (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; } @@ -502,7 +502,7 @@ 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 (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; } @@ -511,7 +511,7 @@ bool is_present_in_ingredients(const recipe& callee, const string& ingredient_na set ingredient_indices(const instruction& inst, const set& ingredient_names) { set result; - for (int i = 0; i < SIZE(inst.ingredients); ++i) { + 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/060rewrite_literal_string.cc b/060rewrite_literal_string.cc index fa59db87..e8e0bc5a 100644 --- a/060rewrite_literal_string.cc +++ b/060rewrite_literal_string.cc @@ -39,10 +39,10 @@ void rewrite_literal_string_to_text(recipe_ordinal r) { trace(9991, "transform") << "--- rewrite literal strings in recipe " << caller.name << end(); if (contains_numeric_locations(caller)) return; vector new_instructions; - for (int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { instruction& inst = caller.steps.at(i); if (recipes_taking_literal_strings.find(inst.name) == recipes_taking_literal_strings.end()) { - for (int j = 0; j < SIZE(inst.ingredients); ++j) { + for (int j = 0; j < SIZE(inst.ingredients); ++j) { if (!is_literal_text(inst.ingredients.at(j))) continue; instruction def; ostringstream ingredient_name; @@ -61,12 +61,12 @@ void rewrite_literal_string_to_text(recipe_ordinal r) { } bool contains_numeric_locations(const recipe& caller) { - for (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 (int in = 0; in < SIZE(inst.ingredients); ++in) + for (int in = 0; in < SIZE(inst.ingredients); ++in) if (is_numeric_location(inst.ingredients.at(in))) return true; - for (int out = 0; out < SIZE(inst.products); ++out) + for (int out = 0; out < SIZE(inst.products); ++out) if (is_numeric_location(inst.products.at(out))) return true; } diff --git a/062convert_ingredients_to_text.cc b/062convert_ingredients_to_text.cc index a223992b..43c459f5 100644 --- a/062convert_ingredients_to_text.cc +++ b/062convert_ingredients_to_text.cc @@ -67,11 +67,11 @@ void convert_ingredients_to_text(recipe_ordinal r) { void convert_ingredients_to_text(recipe& caller) { vector new_instructions; - for (int i = 0; i < SIZE(caller.steps); ++i) { + for (int i = 0; i < SIZE(caller.steps); ++i) { instruction& inst = caller.steps.at(i); // all these cases are getting hairy. how can we make this extensible? if (inst.name == "stash") { - for (int j = 0; j < SIZE(inst.ingredients); ++j) { + for (int j = 0; j < SIZE(inst.ingredients); ++j) { if (is_literal_text(inst.ingredients.at(j))) continue; ostringstream ingredient_name; ingredient_name << "stash_" << i << '_' << j << ":address:array:character"; @@ -79,7 +79,7 @@ void convert_ingredients_to_text(recipe& caller) { } } else if (inst.name == "trace") { - for (int j = /*skip*/2; j < SIZE(inst.ingredients); ++j) { + for (int j = /*skip*/2; j < SIZE(inst.ingredients); ++j) { if (is_literal_text(inst.ingredients.at(j))) continue; ostringstream ingredient_name; ingredient_name << "trace_" << i << '_' << j << ":address:array:character"; @@ -93,7 +93,7 @@ void convert_ingredients_to_text(recipe& caller) { // append _:text, ___ // will never ever get used. if (is_literal_text(inst.ingredients.at(0)) || is_mu_text(inst.ingredients.at(0))) { - for (int j = 0; j < SIZE(inst.ingredients); ++j) { + for (int j = 0; j < SIZE(inst.ingredients); ++j) { ostringstream ingredient_name; ingredient_name << "append_" << i << '_' << j << ":address:array:character"; convert_ingredient_to_text(inst.ingredients.at(j), new_instructions, ingredient_name.str()); diff --git a/069hash.cc b/069hash.cc index f269cf18..ac301b5c 100644 --- a/069hash.cc +++ b/069hash.cc @@ -67,7 +67,7 @@ size_t hash_mu_address(size_t h, reagent& r) { size_t hash_mu_text(size_t h, const reagent& r) { string input = read_mu_text(get_or_insert(Memory, r.value)); - for (int i = 0; i < SIZE(input); ++i) { + for (int i = 0; i < SIZE(input); ++i) { h = hash_iter(h, static_cast(input.at(i))); //? cerr << i << ": " << h << '\n'; } @@ -79,7 +79,7 @@ size_t hash_mu_array(size_t h, const reagent& r) { reagent/*copy*/ elem = r; delete elem.type; elem.type = copy_array_element(r.type); - for (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/*copy*/ tmp = elem; tmp.set_value(address); h = hash(h, tmp); @@ -92,7 +92,7 @@ size_t hash_mu_container(size_t h, const reagent& r) { type_info& info = get(Type, root_type(r.type)->value); int address = r.value; int offset = 0; - for (int i = 0; i < SIZE(info.elements); ++i) { + for (int i = 0; i < SIZE(info.elements); ++i) { reagent/*copy*/ element = element_type(r.type, i); if (has_property(element, "ignore-for-hash")) continue; element.set_value(address+offset); @@ -365,7 +365,7 @@ case HASH_OLD: { string input = read_mu_text(ingredients.at(0).at(0)); size_t h = 0 ; - for (int i = 0; i < SIZE(input); ++i) { + for (int i = 0; i < SIZE(input); ++i) { h += static_cast(input.at(i)); h += (h<<10); h ^= (h>>6); diff --git a/071recipe.cc b/071recipe.cc index 6be95c4b..8a3d8824 100644 --- a/071recipe.cc +++ b/071recipe.cc @@ -58,11 +58,11 @@ void initialize_recipe_literal(reagent& x) { x.set_value(get(Recipe_ordinal, x.name)); } bool contains_reagent_with_type(const recipe& caller, const string& name) { - for (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 (int i = 0; i < SIZE(inst.ingredients); ++i) + for (int i = 0; i < SIZE(inst.ingredients); ++i) if (is_matching_non_recipe_literal(inst.ingredients.at(i), name)) return true; - for (int i = 0; i < SIZE(inst.products); ++i) + for (int i = 0; i < SIZE(inst.products); ++i) if (is_matching_non_recipe_literal(inst.products.at(i), name)) return true; } return false; @@ -156,7 +156,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 (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 @@ -164,11 +164,11 @@ void check_indirect_calls_against_header(const recipe_ordinal r) { if (!is_mu_recipe(callee)) continue; // error raised above const recipe callee_header = is_literal(callee) ? get(Recipe, callee.value) : from_reagent(inst.ingredients.at(0)); if (!callee_header.has_header) continue; - for (long int i = /*skip callee*/1; i < min(SIZE(inst.ingredients), SIZE(callee_header.ingredients)+/*skip callee*/1); ++i) { + for (long int i = /*skip callee*/1; i < min(SIZE(inst.ingredients), SIZE(callee_header.ingredients)+/*skip callee*/1); ++i) { if (!types_coercible(callee_header.ingredients.at(i-/*skip callee*/1), inst.ingredients.at(i))) raise << maybe(caller.name) << "ingredient " << i-/*skip callee*/1 << " has the wrong type at '" << inst.original_string << "'\n" << end(); } - for (long int i = 0; i < min(SIZE(inst.products), SIZE(callee_header.products)); ++i) { + for (long int i = 0; i < min(SIZE(inst.products), SIZE(callee_header.products)); ++i) { if (is_dummy(inst.products.at(i))) continue; if (!types_coercible(callee_header.products.at(i), inst.products.at(i))) raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << inst.original_string << "'\n" << end(); @@ -186,7 +186,7 @@ recipe from_reagent(const reagent& r) { } assert(root_type(r.type)->name == "recipe"); const type_tree* curr = r.type->right; - for (/*nada*/; curr && !curr->atom; curr = curr->right) { + for (/*nada*/; curr && !curr->atom; curr = curr->right) { if (curr->left->atom && curr->left->name == "->") { curr = curr->right; // skip delimiter goto read_products; @@ -199,7 +199,7 @@ recipe from_reagent(const reagent& r) { return result_header; // no products } read_products: - for (/*nada*/; curr && !curr->atom; curr = curr->right) + for (/*nada*/; curr && !curr->atom; curr = curr->right) result_header.products.push_back(next_recipe_reagent(curr->left)); if (curr) { assert(curr->atom); @@ -286,11 +286,11 @@ if (is_mu_recipe(to)) { } const recipe& rrhs = get(Recipe, from.value); const recipe& rlhs = from_reagent(to); - for (long int i = 0; i < min(SIZE(rlhs.ingredients), SIZE(rrhs.ingredients)); ++i) { + for (long int i = 0; i < min(SIZE(rlhs.ingredients), SIZE(rrhs.ingredients)); ++i) { if (!types_match(rlhs.ingredients.at(i), rrhs.ingredients.at(i))) return false; } - for (long int i = 0; i < min(SIZE(rlhs.products), SIZE(rrhs.products)); ++i) { + for (long int i = 0; i < min(SIZE(rlhs.products), SIZE(rrhs.products)); ++i) { if (!types_match(rlhs.products.at(i), rrhs.products.at(i))) return false; } @@ -331,7 +331,7 @@ check_for_recipe_literals(inst, get(Recipe, r)); check_for_recipe_literals(inst, get(Recipe, r)); :(code) void check_for_recipe_literals(const instruction& inst, const recipe& caller) { - for (int i = 0; i < SIZE(inst.ingredients); ++i) { + for (int i = 0; i < SIZE(inst.ingredients); ++i) { if (is_mu_recipe(inst.ingredients.at(i))) raise << maybe(caller.name) << "missing type for " << inst.ingredients.at(i).original_string << " in '" << inst.original_string << "'\n" << end(); } diff --git a/072scheduler.cc b/072scheduler.cc index 411635de..593dac9c 100644 --- a/072scheduler.cc +++ b/072scheduler.cc @@ -80,7 +80,7 @@ void run(routine* rr) { } bool all_routines_done() { - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state == RUNNING) return false; } @@ -107,7 +107,7 @@ string current_routine_label() { string routine_label(routine* r) { ostringstream result; const call_stack& calls = r->calls; - for (call_stack::const_iterator p = calls.begin(); p != calls.end(); ++p) { + for (call_stack::const_iterator p = calls.begin(); p != calls.end(); ++p) { if (p != calls.begin()) result << '/'; result << get(Recipe, p->running_recipe).name; } @@ -115,7 +115,7 @@ string routine_label(routine* r) { } :(before "End Teardown") -for (int i = 0; i < SIZE(Routines); ++i) +for (int i = 0; i < SIZE(Routines); ++i) delete Routines.at(i); Routines.clear(); Current_routine = NULL; @@ -129,7 +129,7 @@ void run_main(int argc, char* argv[]) { // pass in commandline args as ingredients to main // todo: test this Current_routine = main_routine; - for (int i = 1; i < argc; ++i) { + for (int i = 1; i < argc; ++i) { vector arg; arg.push_back(new_mu_text(argv[i])); current_call().ingredient_atoms.push_back(arg); @@ -179,7 +179,7 @@ case START_RUNNING: { routine* new_routine = new routine(ingredients.at(0).at(0)); new_routine->parent_index = Current_routine_index; // populate ingredients - for (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/*copy*/ ingredient = current_instruction().ingredients.at(i); canonize_type(ingredient); @@ -382,7 +382,7 @@ def f1 [ -schedule: f1 :(before "End Scheduler Cleanup") -for (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 // structured concurrency: http://250bpm.com/blog:71 @@ -393,7 +393,7 @@ for (int i = 0; i < SIZE(Routines); ++i) { :(code) bool has_completed_parent(int routine_index) { - for (int j = routine_index; j >= 0; j = Routines.at(j)->parent_index) { + for (int j = routine_index; j >= 0; j = Routines.at(j)->parent_index) { if (Routines.at(j)->state == COMPLETED) return true; } @@ -437,7 +437,7 @@ case ROUTINE_STATE: { case ROUTINE_STATE: { int id = ingredients.at(0).at(0); int result = -1; - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { result = Routines.at(i)->state; break; @@ -469,7 +469,7 @@ case STOP: { :(before "End Primitive Recipe Implementations") case STOP: { int id = ingredients.at(0).at(0); - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { Routines.at(i)->state = COMPLETED; break; @@ -488,7 +488,7 @@ case _DUMP_ROUTINES: { } :(before "End Primitive Recipe Implementations") case _DUMP_ROUTINES: { - for (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; @@ -540,7 +540,7 @@ if (Passed && any_routines_with_error()) { :(code) bool any_routines_with_error() { - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state == DISCONTINUED) return true; } @@ -575,7 +575,7 @@ case LIMIT_TIME: { :(before "End Primitive Recipe Implementations") case LIMIT_TIME: { int id = ingredients.at(0).at(0); - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { Routines.at(i)->limit = ingredients.at(1).at(0); break; @@ -610,7 +610,7 @@ case NUMBER_OF_INSTRUCTIONS: { case NUMBER_OF_INSTRUCTIONS: { int id = ingredients.at(0).at(0); int result = -1; - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { result = Routines.at(i)->instructions_run; break; diff --git a/073wait.cc b/073wait.cc index 4105d506..cf584d69 100644 --- a/073wait.cc +++ b/073wait.cc @@ -49,14 +49,14 @@ if (Passed && any_routines_with_error()) { } :(code) bool any_routines_waiting() { - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state == WAITING) return true; } return false; } void dump_waiting_routines() { - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state == WAITING) cerr << i << ": " << routine_label(Routines.at(i)) << '\n'; } @@ -132,7 +132,7 @@ case RESET: { //: scheduler tweak to get routines out of that state :(before "End Scheduler State Transitions") -for (int i = 0; i < SIZE(Routines); ++i) { +for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state != WAITING) continue; int loc = Routines.at(i)->waiting_on_location; if (loc && get_or_insert(Memory, loc) == 0) { @@ -213,7 +213,7 @@ case GET_LOCATION: { int offset = ingredients.at(1).at(0); if (offset < 0 || offset >= SIZE(get(Type, base_root_type->value).elements)) break; // copied from Check above int result = base_address; - for (int i = 0; i < offset; ++i) + for (int i = 0; i < offset; ++i) result += size_of(element_type(base.type, i)); trace(9998, "run") << "address to copy is " << result << end(); products.resize(1); @@ -353,13 +353,13 @@ case WAIT_FOR_ROUTINE: { // Wake up any routines waiting for other routines to complete. // Important: this must come after the scheduler loop above giving routines // waiting for locations to change a chance to wake up. -for (int i = 0; i < SIZE(Routines); ++i) { +for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state != WAITING) continue; routine* waiter = Routines.at(i); if (!waiter->waiting_on_routine) continue; int id = waiter->waiting_on_routine; assert(id != waiter->id); // routine can't wait on itself - for (int j = 0; j < SIZE(Routines); ++j) { + for (int j = 0; j < SIZE(Routines); ++j) { const routine* waitee = Routines.at(j); if (waitee->id == id && waitee->state != RUNNING && waitee->state != WAITING) { // routine is COMPLETED or DISCONTINUED @@ -513,13 +513,13 @@ case WAIT_FOR_ROUTINE_TO_BLOCK: { :(before "End Scheduler State Transitions") // Wake up any routines waiting for other routines to stop running. -for (int i = 0; i < SIZE(Routines); ++i) { +for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state != WAITING) continue; routine* waiter = Routines.at(i); if (!waiter->waiting_on_routine_to_block) continue; int id = waiter->waiting_on_routine_to_block; assert(id != waiter->id); // routine can't wait on itself - for (int j = 0; j < SIZE(Routines); ++j) { + for (int j = 0; j < SIZE(Routines); ++j) { const routine* waitee = Routines.at(j); if (waitee->id != id) continue; if (waitee->state != RUNNING || waitee->blocked) { @@ -551,7 +551,7 @@ case RESTART: { :(before "End Primitive Recipe Implementations") case RESTART: { int id = ingredients.at(0).at(0); - for (int i = 0; i < SIZE(Routines); ++i) { + for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { if (Routines.at(i)->state == WAITING) Routines.at(i)->state = RUNNING; diff --git a/074deep_copy.cc b/074deep_copy.cc index d0670870..b8767932 100644 --- a/074deep_copy.cc +++ b/074deep_copy.cc @@ -277,9 +277,9 @@ void deep_copy(const reagent& canonized_in, map& addresses_copied, con if (!contains_key(Container_metadata, canonized_in.type)) return; trace(9991, "run") << "deep-copy: scanning for addresses in " << to_string(data) << end(); const container_metadata& metadata = get(Container_metadata, canonized_in.type); - for (map, set >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { + for (map, set >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { if (!all_match(data, p->first)) continue; - for (set::const_iterator info = p->second.begin(); info != p->second.end(); ++info) { + for (set::const_iterator info = p->second.begin(); info != p->second.end(); ++info) { // construct a fake reagent that reads directly from the appropriate // field of the container reagent curr; diff --git a/080display.cc b/080display.cc index 0d2e7db3..52ac4283 100644 --- a/080display.cc +++ b/080display.cc @@ -109,7 +109,7 @@ case CLEAR_LINE_ON_DISPLAY: { case CLEAR_LINE_ON_DISPLAY: { CHECK_SCREEN; int width = tb_width(); - for (int x = Display_column; x < width; ++x) { + 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); @@ -546,8 +546,8 @@ case CLEAR_DISPLAY_FROM: { int left = ingredients.at(2).at(0); int right = ingredients.at(3).at(0); int height=tb_height(); - for (; row < height; ++row, column=left) { // start column from left in every inner loop except first - for (; column <= right; ++column) { + for (/*nada*/; row < height; ++row, column=left) { // start column from left in every inner loop except first + for (/*nada*/; column <= right; ++column) { tb_change_cell(column, row, ' ', TB_WHITE, TB_BLACK); } } diff --git a/082scenario_screen.cc b/082scenario_screen.cc index 56e3ab6b..c6862f9b 100644 --- a/082scenario_screen.cc +++ b/082scenario_screen.cc @@ -262,7 +262,7 @@ void check_screen(const string& expected_contents, const int color) { raw_string_stream cursor(expected_contents); // todo: too-long expected_contents should fail int addr = screen_data_start+/*skip length*/1; - for (int row = 0; row < screen_height; ++row) { + for (int row = 0; row < screen_height; ++row) { cursor.skip_whitespace_and_comments(); if (cursor.at_end()) break; if (cursor.get() != '.') { @@ -401,9 +401,9 @@ void dump_screen() { 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); int curr = screen_data_start+1; // skip length - for (int row = 0; row < screen_height; ++row) { + for (int row = 0; row < screen_height; ++row) { cerr << '.'; - for (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(get_or_insert(Memory, curr))); else diff --git a/085scenario_console.cc b/085scenario_console.cc index dde46134..18ca6607 100644 --- a/085scenario_console.cc +++ b/085scenario_console.cc @@ -63,7 +63,7 @@ case ASSUME_CONSOLE: { // store length put(Memory, event_data_address+/*skip refcount*/1, num_events); int curr_address = event_data_address + /*skip refcount and length*/2; - for (int i = 0; i < SIZE(r.steps); ++i) { + for (int i = 0; i < SIZE(r.steps); ++i) { const instruction& inst = r.steps.at(i); if (inst.name == "left-click") { trace(9999, "mem") << "storing 'left-click' event starting at " << Current_routine->alloc << end(); @@ -100,7 +100,7 @@ case ASSUME_CONSOLE: { const char* raw_contents = contents.c_str(); int num_keyboard_events = unicode_length(contents); int curr = 0; - for (int i = 0; i < num_keyboard_events; ++i) { + for (int i = 0; i < num_keyboard_events; ++i) { trace(9999, "mem") << "storing 'text' tag at " << curr_address << end(); put(Memory, curr_address, /*tag for 'text' variant of 'event' exclusive-container*/0); uint32_t curr_character; @@ -270,10 +270,10 @@ case REPLACE_IN_CONSOLE: { int console_address = get_or_insert(Memory, CONSOLE); int console_data = get_or_insert(Memory, console_address+1); int length = get_or_insert(Memory, console_data); // array length - for (int i = 0, curr = console_data+1; i < length; ++i, curr+=size_of_event()) { + for (int i = 0, curr = console_data+1; i < length; ++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 (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; @@ -282,7 +282,7 @@ case REPLACE_IN_CONSOLE: { :(code) int count_events(const recipe& r) { int result = 0; - for (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 == "type") result += unicode_length(curr.ingredients.at(0).name); diff --git a/089scenario_filesystem.cc b/089scenario_filesystem.cc index f5b7d5db..c761ee93 100644 --- a/089scenario_filesystem.cc +++ b/089scenario_filesystem.cc @@ -170,7 +170,7 @@ string munge_resources_contents(const string& data, const string& filename, cons in.get(); // skip leading '|' string line; getline(in, line); - for (int i = 0; i < SIZE(line); ++i) { + for (int i = 0; i < SIZE(line); ++i) { if (line.at(i) == '|') break; if (line.at(i) == '\\') { ++i; // skip @@ -190,7 +190,7 @@ string munge_resources_contents(const string& data, const string& filename, cons void construct_resources_object(const map& contents) { int resources_data_address = allocate(SIZE(contents)*2 + /*array length*/1); int curr = resources_data_address + /*skip refcount and length*/2; - for (map::const_iterator p = contents.begin(); p != contents.end(); ++p) { + for (map::const_iterator p = contents.begin(); p != contents.end(); ++p) { put(Memory, curr, new_mu_text(p->first)); trace(9999, "mem") << "storing file name " << get(Memory, curr) << " in location " << curr << end(); put(Memory, get(Memory, curr), 1); diff --git a/091socket.cc b/091socket.cc index 54d63ae1..97c90716 100644 --- a/091socket.cc +++ b/091socket.cc @@ -154,7 +154,7 @@ case _READ_FROM_SOCKET: { :(before "End Primitive Recipe Implementations") case _READ_FROM_SOCKET: { long long int x = static_cast(ingredients.at(0).at(0)); - int bytes = static_cast(ingredients.at(1).at(0)); //? Should this be something with more bytes? + int bytes = static_cast(ingredients.at(1).at(0)); socket_t* socket = reinterpret_cast(x); int socket_fd = socket->fd; char contents[bytes]; -- cgit 1.4.1-2-gfad0