From db1f56c8449d2ea3d158753fe37bac5a750a2566 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 29 Nov 2015 14:18:52 -0800 Subject: 2611 --- html/042name.cc.html | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'html/042name.cc.html') diff --git a/html/042name.cc.html b/html/042name.cc.html index da006079..aa0a1fe9 100644 --- a/html/042name.cc.html +++ b/html/042name.cc.html @@ -54,7 +54,7 @@ recipe main [ +error: main: use before set: y # todo: detect conditional defines -:(after "Transform.push_back(check_or_set_invalid_types") // there'll be other transforms relating to types; they all need to happen first +:(before "End Instruction Modifying Transforms") Transform.push_back(transform_names); // idempotent :(before "End Globals") @@ -66,31 +66,32 @@ for (long long int i = 0:(code) void transform_names(const recipe_ordinal r) { - trace(9991, "transform") << "--- transform names for recipe " << get(Recipe, r).name << end(); -//? cerr << "--- transform names for recipe " << get(Recipe, r).name << '\n'; + recipe& caller = get(Recipe, r); + trace(9991, "transform") << "--- transform names for recipe " << caller.name << end(); +//? cerr << "--- transform names for recipe " << caller.name << '\n'; bool names_used = false; bool numeric_locations_used = false; map<string, long long int>& names = Name[r]; // store the indices 'used' so far in the map long long int& curr_idx = names[""]; ++curr_idx; // avoid using index 0, benign skip in some other cases - for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { - instruction& inst = get(Recipe, r).steps.at(i); + for (long long int i = 0; i < SIZE(caller.steps); ++i) { + instruction& inst = caller.steps.at(i); // End transform_names(inst) Special-cases // map names to addresses for (long long int in = 0; in < SIZE(inst.ingredients); ++in) { if (is_numeric_location(inst.ingredients.at(in))) numeric_locations_used = true; if (is_named_location(inst.ingredients.at(in))) names_used = true; - if (disqualified(inst.ingredients.at(in), inst, get(Recipe, r).name)) continue; + if (disqualified(inst.ingredients.at(in), inst, caller.name)) continue; if (!already_transformed(inst.ingredients.at(in), names)) { - raise_error << maybe(get(Recipe, r).name) << "use before set: " << inst.ingredients.at(in).name << '\n' << end(); + raise_error << maybe(caller.name) << "use before set: " << inst.ingredients.at(in).name << '\n' << end(); } inst.ingredients.at(in).set_value(lookup_name(inst.ingredients.at(in), r)); } for (long long int out = 0; out < SIZE(inst.products); ++out) { if (is_numeric_location(inst.products.at(out))) numeric_locations_used = true; if (is_named_location(inst.products.at(out))) names_used = true; - if (disqualified(inst.products.at(out), inst, get(Recipe, r).name)) continue; + if (disqualified(inst.products.at(out), inst, caller.name)) continue; if (names.find(inst.products.at(out).name) == names.end()) { trace(9993, "name") << "assign " << inst.products.at(out).name << " " << curr_idx << end(); names[inst.products.at(out).name] = curr_idx; @@ -100,7 +101,7 @@ void transform_names(const recipe_ordinal r} } if (names_used && numeric_locations_used) - raise_error << maybe(get(Recipe, r).name) << "mixing variable names and numeric addresses\n" << end(); + raise_error << maybe(caller.name) << "mixing variable names and numeric addresses\n" << end(); } bool disqualified(/*mutable*/ reagent& x, const instruction& inst, const string& recipe_name) { @@ -240,8 +241,10 @@ if (inst.name == < if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) { // since first non-address in base type must be a container, we don't have to canonize type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type, get(Recipe, r).name); - inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); - trace(9993, "name") << "element " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end(); + if (contains_key(Type, base_type)) { // otherwise we'll raise an error elsewhere + inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); + trace(9993, "name") << "element " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end(); + } } } @@ -249,8 +252,8 @@ if (inst.name == < :(scenarios transform) :(scenario transform_names_handles_containers) recipe main [ - a:point <- copy 0/raw - b:number <- copy 0/raw + a:point <- copy 0/unsafe + b:number <- copy 0/unsafe ] +name: assign a 1 +name: assign b 3 @@ -279,8 +282,10 @@ if (inst.name == < if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) { // since first non-address in base type must be an exclusive container, we don't have to canonize type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type, get(Recipe, r).name); - inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); - trace(9993, "name") << "variant " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end(); + if (contains_key(Type, base_type)) { // otherwise we'll raise an error elsewhere + inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); + trace(9993, "name") << "variant " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end(); + } } } -- cgit 1.4.1-2-gfad0