From 795f5244abc9b9f26ff621fd1997db427289d2ba Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 6 Nov 2015 11:06:58 -0800 Subject: 2377 - stop using operator[] in map I'm still seeing all sorts of failures in turning on layer 11 of edit/, so I'm backing away and nailing down every culprit I run into. First up: stop accidentally inserting empty objects into maps during lookups. Commands run: $ sed -i 's/\(Recipe_ordinal\|Recipe\|Type_ordinal\|Type\|Memory\)\[\([^]]*\)\] = \(.*\);/put(\1, \2, \3);/' 0[1-9]* $ vi 075scenario_console.cc # manually fix up Memory[Memory[CONSOLE]] $ sed -i 's/\(Memory\)\[\([^]]*\)\]/get_or_insert(\1, \2)/' 0[1-9]* $ sed -i 's/\(Recipe_ordinal\|Type_ordinal\)\[\([^]]*\)\]/get(\1, \2)/' 0[1-9]* $ sed -i 's/\(Recipe\|Type\)\[\([^]]*\)\]/get(\1, \2)/' 0[1-9]* Now mu dies pretty quickly because of all the places I try to lookup a missing value. --- 064random.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to '064random.cc') diff --git a/064random.cc b/064random.cc index 12e1b848..69ed8b2c 100644 --- a/064random.cc +++ b/064random.cc @@ -1,7 +1,7 @@ :(before "End Primitive Recipe Declarations") RANDOM, :(before "End Primitive Recipe Numbers") -Recipe_ordinal["random"] = RANDOM; +put(Recipe_ordinal, "random", RANDOM); :(before "End Primitive Recipe Checks") case RANDOM: { break; @@ -18,7 +18,7 @@ case RANDOM: { :(before "End Primitive Recipe Declarations") MAKE_RANDOM_NONDETERMINISTIC, :(before "End Primitive Recipe Numbers") -Recipe_ordinal["make-random-nondeterministic"] = MAKE_RANDOM_NONDETERMINISTIC; +put(Recipe_ordinal, "make-random-nondeterministic", MAKE_RANDOM_NONDETERMINISTIC); :(before "End Primitive Recipe Checks") case MAKE_RANDOM_NONDETERMINISTIC: { break; @@ -32,15 +32,15 @@ case MAKE_RANDOM_NONDETERMINISTIC: { :(before "End Primitive Recipe Declarations") ROUND, :(before "End Primitive Recipe Numbers") -Recipe_ordinal["round"] = ROUND; +put(Recipe_ordinal, "round", ROUND); :(before "End Primitive Recipe Checks") case ROUND: { if (SIZE(inst.ingredients) != 1) { - raise_error << maybe(Recipe[r].name) << "'round' requires exactly one ingredient, but got " << inst.to_string() << '\n' << end(); + raise_error << maybe(get(Recipe, r).name) << "'round' requires exactly one ingredient, but got " << inst.to_string() << '\n' << end(); break; } if (!is_mu_number(inst.ingredients.at(0))) { - raise_error << maybe(Recipe[r].name) << "first ingredient of 'round' should be a number, but got " << inst.ingredients.at(0).original_string << '\n' << end(); + raise_error << maybe(get(Recipe, r).name) << "first ingredient of 'round' should be a number, but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } break; -- cgit 1.4.1-2-gfad0