diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-02-14 23:15:03 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-02-14 23:15:03 -0800 |
commit | 3965ca030f1d68298ed652328a2f712fff7cc14e (patch) | |
tree | 7d9b7e0b0a8fd4d1f07e4cc6340f8f18546a0bd8 | |
parent | b86707a91d3ccd80b48f354f74f9cd1607bc78e9 (diff) | |
download | mu-3965ca030f1d68298ed652328a2f712fff7cc14e.tar.gz |
2655 - support shape-shifting exclusive containers
-rw-r--r-- | 033exclusive_container.cc | 5 | ||||
-rw-r--r-- | 058shape_shifting_container.cc | 29 |
2 files changed, 32 insertions, 2 deletions
diff --git a/033exclusive_container.cc b/033exclusive_container.cc index ea2d8e3a..46dd2e64 100644 --- a/033exclusive_container.cc +++ b/033exclusive_container.cc @@ -40,8 +40,9 @@ if (t.kind == EXCLUSIVE_CONTAINER) { // (So like containers, it can't contain arrays.) long long int result = 0; for (long long int i = 0; i < t.size; ++i) { - long long int tmp = size_of(t.elements.at(i)); - if (tmp > result) result = tmp; + // End size_of(type) Exclusive Container Cases + long long int size = size_of(t.elements.at(i)); + if (size > result) result = size; } // ...+1 for its tag. return result+1; diff --git a/058shape_shifting_container.cc b/058shape_shifting_container.cc index acdd4081..2fa8f497 100644 --- a/058shape_shifting_container.cc +++ b/058shape_shifting_container.cc @@ -80,6 +80,35 @@ if (t.elements.at(i)->value >= START_TYPE_INGREDIENTS) { continue; } +:(scenario size_of_shape_shifting_exclusive_container) +exclusive-container foo:_t [ + x:_t + y:number +] +recipe main [ + 1:foo:number <- merge 0/x, 34 + 3:foo:point <- merge 0/x, 15, 16 + 6:foo:point <- merge 1/y, 23 +] ++mem: storing 0 in location 1 ++mem: storing 34 in location 2 ++mem: storing 0 in location 3 ++mem: storing 15 in location 4 ++mem: storing 16 in location 5 ++mem: storing 1 in location 6 ++mem: storing 23 in location 7 +$mem: 7 + +:(before "End size_of(type) Exclusive Container Cases") +if (t.elements.at(i)->value >= START_TYPE_INGREDIENTS) { + trace(9999, "type") << "checking size of type ingredient\n" << end(); + long long int size = size_of_type_ingredient(t.elements.at(i), type->right); + if (!size) + raise_error << "illegal type '" << debug_string(type) << "' seems to be missing a type ingredient or three\n" << end(); + if (size > result) result = size; + continue; +} + :(code) // shape-shifting version of size_of long long int size_of_type_ingredient(const type_tree* element_template, const type_tree* rest_of_use) { |