diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-03-19 11:57:47 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-03-19 11:57:47 -0700 |
commit | 1f69d061c17d83b0a665c4fee2407fac1b714b68 (patch) | |
tree | 940e2c878a902fa1b1b49e6f799d3c638d5cc869 | |
parent | d97bafd318567c0f4ae7c80234ecde6cf7658b1c (diff) | |
download | mu-1f69d061c17d83b0a665c4fee2407fac1b714b68.tar.gz |
2797 - bugfix: transform can create recipes
When I started to make channels generic in 2784, I introduced an infinite loop when running until just layer 72. This happens because transform_all() can create new recipes while specializing, and these were getting added to Recently_added_recipes and then deleted. I didn't notice until now because layer 91 was clearing Recently_added_recipes soon after. Solution: make calls to transform_all after calls to load_permanently also clear Recently_added_recipes like load_permanently does. No transforms yet create new types. If they do we'll need to start handling the other Recently_added_* variables as well. I should rethink this whole approach of tracking changes to global state while running tests, and undoing such changes. Ideally I wouldn't need to manually track changes for each global. I should just encapsulate all global state in an object, copy it for each test and delete the copy when I'm done.
-rw-r--r-- | 012transform.cc | 7 | ||||
-rw-r--r-- | 020run.cc | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/012transform.cc b/012transform.cc index a416c20a..0130cd16 100644 --- a/012transform.cc +++ b/012transform.cc @@ -56,6 +56,13 @@ void transform_all() { // End Transform All } +// Later we'll have transforms create recipes out of other recipes. This +// helper will help ensure we don't lose the new recipes. +void transform_permanently() { + transform_all(); + Recently_added_recipes.clear(); +} + void parse_int_reagents() { trace(9991, "transform") << "--- parsing any uninitialized reagents as integers" << end(); for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { diff --git a/020run.cc b/020run.cc index b4810909..41154f06 100644 --- a/020run.cc +++ b/020run.cc @@ -137,7 +137,7 @@ inline const vector<instruction>& routine::steps() const { //? Trace_file = "interactive"; //? START_TRACING_UNTIL_END_OF_SCOPE; load_permanently("core.mu"); -transform_all(); +transform_permanently(); //? DUMP(""); //? exit(0); @@ -156,7 +156,7 @@ if (argc > 1) { argv++; argc--; } - transform_all(); + transform_permanently(); if (Run_tests) Recipe.erase(get(Recipe_ordinal, "main")); // End Loading .mu Files } |