From 360d45e68edf92e85e3ae7cb198be88182374331 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 15 Nov 2015 01:44:58 -0800 Subject: 2444 Yet another bugfix as I trace through the last session with Caleb. --- 010vm.cc | 11 +++++++++-- 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 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 -- cgit 1.4.1-2-gfad0 ' size='10' name='q' value=''/>
blob: 0f013dfc2b64062d0a0ae96da3e5af148049ad4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33