From d9e39b3b1cfac9487a9a0aee2525ea86e3e137b1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 7 Feb 2017 00:05:38 -0800 Subject: 3743 One way to ensure we always set old_name is to create a method to initialize names as opposed to just assigning them. Still not ideal because we still assign directly most of the time, so it's easy to forget. --- 010vm.cc | 1 + 043space.cc | 4 ++++ 053recipe_header.cc | 2 +- 060rewrite_literal_string.cc | 2 +- 062convert_ingredients_to_text.cc | 4 ++-- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/010vm.cc b/010vm.cc index fea11a50..80a817f3 100644 --- a/010vm.cc +++ b/010vm.cc @@ -41,6 +41,7 @@ struct instruction { instruction(); void clear(); bool is_empty(); + // End instruction Methods }; :(before "struct instruction") diff --git a/043space.cc b/043space.cc index 33c4bb09..46736615 100644 --- a/043space.cc +++ b/043space.cc @@ -266,6 +266,10 @@ string old_name; old_name.clear(); :(before "End next_instruction(curr)") curr->old_name = curr->name; // before rewrite rules modify it +:(before "End instruction Methods") +void initialize_name(const string& n) { + name = old_name = n; +} :(code) // is this reagent one of the values returned by the current (return) instruction? diff --git a/053recipe_header.cc b/053recipe_header.cc index c8904ba3..7101d7d6 100644 --- a/053recipe_header.cc +++ b/053recipe_header.cc @@ -481,7 +481,7 @@ void fill_in_return_ingredients(const recipe_ordinal r) { const instruction& final_instruction = caller_recipe.steps.at(SIZE(caller_recipe.steps)-1); if (final_instruction.name != "reply" && final_instruction.name != "return") { instruction inst; - inst.name = "return"; + inst.initialize_name("return"); add_header_products(inst, caller_recipe); caller_recipe.steps.push_back(inst); } diff --git a/060rewrite_literal_string.cc b/060rewrite_literal_string.cc index 3310bf9d..1cd27a8b 100644 --- a/060rewrite_literal_string.cc +++ b/060rewrite_literal_string.cc @@ -46,7 +46,7 @@ void rewrite_literal_string_to_text(const recipe_ordinal r) { instruction def; ostringstream ingredient_name; ingredient_name << inst.name << '_' << i << '_' << j << ":text"; - def.name = "new"; + def.initialize_name("new"); def.ingredients.push_back(inst.ingredients.at(j)); def.products.push_back(reagent(ingredient_name.str())); new_instructions.push_back(def); diff --git a/062convert_ingredients_to_text.cc b/062convert_ingredients_to_text.cc index 94ff5df3..fbdcc4ec 100644 --- a/062convert_ingredients_to_text.cc +++ b/062convert_ingredients_to_text.cc @@ -115,13 +115,13 @@ void convert_ingredient_to_text(reagent& r, vector& out, const stri if (is_static_array(r)) return; instruction def; if (is_lookup_of_address_of_array(r)) { - def.name = "array-to-text-line"; + def.initialize_name("array-to-text-line"); reagent/*copy*/ tmp = r; drop_one_lookup(tmp); def.ingredients.push_back(tmp); } else { - def.name = "to-text-line"; + def.initialize_name("to-text-line"); def.ingredients.push_back(r); } def.products.push_back(reagent(tmp_var)); -- cgit 1.4.1-2-gfad0 <vc@akkartik.com> 2015-03-16 20:26:59 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-03-16 20:26:59 -0700 932 - clean up comments in the tangled c++' href='/akkartik/mu/commit/cpp/021call_ingredient?h=hlt&id=3c435756bcd997dac981ca78c49c5100eb2211b7'>3c435756 ^
1
2
3
4
5
6
7
8