diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-19 23:44:11 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-19 23:47:15 -0800 |
commit | 9aacd50defdb4c6eb5d860a905af4d572cf7598a (patch) | |
tree | da5bbbfeab5aeb91e2d2e9f8a565279f6dfe3eb4 | |
parent | 8a0f55cdffc03ee10b0d7b6740db89e622b4c1c1 (diff) | |
download | mu-9aacd50defdb4c6eb5d860a905af4d572cf7598a.tar.gz |
2464: edit/: update errors in shape-shifting recipes
Requires carefully deleting specializations so that they can be reintroduced each time.
-rw-r--r-- | 059shape_shifting_recipe.cc | 17 | ||||
-rw-r--r-- | 091run_interactive.cc | 17 | ||||
-rw-r--r-- | edit/010-warnings.mu | 49 |
3 files changed, 81 insertions, 2 deletions
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index b3fec956..c34466fe 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -41,11 +41,23 @@ if (Current_routine->calls.front().running_step_index == 0 if (contains_type_ingredient_name(lhs)) return false; //: We'll be creating recipes without loading them from anywhere by -//: *specializing* existing recipes, so make sure we don't clear any of those -//: when we start running tests. +//: *specializing* existing recipes. +//: +//: Keep track of these new recipes in a separate variable in addition to +//: recently_added_recipes, so that edit/ can clear them before reloading to +//: regenerate errors. +:(before "End Globals") +vector<recipe_ordinal> recently_added_shape_shifting_recipes; +:(before "End Setup") +//? cerr << "setup: clearing recently-added shape-shifting recipes\n"; +recently_added_shape_shifting_recipes.clear(); + +//: make sure we don't clear any of these recipes when we start running tests :(before "End Loading .mu Files") recently_added_recipes.clear(); recently_added_types.clear(); +//? cerr << "clearing recently-added shape-shifting recipes\n"; +recently_added_shape_shifting_recipes.clear(); :(before "End Instruction Dispatch(inst, best_score)") if (best_score == -1) { @@ -180,6 +192,7 @@ recipe_ordinal new_variant(recipe_ordinal exemplar, const instruction& inst, con assert(contains_key(Recipe, exemplar)); assert(!contains_key(Recipe, new_recipe_ordinal)); recently_added_recipes.push_back(new_recipe_ordinal); + recently_added_shape_shifting_recipes.push_back(new_recipe_ordinal); put(Recipe, new_recipe_ordinal, get(Recipe, exemplar)); recipe& new_recipe = get(Recipe, new_recipe_ordinal); // Since the exemplar never ran any transforms, we have to redo some of the diff --git a/091run_interactive.cc b/091run_interactive.cc index a883a5ae..44fe5736 100644 --- a/091run_interactive.cc +++ b/091run_interactive.cc @@ -426,6 +426,23 @@ case RELOAD: { Type_ordinal.erase(get(Type, recently_added_types.at(i)).name); Type.erase(recently_added_types.at(i)); } + for (map<string, vector<recipe_ordinal> >::iterator p = Recipe_variants.begin(); p != Recipe_variants.end(); ++p) { +//? cerr << p->first << ":\n"; + vector<recipe_ordinal>& variants = p->second; + for (long long int i = 0; i < SIZE(p->second); ++i) { + if (variants.at(i) == -1) continue; + if (find(recently_added_shape_shifting_recipes.begin(), recently_added_shape_shifting_recipes.end(), variants.at(i)) != recently_added_shape_shifting_recipes.end()) { +//? cerr << " " << variants.at(i) << ' ' << get(Recipe, variants.at(i)).name << '\n'; + variants.at(i) = -1; // ghost + } + } + } + for (long long int i = 0; i < SIZE(recently_added_shape_shifting_recipes); ++i) { +//? cerr << "erasing " << get(Recipe, recently_added_shape_shifting_recipes.at(i)).name << '\n'; + Recipe_ordinal.erase(get(Recipe, recently_added_shape_shifting_recipes.at(i)).name); + Recipe.erase(recently_added_shape_shifting_recipes.at(i)); + } + recently_added_shape_shifting_recipes.clear(); string code = read_mu_string(ingredients.at(0).at(0)); run_code_begin(); routine* save_current_routine = Current_routine; diff --git a/edit/010-warnings.mu b/edit/010-warnings.mu index b2d927c2..b84a512c 100644 --- a/edit/010-warnings.mu +++ b/edit/010-warnings.mu @@ -150,6 +150,55 @@ scenario run-hides-warnings-from-past-sandboxes [ ] ] +scenario run-updates-warnings-for-shape-shifting-recipes [ + trace-until 100/app # trace too long + assume-screen 100/width, 15/height + # define a shape-shifting recipe with an error + 1:address:array:character <- new [recipe foo x:_elem -> z:_elem [ +local-scope +load-ingredients +z <- add x, [a] +]] + 2:address:array:character <- new [foo 2] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + assume-console [ + press F4 + ] + run [ + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + ] + screen-should-contain [ + . run (F4) . + .recipe foo x:_elem -> z:_elem [ ┊ . + .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .load-ingredients ┊ x. + .z <- add x, [a] ┊foo 2 . + .] ┊foo_3: 'add' requires number ingredients, but go↩. + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊t [a] . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + ] + # now rerun everything + assume-console [ + press F4 + ] + run [ + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + ] + # error should remain unchanged + screen-should-contain [ + . run (F4) . + .recipe foo x:_elem -> z:_elem [ ┊ . + .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .load-ingredients ┊ x. + .z <- add x, [a] ┊foo 2 . + .] ┊foo_3: 'add' requires number ingredients, but go↩. + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊t [a] . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + ] +] + scenario run-shows-missing-type-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height |