# Mu - 013update_operation.cc

     1 //: Once all code is loaded, save operation ids of instructions and check that
     2 //: nothing's undefined.
     3
     4 :(before "End Instruction Modifying Transforms")
     5 Transform.push_back(update_instruction_operations);  // idempotent
     6
     7 :(code)
     8 void update_instruction_operations(const recipe_ordinal r) {
     9   trace(9991, "transform") << "--- compute instruction operations for recipe " << get(Recipe, r).name << end();
    10   recipe& caller = get(Recipe, r);
    11 //?   cerr << "--- compute instruction operations for recipe " << caller.name << '\n';
    12   for (int index = 0;  index < SIZE(caller.steps);  ++index) {
    13     instruction& inst = caller.steps.at(index);
    14     if (inst.is_label) continue;
    15     if (!contains_key(Recipe_ordinal, inst.name)) {
    16       raise << maybe(caller.name) << "instruction '" << inst.name << "' has no recipe in '" << to_original_string(inst) << "'\n" << end();
    17       continue;
    18     }
    19     inst.operation = get(Recipe_ordinal, inst.name);
    20     // End Instruction Operation Checks
    21   }
    22 }
    23
    24 // hook to suppress inserting recipe name into errors
    25 string maybe(string recipe_name) {
    26   // End maybe(recipe_name) Special-cases
    27   return recipe_name + ": ";
    28 }
    29
    30 :(scenarios transform)
    31 :(scenario missing_arrow)
    32 % Hide_errors = true;
    33 def main [
    34   1:number , copy 0  # typo: ',' instead of '<-'
    35 ]
    36 +error: main: instruction '1:number' has no recipe in '1:number copy, 0'