From 9f73b16511406dd8281b615b138d8648e854ca52 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 28 Mar 2016 00:00:44 -0700 Subject: 2817 --- 030container.cc | 8 ++------ 057shape_shifting_container.cc | 46 ------------------------------------------ 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/030container.cc b/030container.cc index ecb1f900..b4627355 100644 --- a/030container.cc +++ b/030container.cc @@ -180,10 +180,8 @@ case GET: { int offset = ingredients.at(1).at(0); if (offset < 0 || offset >= SIZE(get(Type, base_type).elements)) break; // copied from Check above int src = base_address; - for (int i = 0; i < offset; ++i) { - // End GET field Cases + for (int i = 0; i < offset; ++i) src += size_of(element_type(base, i)); - } trace(9998, "run") << "address to copy is " << src << end(); reagent tmp = element_type(base, offset); tmp.set_value(src); @@ -321,10 +319,8 @@ case GET_ADDRESS: { int offset = ingredients.at(1).at(0); if (offset < 0 || offset >= SIZE(get(Type, base_type).elements)) break; // copied from Check above int result = base_address; - for (int i = 0; i < offset; ++i) { - // End GET_ADDRESS field Cases + for (int i = 0; i < offset; ++i) result += size_of(element_type(base, i)); - } trace(9998, "run") << "address to copy is " << result << end(); products.resize(1); products.at(0).push_back(result); diff --git a/057shape_shifting_container.cc b/057shape_shifting_container.cc index 613aaaa7..80cd43b7 100644 --- a/057shape_shifting_container.cc +++ b/057shape_shifting_container.cc @@ -126,32 +126,6 @@ def main [ +mem: storing 23 in location 7 $mem: 7 -:(code) -// shape-shifting version of size_of -int size_of_type_ingredient(const type_tree* element_template, const type_tree* rest_of_use) { - type_tree* element_type = type_ingredient(element_template, rest_of_use); - if (!element_type) return 0; - int result = size_of(element_type); - delete element_type; - return result; -} - -type_tree* type_ingredient(const type_tree* element_template, const type_tree* rest_of_use) { - int type_ingredient_index = element_template->value - START_TYPE_INGREDIENTS; - const type_tree* curr = rest_of_use; - if (!curr) return NULL; - while (type_ingredient_index > 0) { - --type_ingredient_index; - curr = curr->right; - if (!curr) return NULL; - } - assert(curr); - if (curr->left) curr = curr->left; - assert(curr->value > 0); - trace(9999, "type") << "type deduced to be " << get(Type, curr->value).name << "$" << end(); - return new type_tree(*curr); -} - :(scenario get_on_shape_shifting_container) container foo:_t [ x:_t @@ -163,16 +137,6 @@ def main [ ] +mem: storing 16 in location 2 -:(before "End GET field Cases") -const type_tree* type = get(Type, base_type).elements.at(i).type; -if (type->value >= START_TYPE_INGREDIENTS) { - int size = size_of_type_ingredient(type, base.type->right); - if (!size) - raise << "illegal field type '" << to_string(type) << "' seems to be missing a type ingredient or three\n" << end(); - src += size; - continue; -} - :(scenario get_on_shape_shifting_container_2) container foo:_t [ x:_t @@ -508,16 +472,6 @@ def main [ ] +mem: storing 12 in location 1 -:(before "End GET_ADDRESS field Cases") -const type_tree* type = get(Type, base_type).elements.at(i).type; -if (type->value >= START_TYPE_INGREDIENTS) { - int size = size_of_type_ingredient(type, base.type->right); - if (!size) - raise << "illegal type '" << to_string(type) << "' seems to be missing a type ingredient or three\n" << end(); - result += size; - continue; -} - //: 'merge' on shape-shifting containers :(scenario merge_check_shape_shifting_container_containing_exclusive_container) -- cgit 1.4.1-2-gfad0