diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-02-18 23:52:12 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-02-18 23:54:44 -0800 |
commit | e8a5f07843d768829b825033b3e7839493ec374e (patch) | |
tree | 6d1866fb28aa61ecaf3117ec70805297b09aaa75 | |
parent | fbc3455bf14ccba2854317ebf40dbb4d47d02d05 (diff) | |
download | mu-e8a5f07843d768829b825033b3e7839493ec374e.tar.gz |
2674
Make it explicit that I don't currently intend to further replace type ingredients inside replacements. That might well make sense, but I've not thought up any use cases or tests for it, and it seems excessive at the moment. And when I find bugs I keep wondering if the repeated replace might be the problem. No longer.
-rw-r--r-- | 058shape_shifting_container.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/058shape_shifting_container.cc b/058shape_shifting_container.cc index 612f0463..7b11a61e 100644 --- a/058shape_shifting_container.cc +++ b/058shape_shifting_container.cc @@ -233,6 +233,7 @@ bool contains_type_ingredient(const type_tree* type) { return contains_type_ingredient(type->left) || contains_type_ingredient(type->right); } +// ugly and likely wrong; maybe avoid replacing in place? void replace_type_ingredients(type_tree* element_type, string_tree* element_type_name, const type_tree* callsite_type, const string_tree* callsite_type_name) { if (!callsite_type) return; // error but it's already been raised above if (!element_type) return; @@ -250,6 +251,7 @@ void replace_type_ingredients(type_tree* element_type, string_tree* element_type type_tree* old_right = element_type->right; element_type->right = replacement->right ? new type_tree(*replacement->right) : NULL; append(element_type->right, old_right); + const string_tree* replacement_name = nth_type_name(callsite_type_name, type_ingredient_index); element_type_name->value = replacement_name->value; assert(!element_type_name->left); // since value is set @@ -257,8 +259,12 @@ void replace_type_ingredients(type_tree* element_type, string_tree* element_type string_tree* old_right_name = element_type_name->right; element_type_name->right = replacement_name->right ? new string_tree(*replacement_name->right) : NULL; append(element_type_name->right, old_right_name); + + replace_type_ingredients(old_right, old_right_name, callsite_type, callsite_type_name); + } + else { + replace_type_ingredients(element_type->right, element_type_name->right, callsite_type, callsite_type_name); } - replace_type_ingredients(element_type->right, element_type_name->right, callsite_type, callsite_type_name); } void append(type_tree*& base, type_tree* extra) { |