summaryrefslogtreecommitdiff
path: root/script/vm/compiler.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-06 05:10:17 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-06 05:10:17 +0800
commit989ffe2a809998605750d5400a9455e0b8d279c0 (patch)
tree991370b3e99a52529cff009bb0a7911d2432c2e7 /script/vm/compiler.lua
parentc4c0009ef28de6cd4bfe01c497cbb718f3c2dff8 (diff)
downloadlua-language-server-989ffe2a809998605750d5400a9455e0b8d279c0.zip
update
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r--script/vm/compiler.lua25
1 files changed, 15 insertions, 10 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index d5d65dfb..7c5eb721 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -483,7 +483,7 @@ local function isValidCallArgNode(source, node)
return node.type == 'doc.type.table'
or (node.type == 'global' and node.cate == 'type' and not guide.isBasicType(node.name))
end
- if source.type == 'dummy' then
+ if source.type == 'dummyarg' then
return true
end
return false
@@ -501,7 +501,7 @@ local function getFuncArg(func, index)
return args[index]
end
local lastArg = args[#args]
- if lastArg.type == '...' then
+ if lastArg and lastArg.type == '...' then
return lastArg
end
return nil
@@ -519,12 +519,14 @@ local function compileCallArgNode(arg, call, callNode, fixIndex, myIndex)
end
local eventIndex, eventMap
- for i = 1, 2 do
- local eventArg = call.args[i + fixIndex]
- eventMap = valueMgr.getLiterals(eventArg)
- if eventMap then
- eventIndex = i
- break
+ if call.args then
+ for i = 1, 2 do
+ local eventArg = call.args[i + fixIndex]
+ eventMap = valueMgr.getLiterals(eventArg)
+ if eventMap then
+ eventIndex = i
+ break
+ end
end
end
@@ -564,6 +566,7 @@ function m.compileCallArg(arg, call, index)
callNode = m.compileNode(call.args[1])
compileCallArgNode(arg, call, callNode, fixIndex, index)
end
+ return nodeMgr.getNode(arg)
end
local compilerSwitch = util.switch()
@@ -702,7 +705,8 @@ local compilerSwitch = util.switch()
: case 'setindex'
: call(function (source)
compileByLocalID(source)
- m.compileByParentNode(source.node, guide.getKeyName(source), function (src)
+ local key = guide.getKeyName(source)
+ m.compileByParentNode(source.node, key, function (src)
if src.type == 'doc.type.field' then
nodeMgr.setNode(source, m.compileNode(src))
end
@@ -713,7 +717,8 @@ local compilerSwitch = util.switch()
: case 'getindex'
: call(function (source)
compileByLocalID(source)
- m.compileByParentNode(source.node, guide.getKeyName(source), function (src)
+ local key = guide.getKeyName(source)
+ m.compileByParentNode(source.node, key, function (src)
nodeMgr.setNode(source, m.compileNode(src))
end)
end)