diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-15 01:44:58 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-15 01:44:58 -0800 |
commit | 360d45e68edf92e85e3ae7cb198be88182374331 (patch) | |
tree | 05fecfe8484d222d79ee68f6255a6bf7f1fa41a9 | |
parent | 28ca3dbc71a3c3258bb7876fe1bae7c5edac4438 (diff) | |
download | mu-360d45e68edf92e85e3ae7cb198be88182374331.tar.gz |
2444
Yet another bugfix as I trace through the last session with Caleb.
-rw-r--r-- | 010vm.cc | 11 | ||||
-rw-r--r-- | 059shape_shifting_recipe.cc | 12 |
2 files changed, 21 insertions, 2 deletions
diff --git a/010vm.cc b/010vm.cc index 0b2888f0..312aa3fc 100644 --- a/010vm.cc +++ b/010vm.cc @@ -484,11 +484,18 @@ bool deeply_equal(const string_tree* a, const string_tree* b) { && deeply_equal(a->right, b->right); } +:(before "End Globals") +set<string> Literal_type_names; +:(before "End One-time Setup") +Literal_type_names.insert("literal"); +Literal_type_names.insert("number"); +Literal_type_names.insert("character"); +:(code) bool deeply_equal_types(const string_tree* a, const string_tree* b) { if (!a) return !b; if (!b) return !a; - if (a->value == "character" && b->value == "number") return true; - if (a->value == "number" && b->value == "character") return true; + if (Literal_type_names.find(a->value) != Literal_type_names.end()) + return Literal_type_names.find(b->value) != Literal_type_names.end(); return a->value == b->value && deeply_equal_types(a->left, b->left) && deeply_equal_types(a->right, b->right); diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index 2436b924..4ca9779c 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -257,6 +257,7 @@ void accumulate_type_ingredients(const string_tree* exemplar_type, const string_ else { if (!deeply_equal_types(get(mappings, exemplar_type->value), refinement_type)) { raise_error << maybe(caller_recipe.name) << "no call found for '" << call_instruction.to_string() << "'\n" << end(); +//? cerr << exemplar_type->value << ": " << debug_string(get(mappings, exemplar_type->value)) << " vs " << debug_string(refinement_type) << '\n'; *error = true; return; } @@ -539,3 +540,14 @@ recipe foo x:address:_elem -> y:address:_elem [ ] +error: foo: failed to map a type to x +error: foo: failed to map a type to y + +:(scenario specialize_with_literal_5) +recipe main [ + foo 3, 4 # recipe mapping two variables to literals +] +recipe foo x:_elem, y:_elem [ + local-scope + load-ingredients + 1:number/raw <- add x, y +] ++mem: storing 7 in location 1 |