From b2566a847948ba808d4ca93d02bcc62ee6487255 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 2 Feb 2016 09:59:40 -0800 Subject: 2625 --- html/043space.cc.html | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'html/043space.cc.html') diff --git a/html/043space.cc.html b/html/043space.cc.html index 7f14f589..36e41bc1 100644 --- a/html/043space.cc.html +++ b/html/043space.cc.html @@ -22,6 +22,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Special { color: #ff6060; } .Identifier { color: #804000; } .Constant { color: #00a0a0; } +.CommentedCode { color: #6c6c6c; } --> @@ -72,7 +73,7 @@ recipe main [ +name: assign x 1 -name: assign default-space 1 -:(before "End Disqualified Reagents") +:(before "End is_disqualified Cases") if (x.name == "default-space") x.initialized = true; :(before "End is_special_name Cases") @@ -201,7 +202,7 @@ recipe main [ # allocate space for x and y, as well as the chaining slot at 0 +mem: array size is 3 -:(before "End Disqualified Reagents") +:(before "End is_disqualified Cases") if (x.name == "number-of-locals") x.initialized = true; :(before "End is_special_name Cases") @@ -278,6 +279,50 @@ void rewrite_default_space_instruction(instructio raise_error << "new-default-space can't take any results\n" << end(); curr.products.push_back(reagent("default-space:address:shared:array:location")); } + +//:: all recipes must set default-space one way or another + +:(before "End Globals") +bool Warn_on_missing_default_space = false; +:(before "End Checks") +Transform.push_back(check_default_space); // idempotent +:(code) +void check_default_space(const recipe_ordinal r) { + if (!Warn_on_missing_default_space) return; // skip previous core tests; this is only for mu code + const recipe& caller = get(Recipe, r); + // skip scenarios (later layer) + // user code should never create recipes with underscores in their names + if (caller.name.find("scenario_") == 0) return; // skip mu scenarios which will use raw memory locations + if (caller.name.find("run_") == 0) return; // skip calls to 'run', which should be in scenarios and will also use raw memory locations + // assume recipes with only numeric addresses know what they're doing (usually tests) + if (!contains_non_special_name(r)) return; + trace(9991, "transform") << "--- check that recipe " << caller.name << " sets default-space" << end(); + if (caller.steps.empty()) return; + if (caller.steps.at(0).products.empty() + || caller.steps.at(0).products.at(0).name != "default-space") { + raise << maybe(caller.name) << " does not seem to start with default-space or local-scope\n" << end(); +//? cerr << maybe(caller.name) << " does not seem to start with default-space or local-scope\n" << '\n'; + } +} +:(after "Load .mu Core") +Warn_on_missing_default_space = true; +:(after "Test Runs") +Warn_on_missing_default_space = false; +:(after "Running Main") +Warn_on_missing_default_space = true; + +:(code) +bool contains_non_special_name(const recipe_ordinal r) { + for (map<string, long long int>::iterator p = Name[r].begin(); p != Name[r].end(); ++p) { + if (p->first.empty()) continue; + if (p->first.find("stash_") == 0) continue; // generated by rewrite_stashes_to_text + if (!is_special_name(p->first)) { +//? cerr << " " << Recipe[r].name << ": " << p->first << '\n'; + return true; + } + } + return false; +} -- cgit 1.4.1-2-gfad0