diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-05-02 23:11:33 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-05-02 23:11:33 -0700 |
commit | 3377364a849d938a9999357caf26853a844b238c (patch) | |
tree | d062357677f378df7104043d498d05bee53dbeca /057shape_shifting_container.cc | |
parent | 481fce0e5df70332ccb3a825efcf1e5db1f3e48b (diff) | |
download | mu-3377364a849d938a9999357caf26853a844b238c.tar.gz |
2891 - precompute container sizes and offsets
It's a bit of a trade-off because we need to store copies of container metadata in each reagent (to support shape-shifting containers), and metadata is not lightweight and will get heavier. But it'll become more unambiguously useful when we switch to a compiler.
Diffstat (limited to '057shape_shifting_container.cc')
-rw-r--r-- | 057shape_shifting_container.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/057shape_shifting_container.cc b/057shape_shifting_container.cc index fa587595..92c2475a 100644 --- a/057shape_shifting_container.cc +++ b/057shape_shifting_container.cc @@ -246,12 +246,23 @@ def main [ +mem: storing 1 in location 4 :(before "End element_type Special-cases") -if (contains_type_ingredient(element)) { - if (!type->right) - raise << "illegal type " << names_to_string(type) << " seems to be missing a type ingredient or three\n" << end(); - replace_type_ingredients(element.type, type->right, info); +replace_type_ingredients(element, type, info); +:(before "Compute Container Metadata(element)") +replace_type_ingredients(element, type, info); +:(before "Compute Exclusive Container Metadata(element)") +replace_type_ingredients(element, type, info); +:(code) +void replace_type_ingredients(reagent& element, const type_tree* caller_type, const type_info& info) { + if (contains_type_ingredient(element)) { + if (!caller_type->right) + raise << "illegal type " << names_to_string(caller_type) << " seems to be missing a type ingredient or three\n" << end(); + replace_type_ingredients(element.type, caller_type->right, info); + } } +:(after "Compute size_of Container") +assert(!contains_type_ingredient(type)); + :(code) bool contains_type_ingredient(const reagent& x) { return contains_type_ingredient(x.type); |