diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-27 22:23:54 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-27 22:23:54 -0800 |
commit | c561f6a91926cb3c9c22f483b94ca40a01e6a9c0 (patch) | |
tree | 25382bf6e061f5b643ca297683ee5b11384dc089 /010vm.cc | |
parent | dfdbcbab4299bbb4fc2725abf7fa26ac592e296e (diff) | |
download | mu-c561f6a91926cb3c9c22f483b94ca40a01e6a9c0.tar.gz |
2487
Ok, now I'm a little happier about our type checking. Type checking lies in three layers: layer 21: checking types, usually at run-time in the VM or just before layer 57: checking type names layer 59: checking type names It's taken me the process of writing this commit to convince myself that all three layers check mappings for literal values in a consistent manner. Layer 21 uses sizes, and layers 57/59 have whitelists, but either way the goal is that number != character != boolean unless mediated through a literal.
Diffstat (limited to '010vm.cc')
-rw-r--r-- | 010vm.cc | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/010vm.cc b/010vm.cc index 52e66f15..ab003c73 100644 --- a/010vm.cc +++ b/010vm.cc @@ -476,34 +476,6 @@ string_tree* property(const reagent& r, const string& name) { return NULL; } -bool deeply_equal(const string_tree* a, const string_tree* b) { - if (!a) return !b; - if (!b) return !a; - return a->value == b->value - && deeply_equal(a->left, b->left) - && deeply_equal(a->right, b->right); -} - -:(before "End Globals") -set<string> Literal_type_names; -:(before "End One-time Setup") -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 == "literal" && b->value == "literal") - return true; - if (a->value == "literal") - return Literal_type_names.find(b->value) != Literal_type_names.end(); - if (b->value == "literal") - return Literal_type_names.find(a->value) != Literal_type_names.end(); - 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'; |