diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-02-20 21:58:48 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-02-20 21:58:48 -0800 |
commit | f22250a174d5ad5abf8bf99ad140ced52563aee2 (patch) | |
tree | 9c18edbad8b10e7b310032dbd4ad0860f28e6836 | |
parent | 791c5eb1398bff36c74b1f7581ddff70d298cbc5 (diff) | |
download | mu-f22250a174d5ad5abf8bf99ad140ced52563aee2.tar.gz |
2680
Delete all the [] that has crept in since 2377 in November.
-rw-r--r-- | 037new.cc | 12 | ||||
-rw-r--r-- | 041jump_target.cc | 6 | ||||
-rw-r--r-- | 043space.cc | 2 | ||||
-rw-r--r-- | 045closure_name.cc | 10 | ||||
-rw-r--r-- | 047check_type_by_name.cc | 12 | ||||
-rw-r--r-- | 052tangle.cc | 8 | ||||
-rw-r--r-- | 090trace_browser.cc | 14 |
7 files changed, 32 insertions, 32 deletions
diff --git a/037new.cc b/037new.cc index c7453ae5..45d014c2 100644 --- a/037new.cc +++ b/037new.cc @@ -329,7 +329,7 @@ case ABANDON: { abandon(address, size_of(types)+/*refcount*/1); // clear the address trace(9999, "mem") << "resetting location " << address_location << end(); - Memory[address_location] = 0; + put(Memory, address_location, 0); break; } @@ -343,15 +343,15 @@ void abandon(long long int address, long long int size) { for (long long int curr = address; curr < address+size; ++curr) put(Memory, curr, 0); // append existing free list to address - put(Memory, address, Free_list[size]); - Free_list[size] = address; + put(Memory, address, get_or_insert(Free_list, size)); + put(Free_list, size, address); } :(before "ensure_space(size)" following "case ALLOCATE") -if (Free_list[size]) { +if (get_or_insert(Free_list, size)) { trace(9999, "abandon") << "picking up space from free-list of size " << size << end(); - long long int result = Free_list[size]; - Free_list[size] = get_or_insert(Memory, result); + long long int result = get_or_insert(Free_list, size); + put(Free_list, size, get_or_insert(Memory, result)); for (long long int curr = result+1; curr < result+size; ++curr) { if (get_or_insert(Memory, curr) != 0) { raise_error << maybe(current_recipe_name()) << "memory in free list was not zeroed out: " << curr << '/' << result << "; somebody wrote to us after free!!!\n" << end(); diff --git a/041jump_target.cc b/041jump_target.cc index 92a56b8d..243513f7 100644 --- a/041jump_target.cc +++ b/041jump_target.cc @@ -28,12 +28,12 @@ void transform_labels(const recipe_ordinal r) { const instruction& inst = get(Recipe, r).steps.at(i); if (!inst.label.empty() && inst.label.at(0) == '+') { if (!contains_key(offset, inst.label)) { - offset[inst.label] = i; + put(offset, inst.label, i); } else { raise_error << maybe(get(Recipe, r).name) << "duplicate label '" << inst.label << "'" << end(); // have all jumps skip some random but noticeable and deterministic amount of code - offset[inst.label] = 9999; + put(offset, inst.label, 9999); } } } @@ -76,7 +76,7 @@ void replace_offset(reagent& x, /*const*/ map<string, long long int>& offset, co x.set_value(0); // no jump by default return; } - x.set_value(offset[x.name]-current_offset); + x.set_value(get(offset, x.name) - current_offset); } bool is_jump_target(string label) { diff --git a/043space.cc b/043space.cc index 497d87be..fdd987b2 100644 --- a/043space.cc +++ b/043space.cc @@ -281,7 +281,7 @@ bool contains_non_special_name(const recipe_ordinal r) { 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)) { -//? cerr << " " << Recipe[r].name << ": " << p->first << '\n'; +//? cerr << " " << get(Recipe, r).name << ": " << p->first << '\n'; return true; } } diff --git a/045closure_name.cc b/045closure_name.cc index 52e415fc..cb258583 100644 --- a/045closure_name.cc +++ b/045closure_name.cc @@ -73,8 +73,8 @@ void collect_surrounding_spaces(const recipe_ordinal r) { continue; } if (contains_key(Surrounding_space, r) - && Surrounding_space[r] != get(Recipe_ordinal, surrounding_recipe_name)) { - raise_error << "recipe " << get(Recipe, r).name << " can have only one 'surrounding' recipe but has " << get(Recipe, Surrounding_space[r]).name << " and " << surrounding_recipe_name << '\n' << end(); + && get(Surrounding_space, r) != get(Recipe_ordinal, surrounding_recipe_name)) { + raise_error << "recipe " << get(Recipe, r).name << " can have only one 'surrounding' recipe but has " << get(Recipe, get(Surrounding_space, r)).name << " and " << surrounding_recipe_name << '\n' << end(); continue; } trace(9993, "name") << "lexically surrounding space for recipe " << get(Recipe, r).name << " comes from " << surrounding_recipe_name << end(); @@ -83,7 +83,7 @@ void collect_surrounding_spaces(const recipe_ordinal r) { raise << "can't find recipe providing surrounding space for " << get(Recipe, r).name << ": " << surrounding_recipe_name << '\n' << end(); continue; } - Surrounding_space[r] = get(Recipe_ordinal, surrounding_recipe_name); + put(Surrounding_space, r, get(Recipe_ordinal, surrounding_recipe_name)); } } } @@ -132,8 +132,8 @@ recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, long long int n raise_error << "don't know surrounding recipe of " << get(Recipe, r).name << '\n' << end(); return 0; } - assert(Surrounding_space[r]); - return lookup_surrounding_recipe(Surrounding_space[r], n-1); + assert(contains_key(Surrounding_space, r)); + return lookup_surrounding_recipe(get(Surrounding_space, r), n-1); } //: weaken use-before-set detection just a tad diff --git a/047check_type_by_name.cc b/047check_type_by_name.cc index 9889674b..bd74e99d 100644 --- a/047check_type_by_name.cc +++ b/047check_type_by_name.cc @@ -39,10 +39,10 @@ void check_or_set_types_by_name(const recipe_ordinal r) { void deduce_missing_type(map<string, type_tree*>& type, map<string, string_tree*>& type_name, reagent& x) { if (x.type) return; if (!contains_key(type, x.name)) return; - x.type = new type_tree(*type[x.name]); + x.type = new type_tree(*get(type, x.name)); trace(9992, "transform") << x.name << " <= " << to_string(x.type) << end(); assert(!x.properties.at(0).second); - x.properties.at(0).second = new string_tree(*type_name[x.name]); + x.properties.at(0).second = new string_tree(*get(type_name, x.name)); } void check_type(map<string, type_tree*>& type, map<string, string_tree*>& type_name, const reagent& x, const recipe_ordinal r) { @@ -55,16 +55,16 @@ void check_type(map<string, type_tree*>& type, map<string, string_tree*>& type_n } if (!contains_key(type_name, x.name)) put(type_name, x.name, x.properties.at(0).second); - if (!types_strictly_match(type[x.name], x.type)) { + if (!types_strictly_match(get(type, x.name), x.type)) { raise_error << maybe(get(Recipe, r).name) << x.name << " used with multiple types\n" << end(); return; } - if (type_name[x.name]->value == "array") { - if (!type_name[x.name]->right) { + if (get(type_name, x.name)->value == "array") { + if (!get(type_name, x.name)->right) { raise_error << maybe(get(Recipe, r).name) << x.name << " can't be just an array. What is it an array of?\n" << end(); return; } - if (!type_name[x.name]->right->right) { + if (!get(type_name, x.name)->right->right) { raise_error << get(Recipe, r).name << " can't determine the size of array variable " << x.name << ". Either allocate it separately and make the type of " << x.name << " address:shared:..., or specify the length of the array in the type of " << x.name << ".\n" << end(); return; } diff --git a/052tangle.cc b/052tangle.cc index 94a0bd35..5e38e129 100644 --- a/052tangle.cc +++ b/052tangle.cc @@ -84,13 +84,13 @@ void insert_fragments(const recipe_ordinal r) { Fragments_used.insert(inst.label); ostringstream prefix; prefix << '+' << get(Recipe, r).name << '_' << pass << '_' << i; - if (contains_key(Before_fragments, inst.label)) { + // ok to use contains_key even though Before_fragments uses [], + // because appending an empty recipe is a noop + if (contains_key(Before_fragments, inst.label)) append_fragment(result, Before_fragments[inst.label].steps, prefix.str()); - } result.push_back(inst); - if (contains_key(After_fragments, inst.label)) { + if (contains_key(After_fragments, inst.label)) append_fragment(result, After_fragments[inst.label].steps, prefix.str()); - } } get(Recipe, r).steps.swap(result); ++pass; diff --git a/090trace_browser.cc b/090trace_browser.cc index d98b7fab..8c2610a4 100644 --- a/090trace_browser.cc +++ b/090trace_browser.cc @@ -79,7 +79,7 @@ void start_trace_browser() { if (key == 'J' || key == TB_KEY_PGDN) { // page-down if (Trace_index.find(tb_height()-1) != Trace_index.end()) { - Top_of_screen = Trace_index[tb_height()-1]+1; + Top_of_screen = get(Trace_index, tb_height()-1) + 1; refresh_screen_rows(); } } @@ -111,7 +111,7 @@ void start_trace_browser() { if (key == TB_KEY_CARRIAGE_RETURN) { // expand lines under current by one level assert(contains_key(Trace_index, Display_row)); - long long int start_index = Trace_index[Display_row]; + long long int start_index = get(Trace_index, Display_row); long long int index = 0; // simultaneously compute end_index and min_depth int min_depth = 9999; @@ -134,7 +134,7 @@ void start_trace_browser() { if (key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2) { // collapse all lines under current assert(contains_key(Trace_index, Display_row)); - long long int start_index = Trace_index[Display_row]; + long long int start_index = get(Trace_index, Display_row); long long int index = 0; // end_index is the next line at a depth same as or lower than start_index int initial_depth = Trace_stream->past_lines.at(start_index).depth; @@ -165,7 +165,7 @@ void refresh_screen_rows() { if (index >= SIZE(Trace_stream->past_lines)) goto done; } assert(index < SIZE(Trace_stream->past_lines)); - Trace_index[screen_row] = index; + put(Trace_index, screen_row, index); } done:; } @@ -174,7 +174,7 @@ void render() { long long int screen_row = 0; for (screen_row = 0; screen_row < tb_height(); ++screen_row) { if (!contains_key(Trace_index, screen_row)) break; - trace_line& curr_line = Trace_stream->past_lines.at(Trace_index[screen_row]); + trace_line& curr_line = Trace_stream->past_lines.at(get(Trace_index, screen_row)); ostringstream out; out << std::setw(4) << curr_line.depth << ' ' << curr_line.label << ": " << curr_line.contents; if (screen_row < tb_height()-1) { @@ -199,9 +199,9 @@ void render() { long long int lines_hidden(long long int screen_row) { assert(contains_key(Trace_index, screen_row)); if (!contains_key(Trace_index, screen_row+1)) - return SIZE(Trace_stream->past_lines)-Trace_index[screen_row]; + return SIZE(Trace_stream->past_lines) - get(Trace_index, screen_row); else - return Trace_index[screen_row+1] - Trace_index[screen_row]; + return get(Trace_index, screen_row+1) - get(Trace_index, screen_row); } void render_line(int screen_row, const string& s) { |