summaryrefslogtreecommitdiff
path: root/script-beta/vm/getClass.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-01-23 13:31:41 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-01-23 13:31:41 +0800
commit79e528095032330d4fc80585f1873fa0e566a79f (patch)
tree88ca707210878bdc210ff00d641014ea91266df6 /script-beta/vm/getClass.lua
parentdb846579d49e2357967627f78e2269327f88511b (diff)
downloadlua-language-server-79e528095032330d4fc80585f1873fa0e566a79f.zip
eachMeta
Diffstat (limited to 'script-beta/vm/getClass.lua')
-rw-r--r--script-beta/vm/getClass.lua20
1 files changed, 13 insertions, 7 deletions
diff --git a/script-beta/vm/getClass.lua b/script-beta/vm/getClass.lua
index f1a50568..295ffae3 100644
--- a/script-beta/vm/getClass.lua
+++ b/script-beta/vm/getClass.lua
@@ -1,10 +1,9 @@
local vm = require 'vm.vm'
-local function getClass(source, deep)
+local function getClass(source, classes, deep)
if deep > 3 then
- return nil
+ return
end
- local classes = {}
vm.eachField(source, function (src)
local key = vm.getKeyName(src)
local lkey = key:lower()
@@ -17,12 +16,19 @@ local function getClass(source, deep)
end
end
end)
- if #classes == 0 then
- return nil
+ if #classes ~= 0 then
+ return
end
- return vm.mergeTypeViews(table.unpack(classes))
+ vm.eachMeta(source, function (mt)
+ getClass(mt, classes, deep + 1)
+ end)
end
function vm.getClass(source)
- return getClass(source, 1)
+ local classes = {}
+ getClass(source, classes, 1)
+ if #classes == 0 then
+ return nil
+ end
+ return vm.mergeTypeViews(table.unpack(classes))
end