summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2022-03-11 23:26:01 +0800
committersumneko <sumneko@hotmail.com>2022-03-11 23:26:01 +0800
commit18ef2f600c3f389e6984e2366e8b0c93d30d5792 (patch)
tree14e7139cc38a08e4e100fdf48cd1fd754ae3233c
parent0cd41e39f4439a442ef8d7b55e79549f48591034 (diff)
downloadlua-language-server-18ef2f600c3f389e6984e2366e8b0c93d30d5792.zip
update
-rw-r--r--script/vm/node.lua3
-rw-r--r--script/vm/type.lua34
2 files changed, 33 insertions, 4 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 082a5e87..b8b7917d 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -16,6 +16,9 @@ function m.mergeNode(a, b)
if not b then
return a
end
+ if not a then
+ return b
+ end
if a.type == 'union' then
a:merge(b)
return a
diff --git a/script/vm/type.lua b/script/vm/type.lua
index 5bdc975b..8b80d4f3 100644
--- a/script/vm/type.lua
+++ b/script/vm/type.lua
@@ -78,13 +78,26 @@ function m.getTableValue(tnode, knode)
if tn.type == 'doc.type.table' then
for _, field in ipairs(tn.fields) do
if m.isSubType(field.name, knode) then
- result = nodeMgr.mergeNode(compiler.compileNode(field.extends), result)
+ result = nodeMgr.mergeNode(result, compiler.compileNode(field.extends))
end
end
end
if tn.type == 'doc.type.array' then
if m.isSubType(globalMgr.getGlobal('type', 'integer'), knode) then
- result = nodeMgr.mergeNode(compiler.compileNode(tn.node), result)
+ result = nodeMgr.mergeNode(result, compiler.compileNode(tn.node))
+ end
+ end
+ if tn.type == 'table' then
+ for _, field in ipairs(tn) do
+ if field.type == 'tableindex' then
+ result = nodeMgr.mergeNode(result, compiler.compileNode(field.value))
+ end
+ if field.type == 'tablefield' then
+ result = nodeMgr.mergeNode(result, compiler.compileNode(field.value))
+ end
+ if field.type == 'tableexp' then
+ result = nodeMgr.mergeNode(result, compiler.compileNode(field.value))
+ end
end
end
end
@@ -99,13 +112,26 @@ function m.getTableKey(tnode, vnode)
if tn.type == 'doc.type.table' then
for _, field in ipairs(tn.fields) do
if m.isSubType(field.extends, vnode) then
- result = nodeMgr.mergeNode(compiler.compileNode(field.name), result)
+ result = nodeMgr.mergeNode(result, compiler.compileNode(field.name))
end
end
end
if tn.type == 'doc.type.array' then
if m.isSubType(tn.node, vnode) then
- result = nodeMgr.mergeNode(globalMgr.getGlobal('type', 'integer'), result)
+ result = nodeMgr.mergeNode(result, globalMgr.getGlobal('type', 'integer'))
+ end
+ end
+ if tn.type == 'table' then
+ for _, field in ipairs(tn) do
+ if field.type == 'tableindex' then
+ result = nodeMgr.mergeNode(result, compiler.compileNode(field.index))
+ end
+ if field.type == 'tablefield' then
+ result = nodeMgr.mergeNode(result, globalMgr.getGlobal('type', 'string'))
+ end
+ if field.type == 'tableexp' then
+ result = nodeMgr.mergeNode(result, globalMgr.getGlobal('type', 'integer'))
+ end
end
end
end