diff options
-rw-r--r-- | 021check_instruction.cc | 54 | ||||
-rw-r--r-- | 031address.cc | 6 | ||||
-rw-r--r-- | 059shape_shifting_recipe.cc | 40 | ||||
-rw-r--r-- | 061recipe.cc | 12 |
4 files changed, 56 insertions, 56 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc index 03f1cc61..de5d8394 100644 --- a/021check_instruction.cc +++ b/021check_instruction.cc @@ -100,50 +100,50 @@ bool types_coercible(const reagent& to, const reagent& from) { return false; } -bool types_match(const reagent& lhs, const reagent& rhs) { +bool types_match(const reagent& to, const reagent& from) { // to sidestep type-checking, use /unsafe in the source. // this will be highlighted in red inside vim. just for setting up some tests. - if (is_unsafe(rhs)) return true; - if (is_literal(rhs)) { - if (is_mu_array(lhs)) return false; - // End Matching Types For Literal(lhs) + if (is_unsafe(from)) return true; + if (is_literal(from)) { + if (is_mu_array(to)) return false; + // End Matching Types For Literal(to) // allow writing 0 to any address - if (is_mu_address(lhs)) return rhs.name == "0"; - if (!lhs.type) return false; - if (lhs.type->value == get(Type_ordinal, "boolean")) - return boolean_matches_literal(lhs, rhs); - return size_of(lhs) == 1; // literals are always scalars + if (is_mu_address(to)) return from.name == "0"; + if (!to.type) return false; + if (to.type->value == get(Type_ordinal, "boolean")) + return boolean_matches_literal(to, from); + return size_of(to) == 1; // literals are always scalars } - return types_strictly_match(lhs, rhs); + return types_strictly_match(to, from); } -bool boolean_matches_literal(const reagent& lhs, const reagent& rhs) { - if (!is_literal(rhs)) return false; - if (!lhs.type) return false; - if (lhs.type->value != get(Type_ordinal, "boolean")) return false; - return rhs.name == "0" || rhs.name == "1"; +bool boolean_matches_literal(const reagent& to, const reagent& from) { + if (!is_literal(from)) return false; + if (!to.type) return false; + if (to.type->value != get(Type_ordinal, "boolean")) return false; + return from.name == "0" || from.name == "1"; } // copy arguments because later layers will want to make changes to them // without perturbing the caller -bool types_strictly_match(reagent lhs, reagent rhs) { - if (is_literal(rhs) && lhs.type->value == get(Type_ordinal, "number")) return true; +bool types_strictly_match(reagent to, reagent from) { + if (is_literal(from) && to.type->value == get(Type_ordinal, "number")) return true; // to sidestep type-checking, use /unsafe in the source. // this will be highlighted in red inside vim. just for setting up some tests. - if (is_unsafe(rhs)) return true; + if (is_unsafe(from)) return true; // '_' never raises type error - if (is_dummy(lhs)) return true; - if (!lhs.type) return !rhs.type; - return types_strictly_match(lhs.type, rhs.type); + if (is_dummy(to)) return true; + if (!to.type) return !from.type; + return types_strictly_match(to.type, from.type); } // two types match if the second begins like the first // (trees perform the same check recursively on each subtree) -bool types_strictly_match(type_tree* lhs, type_tree* rhs) { - if (!lhs) return true; - if (!rhs) return lhs->value == 0; - if (lhs->value != rhs->value) return false; - return types_strictly_match(lhs->left, rhs->left) && types_strictly_match(lhs->right, rhs->right); +bool types_strictly_match(type_tree* to, type_tree* from) { + if (!to) return true; + if (!from) return to->value == 0; + if (to->value != from->value) return false; + return types_strictly_match(to->left, from->left) && types_strictly_match(to->right, from->right); } bool is_unsafe(const reagent& r) { diff --git a/031address.cc b/031address.cc index cc818a87..3fe289dd 100644 --- a/031address.cc +++ b/031address.cc @@ -71,9 +71,9 @@ recipe foo [ ] # don't crash -:(after "bool types_strictly_match(reagent lhs, reagent rhs)") - if (!canonize_type(lhs)) return false; - if (!canonize_type(rhs)) return false; +:(after "bool types_strictly_match(reagent to, reagent from)") + if (!canonize_type(to)) return false; + if (!canonize_type(from)) return false; :(after "bool is_mu_array(reagent r)") if (!canonize_type(r)) return false; diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index 97bd8dfe..5b423e9a 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -37,8 +37,8 @@ if (Current_routine->calls.front().running_step_index == 0 //: Make sure we don't match up literals with type ingredients without //: specialization. -:(before "End Matching Types For Literal(lhs)") -if (contains_type_ingredient_name(lhs)) return false; +:(before "End Matching Types For Literal(to)") +if (contains_type_ingredient_name(to)) return false; //: We'll be creating recipes without loading them from anywhere by //: *specializing* existing recipes. @@ -192,10 +192,10 @@ bool any_type_ingredient_in_header(recipe_ordinal variant) { return false; } -bool deeply_equal_concrete_types(reagent lhs, reagent rhs) { - canonize_type(lhs); - canonize_type(rhs); - return deeply_equal_concrete_types(lhs.properties.at(0).second, rhs.properties.at(0).second, rhs); +bool deeply_equal_concrete_types(reagent to, reagent from) { + canonize_type(to); + canonize_type(from); + return deeply_equal_concrete_types(to.properties.at(0).second, from.properties.at(0).second, from); } long long int number_of_concrete_types(recipe_ordinal r) { @@ -222,24 +222,24 @@ long long int number_of_concrete_types(const string_tree* type) { return result; } -bool deeply_equal_concrete_types(const string_tree* lhs, const string_tree* rhs, const reagent& rhs_reagent) { - if (!lhs) return !rhs; - if (!rhs) return !lhs; - if (is_type_ingredient_name(lhs->value)) return true; // type ingredient matches anything - if (lhs->value == "literal" && rhs->value == "literal") +bool deeply_equal_concrete_types(const string_tree* to, const string_tree* from, const reagent& rhs_reagent) { + if (!to) return !from; + if (!from) return !to; + if (is_type_ingredient_name(to->value)) return true; // type ingredient matches anything + if (to->value == "literal" && from->value == "literal") return true; - if (lhs->value == "literal" - && Literal_type_names.find(rhs->value) != Literal_type_names.end()) + if (to->value == "literal" + && Literal_type_names.find(from->value) != Literal_type_names.end()) return true; - if (rhs->value == "literal" - && Literal_type_names.find(lhs->value) != Literal_type_names.end()) + if (from->value == "literal" + && Literal_type_names.find(to->value) != Literal_type_names.end()) return true; - if (rhs->value == "literal" && lhs->value == "address") + if (from->value == "literal" && to->value == "address") return rhs_reagent.name == "0"; -//? cerr << lhs->value << " vs " << rhs->value << '\n'; - return lhs->value == rhs->value - && deeply_equal_concrete_types(lhs->left, rhs->left, rhs_reagent) - && deeply_equal_concrete_types(lhs->right, rhs->right, rhs_reagent); +//? cerr << to->value << " vs " << from->value << '\n'; + return to->value == from->value + && deeply_equal_concrete_types(to->left, from->left, rhs_reagent) + && deeply_equal_concrete_types(to->right, from->right, rhs_reagent); } bool contains_type_ingredient_name(const reagent& x) { diff --git a/061recipe.cc b/061recipe.cc index 0b4686dc..5798f4df 100644 --- a/061recipe.cc +++ b/061recipe.cc @@ -177,14 +177,14 @@ recipe f x:boolean -> y:boolean [ ] +error: main: can't copy f to {1: (recipe number -> number)}; types don't match -:(before "End Matching Types For Literal(lhs)") -if (is_mu_recipe(lhs)) { - if (!contains_key(Recipe, rhs.value)) { - raise_error << "trying to store recipe " << rhs.name << " into " << debug_string(lhs) << " but there's no such recipe\n" << end(); +:(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(); return false; } - const recipe& rrhs = get(Recipe, rhs.value); - const recipe& rlhs = from_reagent(lhs); + const recipe& rrhs = get(Recipe, from.value); + const recipe& rlhs = from_reagent(to); for (long int i = 0; i < min(SIZE(rlhs.ingredients), SIZE(rrhs.ingredients)); ++i) { if (!types_match(rlhs.ingredients.at(i), rrhs.ingredients.at(i))) return false; |