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. --- 047global.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '047global.cc') diff --git a/047global.cc b/047global.cc index b080b90d..c0e09ce4 100644 --- a/047global.cc +++ b/047global.cc @@ -33,11 +33,11 @@ global_space = 0; if (x.name == "global-space") { if (!scalar(data) || !x.type - || x.type->value != Type_ordinal["address"] + || x.type->value != get(Type_ordinal, "address") || !x.type->right - || x.type->right->value != Type_ordinal["array"] + || x.type->right->value != get(Type_ordinal, "array") || !x.type->right->right - || x.type->right->right->value != Type_ordinal["location"] + || x.type->right->right->value != get(Type_ordinal, "location") || x.type->right->right->right) { raise_error << maybe(current_recipe_name()) << "'global-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end(); } -- cgit 1.4.1-2-gfad0