diff options
-rw-r--r-- | 010vm.cc | 12 | ||||
-rw-r--r-- | 014literal_string.cc | 2 | ||||
-rw-r--r-- | 015literal_noninteger.cc | 2 | ||||
-rw-r--r-- | 030container.cc | 4 | ||||
-rw-r--r-- | 032array.cc | 4 | ||||
-rw-r--r-- | 033exclusive_container.cc | 2 | ||||
-rw-r--r-- | 040brace.cc | 2 | ||||
-rw-r--r-- | 059shape_shifting_recipe.cc | 2 | ||||
-rw-r--r-- | 061recipe.cc | 2 | ||||
-rw-r--r-- | 085scenario_console.cc | 4 |
10 files changed, 19 insertions, 17 deletions
diff --git a/010vm.cc b/010vm.cc index e8c7b78d..b059ece0 100644 --- a/010vm.cc +++ b/010vm.cc @@ -73,15 +73,16 @@ struct property { // Types can range from a simple type ordinal, to arbitrarily complex trees of // type parameters, like (map (address array character) (list number)) struct type_tree { + string name; type_ordinal value; type_tree* left; type_tree* right; ~type_tree(); type_tree(const type_tree& old); // simple: type ordinal - explicit type_tree(type_ordinal v) :value(v), left(NULL), right(NULL) {} + explicit type_tree(string name, type_ordinal v) :name(name), value(v), left(NULL), right(NULL) {} // intermediate: list of type ordinals - type_tree(type_ordinal v, type_tree* r) :value(v), left(NULL), right(r) {} + type_tree(string name, type_ordinal v, type_tree* r) :name(name), value(v), left(NULL), right(r) {} // advanced: tree containing type ordinals type_tree(type_tree* l, type_tree* r) :value(0), left(l), right(r) {} }; @@ -245,12 +246,12 @@ reagent::reagent(string s) :original_string(s), type(NULL), value(0), initialize if (is_integer(name) && type == NULL) { assert(!properties.at(0).second); properties.at(0).second = new string_tree("literal"); - type = new type_tree(get(Type_ordinal, "literal")); + type = new type_tree("literal", get(Type_ordinal, "literal")); } if (name == "_" && type == NULL) { assert(!properties.at(0).second); properties.at(0).second = new string_tree("dummy"); - type = new type_tree(get(Type_ordinal, "literal")); + type = new type_tree("literal", get(Type_ordinal, "literal")); } // End Parsing reagent } @@ -263,9 +264,10 @@ string_tree* parse_property_list(istream& in) { return result; } +// TODO: delete type_tree* new_type_tree(const string_tree* properties) { if (!properties) return NULL; - type_tree* result = new type_tree(0); + type_tree* result = new type_tree("", 0); if (!properties->value.empty()) { const string& type_name = properties->value; if (contains_key(Type_ordinal, type_name)) diff --git a/014literal_string.cc b/014literal_string.cc index d089250e..12015f3b 100644 --- a/014literal_string.cc +++ b/014literal_string.cc @@ -110,7 +110,7 @@ if (s.at(0) == '[') { s.erase(0, 1); strip_last(s); name = s; - type = new type_tree(0); + type = new type_tree("literal-string", 0); properties.push_back(pair<string, string_tree*>(name, new string_tree("literal-string"))); return; } diff --git a/015literal_noninteger.cc b/015literal_noninteger.cc index 497b4676..4cea4104 100644 --- a/015literal_noninteger.cc +++ b/015literal_noninteger.cc @@ -10,7 +10,7 @@ recipe main [ :(after "Parsing reagent(string s)") if (is_noninteger(s)) { name = s; - type = new type_tree(0); + type = new type_tree("literal-number", 0); properties.push_back(pair<string, string_tree*>(name, new string_tree("literal-number"))); set_value(to_double(s)); return; diff --git a/030container.cc b/030container.cc index f3ecd8f5..1a601997 100644 --- a/030container.cc +++ b/030container.cc @@ -301,7 +301,7 @@ case GET_ADDRESS: { // same type as for GET.. reagent element = element_type(base, offset_value); // ..except for an address at the start - element.type = new type_tree(get(Type_ordinal, "address"), element.type); + element.type = new type_tree("address", get(Type_ordinal, "address"), element.type); if (!types_coercible(product, element)) { raise_error << maybe(get(Recipe, r).name) << "'get-address " << base.original_string << ", " << offset.original_string << "' should write to " << to_string(element.type) << " but " << product.name << " has type " << to_string(product.type) << '\n' << end(); break; @@ -435,7 +435,7 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { type_tree* new_type_tree_with_new_types_for_unknown(const string_tree* properties, const type_info& info) { if (!properties) return NULL; - type_tree* result = new type_tree(0); + type_tree* result = new type_tree("", 0); if (!properties->value.empty()) { const string& type_name = properties->value; if (contains_key(Type_ordinal, type_name)) { diff --git a/032array.cc b/032array.cc index cef79b35..c4676d96 100644 --- a/032array.cc +++ b/032array.cc @@ -331,8 +331,8 @@ case INDEX_ADDRESS: { reagent product = inst.products.at(0); canonize_type(product); reagent element; - element.type = new type_tree(*array_element(base.type)); - element.type = new type_tree(get(Type_ordinal, "address"), element.type); + element.type = new type_tree("address", get(Type_ordinal, "address"), + new type_tree(*array_element(base.type))); if (!types_coercible(product, element)) { raise_error << maybe(get(Recipe, r).name) << "'index' on " << base.original_string << " can't be saved in " << product.original_string << "; type should be " << to_string(element.type) << '\n' << end(); break; diff --git a/033exclusive_container.cc b/033exclusive_container.cc index fd47728b..26def074 100644 --- a/033exclusive_container.cc +++ b/033exclusive_container.cc @@ -104,7 +104,7 @@ case MAYBE_CONVERT: { break; } reagent variant = variant_type(base, offset.value); - variant.type = new type_tree(get(Type_ordinal, "address"), variant.type); + variant.type = new type_tree("address", get(Type_ordinal, "address"), variant.type); if (!types_coercible(product, variant)) { raise_error << maybe(caller.name) << "'maybe-convert " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should write to " << to_string(variant.type) << " but " << product.name << " has type " << to_string(product.type) << '\n' << end(); break; diff --git a/040brace.cc b/040brace.cc index 007088a3..873c604c 100644 --- a/040brace.cc +++ b/040brace.cc @@ -114,7 +114,7 @@ void transform_braces(const recipe_ordinal r) { } // if implicit, compute target reagent target; - target.type = new type_tree(get(Type_ordinal, "offset")); + target.type = new type_tree("offset", get(Type_ordinal, "offset")); target.properties.at(0).second = new string_tree("offset"); target.set_value(0); if (open_braces.empty()) diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index 18b4873a..dd874bb7 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -447,7 +447,7 @@ void ensure_all_concrete_types(/*const*/ recipe& new_recipe, const recipe& exemp void ensure_all_concrete_types(/*const*/ reagent& x, const recipe& exemplar) { if (!x.type) { raise_error << maybe(exemplar.name) << "failed to map a type to " << x.original_string << '\n' << end(); - x.type = new type_tree(0); // just to prevent crashes later + x.type = new type_tree("", 0); // just to prevent crashes later return; } if (x.type->value == -1) { diff --git a/061recipe.cc b/061recipe.cc index 7d9bb3af..3945ff49 100644 --- a/061recipe.cc +++ b/061recipe.cc @@ -34,7 +34,7 @@ get_or_insert(Type, recipe).name = "recipe"; :(before "End Null-type is_disqualified Exceptions") if (!x.properties.at(0).second && contains_key(Recipe_ordinal, x.name)) { x.properties.at(0).second = new string_tree("recipe-literal"); - x.type = new type_tree(get(Type_ordinal, "recipe-literal")); + x.type = new type_tree("recipe-literal", get(Type_ordinal, "recipe-literal")); x.set_value(get(Recipe_ordinal, x.name)); return true; } diff --git a/085scenario_console.cc b/085scenario_console.cc index 1b746adb..3ed819cc 100644 --- a/085scenario_console.cc +++ b/085scenario_console.cc @@ -277,7 +277,7 @@ long long int size_of_event() { // memoize result if already computed static long long int result = 0; if (result) return result; - type_tree* type = new type_tree(get(Type_ordinal, "event")); + type_tree* type = new type_tree("event", get(Type_ordinal, "event")); result = size_of(type); delete type; return result; @@ -288,7 +288,7 @@ long long int size_of_console() { static long long int result = 0; if (result) return result; assert(get(Type_ordinal, "console")); - type_tree* type = new type_tree(get(Type_ordinal, "console")); + type_tree* type = new type_tree("console", get(Type_ordinal, "console")); result = size_of(type)+/*refcount*/1; delete type; return result; |