aboutsummaryrefslogtreecommitdiff
path: root/utils.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2017-10-13 18:09:04 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2017-10-13 18:09:04 -0700
commite476bfea5261b04e32cd444208bbffa34bc6f475 (patch)
tree1e298777e70f50e9fb7625b45395d8c5c4c91e38 /utils.lua
parentd13bcde2b9306e0c87b055faed88da76bd3ff41e (diff)
Improved code generation for "when" statements using elseif, and
improved code generation for loops by omitting goto labels when not used.
Diffstat (limited to 'utils.lua')
-rw-r--r--utils.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/utils.lua b/utils.lua
index e8fca96..19ba20a 100644
--- a/utils.lua
+++ b/utils.lua
@@ -290,7 +290,10 @@ utils = {
end
return table.sort(list, comparison)
end,
- equivalent = function(x, y)
+ equivalent = function(x, y, depth)
+ if depth == nil then
+ depth = 1
+ end
if x == y then
return true
end
@@ -300,13 +303,16 @@ utils = {
if type(x) ~= 'table' then
return false
end
+ if depth == 0 then
+ return false
+ end
for k, v in pairs(x) do
- if y[k] ~= v then
+ if not (utils.equivalent(y[k], v, depth - 1)) then
return false
end
end
for k, v in pairs(y) do
- if x[k] ~= v then
+ if not (utils.equivalent(x[k], v, depth - 1)) then
return false
end
end