diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-04-28 17:23:50 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-04-28 17:36:30 -0700 |
commit | 7858a06a5444328594bac9a9213bcbdda20580d6 (patch) | |
tree | 7a3612d8d2388a966dc1e5162404922a227a8451 /012transform.cc | |
parent | 4f5bb5b6b199b9ccf1bf12082436d9f841559b2c (diff) | |
download | mu-7858a06a5444328594bac9a9213bcbdda20580d6.tar.gz |
2882 - warn if programmer overuses transform_all()
This continues a line of thought sparked in commit 2831. I spent a while trying to avoid calling size_of() at transform-time, but there's no getting around the fact that translating names to addresses requires knowing how much space they need. This raised the question of what happens if the size of a container changes after a recipe using it is already transformed. I could go down the road of trying to detect such situations and redoing work, but that massively goes against the grain of my original design, which assumed that recipes don't get repeatedly transformed. Even though we call transform_all() in every test, in a non-testing run we should be loading all code and calling transform_all() just once to 'freeze-dry' everything. But even if we don't want to support multiple transforms it's worth checking that they don't occur. This commit does so in just one situation. There are likely others.
Diffstat (limited to '012transform.cc')
-rw-r--r-- | 012transform.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/012transform.cc b/012transform.cc index d3b4384e..b5b6e4fe 100644 --- a/012transform.cc +++ b/012transform.cc @@ -56,6 +56,18 @@ void transform_all() { // End transform_all } +//: Even though a run will involve many calls to transform_all() for tests, +//: our logical model is to load all code, then transform all code, then run. +//: If you load new code that should cause already-transformed recipes to +//: change, that's not supported. To help detect such situations and raise +//: helpful errors we track a count of the number of calls made to +//: transform_all(). +:(before "End Globals") +int Num_calls_to_transform_all = 0; +:(after "void transform_all()") + ++Num_calls_to_transform_all; + +:(code) 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) { |