diff options
-rw-r--r-- | 010vm.cc | 1 | ||||
-rw-r--r-- | 032array.cc | 9 | ||||
-rw-r--r-- | 034address.cc | 3 | ||||
-rw-r--r-- | 040brace.cc | 3 | ||||
-rw-r--r-- | 072recipe.cc | 5 |
5 files changed, 7 insertions, 14 deletions
diff --git a/010vm.cc b/010vm.cc index f5138329..f860a953 100644 --- a/010vm.cc +++ b/010vm.cc @@ -58,6 +58,7 @@ struct reagent { // End reagent Fields reagent(const string& s); reagent() :type(NULL), value(0), initialized(false) {} + reagent(type_tree* t) :type(t), value(0), initialized(false) {} ~reagent(); void clear(); reagent(const reagent& original); diff --git a/032array.cc b/032array.cc index bc933aad..e2599df1 100644 --- a/032array.cc +++ b/032array.cc @@ -338,8 +338,7 @@ case INDEX: { if (inst.products.empty()) break; reagent/*copy*/ product = inst.products.at(0); // Update INDEX product in Check - reagent/*local*/ element; - element.type = copy_array_element(base.type); + reagent/*local*/ element(copy_array_element(base.type)); if (!types_coercible(product, element)) { raise << maybe(get(Recipe, r).name) << "'index' on '" << base.original_string << "' can't be saved in '" << product.original_string << "'; type should be '" << names_to_string_without_quotes(element.type) << "'\n" << end(); break; @@ -363,8 +362,7 @@ case INDEX: { raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); break; } - reagent/*local*/ element; - element.type = copy_array_element(base.type); + reagent/*local*/ element(copy_array_element(base.type)); element.set_value(base_address + /*skip length*/1 + index_val.at(0)*size_of(element.type)); trace(9998, "run") << "address to copy is " << element.value << end(); trace(9998, "run") << "its type is " << to_string(element.type) << end(); @@ -523,8 +521,7 @@ case PUT_INDEX: { } reagent/*copy*/ value = inst.ingredients.at(2); // Update PUT_INDEX value in Check - reagent/*local*/ element; - element.type = copy_array_element(base.type); + reagent/*local*/ element(copy_array_element(base.type)); if (!types_coercible(element, value)) { raise << maybe(get(Recipe, r).name) << "'put-index " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should store " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); break; diff --git a/034address.cc b/034address.cc index 0b2b9797..9b74afdf 100644 --- a/034address.cc +++ b/034address.cc @@ -101,8 +101,7 @@ bool product_of_new_is_valid(const instruction& inst) { return false; drop_from_type(product, "array"); } - reagent/*local*/ expected_product; - expected_product.type = new_type_tree(inst.ingredients.at(0).name); + reagent/*local*/ expected_product(new_type_tree(inst.ingredients.at(0).name)); return types_strictly_match(product, expected_product); } diff --git a/040brace.cc b/040brace.cc index c69c4ef1..2501bc1b 100644 --- a/040brace.cc +++ b/040brace.cc @@ -113,8 +113,7 @@ void transform_braces(const recipe_ordinal r) { } } // if implicit, compute target - reagent target; - target.type = new type_tree("offset"); + reagent target(new type_tree("offset")); target.set_value(0); if (open_braces.empty()) raise << maybe(get(Recipe, r).name) << "'" << old_name << "' needs a '{' before\n" << end(); diff --git a/072recipe.cc b/072recipe.cc index 99411e31..62e4638b 100644 --- a/072recipe.cc +++ b/072recipe.cc @@ -331,10 +331,7 @@ void test_from_reagent_reads_sole_ingredient_at_end() { :(code) reagent next_recipe_reagent(const type_tree* curr) { if (!curr->left) return reagent("recipe:"+curr->name); - reagent result; - result.name = "recipe"; - result.type = new type_tree(*curr); - return result; + return reagent(new type_tree(*curr)); } bool is_mu_recipe(const reagent& r) { |