about summary refs log tree commit diff stats
path: root/021check_instruction.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-11 16:13:10 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-11 17:29:50 -0800
commit5d67fac7966b6f05611d014420eb4971b8016c31 (patch)
tree4ad84631596f09a994a2154b77e80118e7189b37 /021check_instruction.cc
parente4b03c6f574ade8c3fe4df18b958da981ac58acb (diff)
downloadmu-5d67fac7966b6f05611d014420eb4971b8016c31.tar.gz
2646 - redo static dispatch algorithm
The old approach of ad hoc boosts and penalties based on various
features was repeatedly running into exceptions and bugs. New
organization: multiple tiered scores interleaved with tie-breaks. The
moment one tier yields one or more candidates, we stop scanning further
tiers. Just break ties and return.
Diffstat (limited to '021check_instruction.cc')
-rw-r--r--021check_instruction.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc
index de5d8394..cf0a8d74 100644
--- a/021check_instruction.cc
+++ b/021check_instruction.cc
@@ -117,6 +117,15 @@ bool types_match(const reagent& to, const reagent& from) {
   return types_strictly_match(to, from);
 }
 
+bool types_strictly_match_except_literal_against_boolean(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_literal(from)
+      && to.type && to.type->value == get(Type_ordinal, "boolean"))
+    return boolean_matches_literal(to, from);
+  return types_strictly_match(to, from);
+}
+
 bool boolean_matches_literal(const reagent& to, const reagent& from) {
   if (!is_literal(from)) return false;
   if (!to.type) return false;