diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-03-19 00:51:19 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-03-19 00:53:45 -0700 |
commit | 968866f7ac183811e449b11da9b2a2f1b0d97227 (patch) | |
tree | 6bd8d4f1412d4d2ccc7a74f0537c166bf0fda77e | |
parent | 1d1faace5d624b7bac96eb57a9373d2511ac08e1 (diff) | |
download | mu-968866f7ac183811e449b11da9b2a2f1b0d97227.tar.gz |
2791
Simplify 2790 by simply not computing any type->value inside parse_type_tree. It now only generates names, and it turns out the consumers handle the absence of values anyway. Now parse_type_tree no longer pollutes the Type_ordinal table with type ingredients.
-rw-r--r-- | 030container.cc | 3 | ||||
-rw-r--r-- | 057shape_shifting_container.cc | 3 | ||||
-rw-r--r-- | 058shape_shifting_recipe.cc | 17 |
3 files changed, 5 insertions, 18 deletions
diff --git a/030container.cc b/030container.cc index 1f86d054..4cc0d58e 100644 --- a/030container.cc +++ b/030container.cc @@ -433,7 +433,6 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { void replace_unknown_types_with_unique_ordinals(type_tree* type, const type_info& info) { if (!type) return; - // End insert_container Special-cases if (!type->name.empty()) { if (contains_key(Type_ordinal, type->name)) { type->value = get(Type_ordinal, type->name); @@ -441,12 +440,12 @@ void replace_unknown_types_with_unique_ordinals(type_tree* type, const type_info else if (is_integer(type->name)) { // sometimes types will contain non-type tags, like numbers for the size of an array type->value = 0; } + // End insert_container Special-cases else if (type->name != "->") { // used in recipe types put(Type_ordinal, type->name, Next_type_ordinal++); type->value = get(Type_ordinal, type->name); } } - recurse: replace_unknown_types_with_unique_ordinals(type->left, info); replace_unknown_types_with_unique_ordinals(type->right, info); } diff --git a/057shape_shifting_container.cc b/057shape_shifting_container.cc index 04b5900f..06ceeea3 100644 --- a/057shape_shifting_container.cc +++ b/057shape_shifting_container.cc @@ -94,9 +94,8 @@ void read_type_ingredients(string& name) { :(before "End insert_container Special-cases") // check for use of type ingredients -else if (!type->name.empty() && is_type_ingredient_name(type->name)) { +else if (is_type_ingredient_name(type->name)) { type->value = get(info.type_ingredient_names, type->name); - goto recurse; } :(code) bool is_type_ingredient_name(const string& type) { diff --git a/058shape_shifting_recipe.cc b/058shape_shifting_recipe.cc index 26e0eaf6..784b1fd0 100644 --- a/058shape_shifting_recipe.cc +++ b/058shape_shifting_recipe.cc @@ -463,13 +463,8 @@ type_tree* parse_type_tree(istream& in) { in.get(); return NULL; } - if (in.peek() != '(') { - string type_name = next_word(in); - if (!contains_key(Type_ordinal, type_name)) - put(Type_ordinal, type_name, Next_type_ordinal++); - type_tree* result = new type_tree(type_name, get(Type_ordinal, type_name)); - return result; - } + if (in.peek() != '(') + return new type_tree(next_word(in), 0); in.get(); // skip '(' type_tree* result = NULL; type_tree** curr = &result; @@ -479,14 +474,8 @@ type_tree* parse_type_tree(istream& in) { skip_whitespace_but_not_newline(in); if (in.peek() == '(') (*curr)->left = parse_type_tree(in); - else { + else (*curr)->name = next_word(in); - if (!is_type_ingredient_name((*curr)->name)) { - if (!contains_key(Type_ordinal, (*curr)->name)) - put(Type_ordinal, (*curr)->name, Next_type_ordinal++); - (*curr)->value = get(Type_ordinal, (*curr)->name); - } - } curr = &(*curr)->right; } in.get(); // skip ')' |