diff options
-rw-r--r-- | 010vm.cc | 4 | ||||
-rw-r--r-- | 030container.cc | 28 | ||||
-rw-r--r-- | 031address.cc | 6 | ||||
-rw-r--r-- | 032array.cc | 4 | ||||
-rw-r--r-- | 033exclusive_container.cc | 8 | ||||
-rw-r--r-- | 036call_reply.cc | 2 | ||||
-rw-r--r-- | 047check_type_by_name.cc | 4 | ||||
-rw-r--r-- | 056recipe_header.cc | 10 | ||||
-rw-r--r-- | 058shape_shifting_container.cc | 10 | ||||
-rw-r--r-- | 059shape_shifting_recipe.cc | 22 | ||||
-rw-r--r-- | 061recipe.cc | 2 | ||||
-rw-r--r-- | 062scheduler.cc | 2 |
12 files changed, 41 insertions, 61 deletions
diff --git a/010vm.cc b/010vm.cc index 711f8fa4..ed98bf6d 100644 --- a/010vm.cc +++ b/010vm.cc @@ -461,7 +461,7 @@ string to_string(const reagent& r) { string debug_string(const reagent& x) { ostringstream out; - out << x.name << ": " << debug_string(x.type) << " -- " << to_string(x); + out << x.name << ": " << x.value << ' ' << to_string(x.type) << " -- " << to_string(x); return out.str(); } @@ -514,7 +514,7 @@ void dump(const string_tree* x, ostream& out) { out << ')'; } -string debug_string(const type_tree* type) { +string to_string(const type_tree* type) { // abbreviate a single-node tree to just its contents if (!type) return "NULLNULLNULL"; // should never happen ostringstream out; diff --git a/030container.cc b/030container.cc index e88b0692..f3ecd8f5 100644 --- a/030container.cc +++ b/030container.cc @@ -162,7 +162,7 @@ case GET: { // Update GET product in Check const reagent element = element_type(base, offset_value); if (!types_coercible(product, element)) { - raise_error << maybe(get(Recipe, r).name) << "'get " << base.original_string << ", " << offset.original_string << "' should write to " << debug_string(element.type) << " but " << product.name << " has type " << debug_string(product.type) << '\n' << end(); + raise_error << maybe(get(Recipe, r).name) << "'get " << 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; } break; @@ -187,7 +187,7 @@ case GET: { trace(9998, "run") << "address to copy is " << src << end(); reagent tmp = element_type(base, offset); tmp.set_value(src); - trace(9998, "run") << "its type is " << debug_string(tmp.type) << end(); + trace(9998, "run") << "its type is " << to_string(tmp.type) << end(); products.push_back(read_memory(tmp)); break; } @@ -303,7 +303,7 @@ case GET_ADDRESS: { // ..except for an address at the start element.type = new type_tree(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 " << debug_string(element.type) << " but " << product.name << " has type " << debug_string(product.type) << '\n' << end(); + 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; } break; @@ -373,8 +373,8 @@ container foo [ y:number ] +parse: --- defining container foo -+parse: element: x: number -- {"x": "number"} -+parse: element: y: number -- {"y": "number"} ++parse: element: {"x": "number"} ++parse: element: {"y": "number"} :(scenario container_use_before_definition) container foo [ @@ -388,15 +388,15 @@ container bar [ ] +parse: --- defining container foo +parse: type number: 1000 -+parse: element: x: number -- {"x": "number"} ++parse: element: {"x": "number"} # todo: brittle # type bar is unknown at this point, but we assign it a number -+parse: element: y: ?1001 -- {"y": "bar"} -# later type bar gets a definition ++parse: element: {"y": "bar"} +# later type bar geon +parse: --- defining container bar +parse: type number: 1001 -+parse: element: x: number -- {"x": "number"} -+parse: element: y: number -- {"y": "number"} ++parse: element: {"x": "number"} ++parse: element: {"y": "number"} :(before "End Command Handlers") else if (command == "container") { @@ -427,7 +427,7 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { // handle undefined types delete info.elements.back().type; info.elements.back().type = new_type_tree_with_new_types_for_unknown(info.elements.back().properties.at(0).second, info); - trace(9993, "parse") << " element: " << debug_string(info.elements.back()) << end(); + trace(9993, "parse") << " element: " << to_string(info.elements.back()) << end(); // End Load Container Element Definition } info.size = SIZE(info.elements); @@ -592,8 +592,8 @@ container foo [ y:number ] +parse: --- defining container foo -+parse: element: x: number -- {"x": "number"} -+parse: element: y: number -- {"y": "number"} ++parse: element: {"x": "number"} ++parse: element: {"y": "number"} :(before "End Transform All") check_container_field_types(); @@ -787,7 +787,7 @@ void check_merge_call(const vector<reagent>& ingredients, const reagent& product switch (container_info.kind) { case CONTAINER: { reagent expected_ingredient = element_type(container, state.data.top().container_element_index); - trace(9999, "transform") << "checking container " << debug_string(container) << " || " << debug_string(expected_ingredient) << " vs ingredient " << ingredient_index << end(); + trace(9999, "transform") << "checking container " << to_string(container) << " || " << to_string(expected_ingredient) << " vs ingredient " << ingredient_index << end(); // if the current element is the ingredient we expect, move on to the next element/ingredient if (types_coercible(expected_ingredient, ingredients.at(ingredient_index))) { ++ingredient_index; diff --git a/031address.cc b/031address.cc index 335dcd6c..a6341cf7 100644 --- a/031address.cc +++ b/031address.cc @@ -91,7 +91,7 @@ if (!canonize_type(product)) continue; bool canonize_type(reagent& r) { while (has_property(r, "lookup")) { if (!r.type || r.type->value != get(Type_ordinal, "address")) { - raise_error << "can't lookup non-address: " << to_string(r) << ": " << debug_string(r.type) << '\n' << end(); + raise_error << "can't lookup non-address: " << to_string(r) << ": " << to_string(r.type) << '\n' << end(); return false; } drop_from_type(r, "address"); @@ -103,11 +103,11 @@ bool canonize_type(reagent& r) { void drop_from_type(reagent& r, string expected_type) { if (!r.type) { - raise_error << "can't drop " << expected_type << " from " << debug_string(r) << '\n' << end(); + raise_error << "can't drop " << expected_type << " from " << to_string(r) << '\n' << end(); return; } if (r.properties.at(0).second->value != expected_type) { - raise_error << "can't drop " << expected_type << " from " << debug_string(r) << '\n' << end(); + raise_error << "can't drop " << expected_type << " from " << to_string(r) << '\n' << end(); return; } type_tree* tmp = r.type; diff --git a/032array.cc b/032array.cc index d25ee7fa..cef79b35 100644 --- a/032array.cc +++ b/032array.cc @@ -193,7 +193,7 @@ case INDEX: { reagent element; element.type = 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 " << debug_string(element.type) << '\n' << end(); + 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; } break; @@ -334,7 +334,7 @@ case INDEX_ADDRESS: { element.type = new type_tree(*array_element(base.type)); element.type = new type_tree(get(Type_ordinal, "address"), element.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 " << debug_string(element.type) << '\n' << end(); + 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; } break; diff --git a/033exclusive_container.cc b/033exclusive_container.cc index b5116914..fd47728b 100644 --- a/033exclusive_container.cc +++ b/033exclusive_container.cc @@ -106,7 +106,7 @@ case MAYBE_CONVERT: { reagent variant = variant_type(base, offset.value); variant.type = new type_tree(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 " << debug_string(variant.type) << " but " << product.name << " has type " << debug_string(product.type) << '\n' << end(); + 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; } break; @@ -164,8 +164,8 @@ exclusive-container foo [ y:number ] +parse: --- defining exclusive-container foo -+parse: element: x: number -- {"x": "number"} -+parse: element: y: number -- {"y": "number"} ++parse: element: {"x": "number"} ++parse: element: {"y": "number"} :(before "End Command Handlers") else if (command == "exclusive-container") { @@ -243,7 +243,7 @@ recipe main [ :(before "End valid_merge Cases") case EXCLUSIVE_CONTAINER: { assert(state.data.top().container_element_index == 0); - trace(9999, "transform") << "checking exclusive container " << debug_string(container) << " vs ingredient " << ingredient_index << end(); + trace(9999, "transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end(); if (!is_literal(ingredients.at(ingredient_index))) { raise_error << maybe(caller.name) << "ingredient " << ingredient_index << " of 'merge' should be a literal, for the tag of exclusive-container " << container_info.name << '\n' << end(); return; diff --git a/036call_reply.cc b/036call_reply.cc index ee295aa2..d4bfa085 100644 --- a/036call_reply.cc +++ b/036call_reply.cc @@ -87,7 +87,7 @@ void check_types_of_reply_instructions(recipe_ordinal r) { canonize_type(lhs); reagent rhs = caller_instruction.products.at(i); canonize_type(rhs); - raise_error << debug_string(lhs.type) << " vs " << debug_string(rhs.type) << '\n' << end(); + raise_error << to_string(lhs.type) << " vs " << to_string(rhs.type) << '\n' << end(); goto finish_reply_check; } } diff --git a/047check_type_by_name.cc b/047check_type_by_name.cc index 74f61e24..9889674b 100644 --- a/047check_type_by_name.cc +++ b/047check_type_by_name.cc @@ -40,7 +40,7 @@ void deduce_missing_type(map<string, type_tree*>& type, map<string, string_tree* if (x.type) return; if (!contains_key(type, x.name)) return; x.type = new type_tree(*type[x.name]); - trace(9992, "transform") << x.name << " <= " << debug_string(x.type) << end(); + trace(9992, "transform") << x.name << " <= " << to_string(x.type) << end(); assert(!x.properties.at(0).second); x.properties.at(0).second = new string_tree(*type_name[x.name]); } @@ -50,7 +50,7 @@ void check_type(map<string, type_tree*>& type, map<string, string_tree*>& type_n if (is_integer(x.name)) return; // if you use raw locations you're probably doing something unsafe if (!x.type) return; // might get filled in by other logic later if (!contains_key(type, x.name)) { - trace(9992, "transform") << x.name << " => " << debug_string(x.type) << end(); + trace(9992, "transform") << x.name << " => " << to_string(x.type) << end(); put(type, x.name, x.type); } if (!contains_key(type_name, x.name)) diff --git a/056recipe_header.cc b/056recipe_header.cc index 757e57fe..40952f69 100644 --- a/056recipe_header.cc +++ b/056recipe_header.cc @@ -369,12 +369,12 @@ void deduce_types_from_header(const recipe_ordinal r) { for (long long int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { put(header_type, caller_recipe.ingredients.at(i).name, caller_recipe.ingredients.at(i).type); put(header_type_name, caller_recipe.ingredients.at(i).name, caller_recipe.ingredients.at(i).properties.at(0).second); - trace(9993, "transform") << "type of " << caller_recipe.ingredients.at(i).name << " is " << debug_string(caller_recipe.ingredients.at(i).type) << end(); + trace(9993, "transform") << "type of " << caller_recipe.ingredients.at(i).name << " is " << to_string(caller_recipe.ingredients.at(i).type) << end(); } for (long long int i = 0; i < SIZE(caller_recipe.products); ++i) { put(header_type, caller_recipe.products.at(i).name, caller_recipe.products.at(i).type); put(header_type_name, caller_recipe.products.at(i).name, caller_recipe.products.at(i).properties.at(0).second); - trace(9993, "transform") << "type of " << caller_recipe.products.at(i).name << " is " << debug_string(caller_recipe.products.at(i).type) << end(); + trace(9993, "transform") << "type of " << caller_recipe.products.at(i).name << " is " << to_string(caller_recipe.products.at(i).type) << end(); } for (long long int i = 0; i < SIZE(caller_recipe.steps); ++i) { instruction& inst = caller_recipe.steps.at(i); @@ -387,10 +387,10 @@ void deduce_types_from_header(const recipe_ordinal r) { inst.ingredients.at(i).type = new type_tree(*get(header_type, inst.ingredients.at(i).name)); if (!inst.ingredients.at(i).properties.at(0).second) inst.ingredients.at(i).properties.at(0).second = new string_tree(*get(header_type_name, inst.ingredients.at(i).name)); - trace(9993, "transform") << "type of " << inst.ingredients.at(i).name << " is " << debug_string(inst.ingredients.at(i).type) << end(); + trace(9993, "transform") << "type of " << inst.ingredients.at(i).name << " is " << to_string(inst.ingredients.at(i).type) << end(); } for (long long int i = 0; i < SIZE(inst.products); ++i) { - trace(9993, "transform") << " product: " << debug_string(inst.products.at(i)) << end(); + trace(9993, "transform") << " product: " << to_string(inst.products.at(i)) << end(); if (inst.products.at(i).type) continue; if (header_type.find(inst.products.at(i).name) == header_type.end()) continue; @@ -398,7 +398,7 @@ void deduce_types_from_header(const recipe_ordinal r) { inst.products.at(i).type = new type_tree(*get(header_type, inst.products.at(i).name)); if (!inst.products.at(i).properties.at(0).second) inst.products.at(i).properties.at(0).second = new string_tree(*get(header_type_name, inst.products.at(i).name)); - trace(9993, "transform") << "type of " << inst.products.at(i).name << " is " << debug_string(inst.products.at(i).type) << end(); + trace(9993, "transform") << "type of " << inst.products.at(i).name << " is " << to_string(inst.products.at(i).type) << end(); } } } diff --git a/058shape_shifting_container.cc b/058shape_shifting_container.cc index b5da0992..f16d4c75 100644 --- a/058shape_shifting_container.cc +++ b/058shape_shifting_container.cc @@ -167,7 +167,7 @@ const type_tree* type = get(Type, base_type).elements.at(i).type; if (type->value >= START_TYPE_INGREDIENTS) { long long int size = size_of_type_ingredient(type, base.type->right); if (!size) - raise_error << "illegal field type '" << debug_string(type) << "' seems to be missing a type ingredient or three\n" << end(); + raise_error << "illegal field type '" << to_string(type) << "' seems to be missing a type ingredient or three\n" << end(); src += size; continue; } @@ -226,7 +226,7 @@ recipe main [ :(before "End element_type Special-cases") if (contains_type_ingredient(element)) { if (!canonized_base.type->right) - raise_error << "illegal type '" << debug_string(canonized_base.type) << "' seems to be missing a type ingredient or three\n" << end(); + raise_error << "illegal type '" << to_string(canonized_base.type) << "' seems to be missing a type ingredient or three\n" << end(); replace_type_ingredients(element.type, element.properties.at(0).second, canonized_base.type->right, canonized_base.properties.at(0).second ? canonized_base.properties.at(0).second->right : NULL, info); } @@ -253,7 +253,7 @@ void replace_type_ingredients(type_tree* element_type, string_tree* element_type const long long int type_ingredient_index = element_type->value-START_TYPE_INGREDIENTS; if (!has_nth_type(callsite_type, type_ingredient_index)) { - raise_error << "illegal type '" << debug_string(callsite_type) << "' seems to be missing a type ingredient or three\n" << end(); + raise_error << "illegal type '" << to_string(callsite_type) << "' seems to be missing a type ingredient or three\n" << end(); return; } @@ -479,7 +479,7 @@ const type_tree* type = get(Type, base_type).elements.at(i).type; if (type->value >= START_TYPE_INGREDIENTS) { long long int size = size_of_type_ingredient(type, base.type->right); if (!size) - raise_error << "illegal type '" << debug_string(type) << "' seems to be missing a type ingredient or three\n" << end(); + raise_error << "illegal type '" << to_string(type) << "' seems to be missing a type ingredient or three\n" << end(); result += size; continue; } @@ -570,6 +570,6 @@ recipe main [ :(before "End variant_type Special-cases") if (contains_type_ingredient(element)) { if (!canonized_base.type->right) - raise_error << "illegal type '" << debug_string(canonized_base.type) << "' seems to be missing a type ingredient or three\n" << end(); + raise_error << "illegal type '" << to_string(canonized_base.type) << "' seems to be missing a type ingredient or three\n" << end(); replace_type_ingredients(element.type, element.properties.at(0).second, canonized_base.type->right, canonized_base.properties.at(0).second ? canonized_base.properties.at(0).second->right : NULL, info); } diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index a9bf9071..18b4873a 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -165,26 +165,6 @@ recipe_ordinal best_shape_shifting_variant(const instruction& inst, vector<recip return candidates.at(best_index); } - -string header(const recipe& caller) { - if (!caller.has_header) return maybe(caller.name); - ostringstream out; - out << caller.name; - for (long long int i = 0; i < SIZE(caller.ingredients); ++i) { - if (i > 0) out << ','; - out << ' ' << debug_string(caller.ingredients.at(i)); - } - if (!caller.products.empty()) { - out << " ->"; - for (long long int i = 0; i < SIZE(caller.products); ++i) { - if (i > 0) out << ','; - out << ' ' << debug_string(caller.products.at(i)); - } - } - out << ": "; - return out.str(); -} - bool any_type_ingredient_in_header(recipe_ordinal variant) { const recipe& caller = get(Recipe, variant); for (long long int i = 0; i < SIZE(caller.ingredients); ++i) { @@ -431,7 +411,7 @@ void replace_type_ingredients(reagent& x, const map<string, const string_tree*>& delete x.type; x.type = new_type_tree(x.properties.at(0).second); if (x.type) - trace(9993, "transform") << " after: " << debug_string(x.type) << end(); + trace(9993, "transform") << " after: " << to_string(x.type) << end(); } void replace_type_ingredients(string_tree* type, const map<string, const string_tree*>& mappings) { diff --git a/061recipe.cc b/061recipe.cc index 4e6f2b83..7d9bb3af 100644 --- a/061recipe.cc +++ b/061recipe.cc @@ -180,7 +180,7 @@ recipe f x:boolean -> y:boolean [ :(before "End Matching Types For Literal(to)") if (is_mu_recipe(to)) { if (!contains_key(Recipe, from.value)) { - raise_error << "trying to store recipe " << from.name << " into " << debug_string(to) << " but there's no such recipe\n" << end(); + raise_error << "trying to store recipe " << from.name << " into " << to_string(to) << " but there's no such recipe\n" << end(); return false; } const recipe& rrhs = get(Recipe, from.value); diff --git a/062scheduler.cc b/062scheduler.cc index 348024c2..2d3d4418 100644 --- a/062scheduler.cc +++ b/062scheduler.cc @@ -157,7 +157,7 @@ case START_RUNNING: { break; } if (!is_mu_recipe(inst.ingredients.at(0))) { - raise_error << maybe(get(Recipe, r).name) << "first ingredient of 'start-running' should be a recipe, but got " << debug_string(inst.ingredients.at(0)) << '\n' << end(); + raise_error << maybe(get(Recipe, r).name) << "first ingredient of 'start-running' should be a recipe, but got " << to_string(inst.ingredients.at(0)) << '\n' << end(); break; } break; |