about summary refs log tree commit diff stats
path: root/010vm.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-15 00:37:29 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-15 00:37:29 -0800
commitef96f57ce264c8e0bd98f6e8622d1c1e2eceafb2 (patch)
treef2113d385fde9c4b9579521402eab5ec9c1f208d /010vm.cc
parent7ecb3374340c02cc2c54abf4a5d4a617f362b4c4 (diff)
downloadmu-ef96f57ce264c8e0bd98f6e8622d1c1e2eceafb2.tar.gz
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.
Diffstat (limited to '010vm.cc')
-rw-r--r--010vm.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/010vm.cc b/010vm.cc
index 92721d32..0b2888f0 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -484,6 +484,16 @@ bool deeply_equal(const string_tree* a, const string_tree* b) {
       && deeply_equal(a->right, b->right);
 }
 
+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;
+  return a->value == b->value
+      && deeply_equal_types(a->left, b->left)
+      && deeply_equal_types(a->right, b->right);
+}
+
 void dump_memory() {
   for (map<long long int, double>::iterator p = Memory.begin(); p != Memory.end(); ++p) {
     cout << p->first << ": " << no_scientific(p->second) << '\n';