2015-10-30 00:15:09 +00:00
|
|
|
//: Once all code is loaded, save operation ids of instructions and check that
|
|
|
|
//: nothing's undefined.
|
|
|
|
|
2015-11-29 06:17:47 +00:00
|
|
|
:(before "End Instruction Modifying Transforms")
|
2015-11-07 01:29:52 +00:00
|
|
|
Transform.push_back(update_instruction_operations); // idempotent
|
2015-10-30 00:15:09 +00:00
|
|
|
|
|
|
|
:(code)
|
2016-10-22 23:10:23 +00:00
|
|
|
void update_instruction_operations(const recipe_ordinal r) {
|
2015-11-06 19:06:58 +00:00
|
|
|
trace(9991, "transform") << "--- compute instruction operations for recipe " << get(Recipe, r).name << end();
|
2015-11-19 07:55:54 +00:00
|
|
|
recipe& caller = get(Recipe, r);
|
|
|
|
//? cerr << "--- compute instruction operations for recipe " << caller.name << '\n';
|
2016-10-20 05:10:35 +00:00
|
|
|
for (int index = 0; index < SIZE(caller.steps); ++index) {
|
2015-11-19 07:55:54 +00:00
|
|
|
instruction& inst = caller.steps.at(index);
|
2015-10-30 00:15:09 +00:00
|
|
|
if (inst.is_label) continue;
|
2015-11-06 21:22:16 +00:00
|
|
|
if (!contains_key(Recipe_ordinal, inst.name)) {
|
2017-05-26 23:43:18 +00:00
|
|
|
raise << maybe(caller.name) << "instruction '" << inst.name << "' has no recipe in '" << to_original_string(inst) << "'\n" << end();
|
2016-02-23 23:53:47 +00:00
|
|
|
continue;
|
2015-10-30 00:15:09 +00:00
|
|
|
}
|
2015-11-06 19:06:58 +00:00
|
|
|
inst.operation = get(Recipe_ordinal, inst.name);
|
2015-11-19 07:55:54 +00:00
|
|
|
// End Instruction Operation Checks
|
2015-10-30 00:15:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-12 18:01:12 +00:00
|
|
|
// hook to suppress inserting recipe name into errors
|
2017-06-15 17:45:03 +00:00
|
|
|
string maybe(string recipe_name) {
|
|
|
|
// End maybe(recipe_name) Special-cases
|
|
|
|
return recipe_name + ": ";
|
2015-10-30 00:15:09 +00:00
|
|
|
}
|
2016-10-31 16:16:26 +00:00
|
|
|
|
2016-11-01 00:53:11 +00:00
|
|
|
:(scenarios transform)
|
2016-10-31 16:16:26 +00:00
|
|
|
:(scenario missing_arrow)
|
|
|
|
% Hide_errors = true;
|
|
|
|
def main [
|
|
|
|
1:number , copy 0 # typo: ',' instead of '<-'
|
|
|
|
]
|
2017-03-19 03:44:48 +00:00
|
|
|
+error: main: instruction '1:number' has no recipe in '1:number copy, 0'
|