From ef96f57ce264c8e0bd98f6e8622d1c1e2eceafb2 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 15 Nov 2015 00:37:29 -0800 Subject: 2441 - never miss any specializations I was failing to specialize calls containing literals. And then I had to deal with whether literals should map to numbers or characters. (Answer: both.) One of the issues that still remains: shape-shifting recipes can't be called with literals for addresses, even if it's 0. --- 021check_instruction.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to '021check_instruction.cc') diff --git a/021check_instruction.cc b/021check_instruction.cc index 1d831369..fc1f0a1f 100644 --- a/021check_instruction.cc +++ b/021check_instruction.cc @@ -81,11 +81,18 @@ bool types_match(reagent lhs, reagent rhs) { if (is_raw(rhs)) return true; // allow writing 0 to any address if (rhs.name == "0" && is_mu_address(lhs)) return true; - if (is_literal(rhs)) return !is_mu_array(lhs) && !is_mu_address(lhs) && size_of(rhs) == size_of(lhs); + if (is_literal(rhs)) return valid_type_for_literal(lhs) && size_of(rhs) == size_of(lhs); if (!lhs.type) return !rhs.type; return types_match(lhs.type, rhs.type); } +bool valid_type_for_literal(const reagent& r) { + if (is_mu_array(r)) return false; + if (is_mu_address(r)) return false; + // End valid_type_for_literal Special-cases + return true; +} + // two types match if the second begins like the first // (trees perform the same check recursively on each subtree) bool types_match(type_tree* lhs, type_tree* rhs) { @@ -95,6 +102,8 @@ bool types_match(type_tree* lhs, type_tree* rhs) { if (lhs->value == get(Type_ordinal, "address")) return false; return size_of(rhs) == size_of(lhs); } + if (lhs->value == get(Type_ordinal, "character") && rhs->value == get(Type_ordinal, "number")) return true; + if (lhs->value == get(Type_ordinal, "number") && rhs->value == get(Type_ordinal, "character")) return true; if (lhs->value != rhs->value) return false; return types_match(lhs->left, rhs->left) && types_match(lhs->right, rhs->right); } -- cgit 1.4.1-2-gfad0
path: root/html/309stream.subx.html
blob: e950cd8e97789fe3cfb5453669f080fafc483ef1 (plain) (tree)



























































                                                                                                                                                     


























































































































































                                                                                                                                                                                                                                                                             



                                     
r  Kartik K. Agaram <vc@akkartik.com>  2016-10-19 22:10:35 -0700
committer  Kartik K. Agaram <vc@akkartik.com>  2016-10-19 22:10:35 -0700

3522' href='/akkartik/mu/commit/023boolean.cc?h=main&id=6c96a437cef5140197660a0903309f11c364bf78'>6c96a437 ^
1
2
3
4
5
6
7
8
9