diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-22 13:44:00 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-22 13:44:00 -0700 |
| commit | fead66ab9b39b24e1059b3a55dd09dd1491fee60 (patch) | |
| tree | 3ffd13f0394055b8500d9ed29f46cb696980b5c7 /nomsu_tree.moon | |
| parent | 5435e50f0f0512656bca873b90c0e0fcfb9e38b1 (diff) | |
Added equality metamethod to ASTs.
Diffstat (limited to 'nomsu_tree.moon')
| -rw-r--r-- | nomsu_tree.moon | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/nomsu_tree.moon b/nomsu_tree.moon index 9df240a..885892f 100644 --- a/nomsu_tree.moon +++ b/nomsu_tree.moon @@ -40,6 +40,11 @@ for name in *types replacement = (@__class)(@source, unpack(replacements)) replacement.comments = [c for c in *@comments] if @comments return replacement + .__eq = (other)=> + return false if type(@) != type(other) or #@ != #other or getmetatable(@) != getmetatable(other) + for i=1,#@ + return false if @[i] != other[i] + return true AST[name] = setmetatable cls, __tostring: => @name |
