summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-12 16:33:12 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-12 16:33:12 +0800
commit3b48f52ca21700f928e3e463736e280f46b2a2c7 (patch)
tree9d4bf9d3fc2982e2abe74027b6d6b3ebd257101c /server/src
parent8739fbf5197f28331713ffb264b7d77112272774 (diff)
downloadlua-language-server-3b48f52ca21700f928e3e463736e280f46b2a2c7.zip
改进函数参数
Diffstat (limited to 'server/src')
-rw-r--r--server/src/matcher/vm.lua38
1 files changed, 20 insertions, 18 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 2c89b5e7..1079816a 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -273,35 +273,42 @@ function mt:forList(list, callback)
end
end
-function mt:setFunctionArgs(func, values)
+function mt:updateFunctionArgs(func)
+ if not func.argValues then
+ return
+ end
if not func.args then
return
end
+ local values = func.argValues
for i, var in ipairs(func.args) do
if var.type == 'dots' then
local list = {
type = 'list',
}
- if values then
- for n = i, #values do
- list[n-i+1] = values[n]
- end
- self:setValue(var, list)
- else
- self:setValue(var, nil)
+ for n = i, #values do
+ list[n-i+1] = values[n]
end
+ self:setValue(var, list)
break
else
- if values then
- self:setValue(var, values[i])
- else
- self:setValue(var, nil)
- end
+ self:setValue(var, values[i])
end
end
end
+function mt:setFunctionArgs(func, values)
+ if not func.argValues then
+ func.argValues = {}
+ end
+ for i = 1, #values do
+ func.argValues[i] = values[i]
+ end
+
+ self:updateFunctionArgs(func)
+end
+
function mt:checkMetaIndex(value, meta)
local index = self:getField(meta, '__index')
if not index then
@@ -430,15 +437,10 @@ function mt:getLibValue(lib, parentType, v)
end
end
if lib.args then
- value.args = {}
local values = {}
- self.scope:push()
for i, arg in ipairs(lib.args) do
- value.args[#value.args+1] = self:createLocal(arg.name)
-
values[i] = self:getLibValue(arg, parentType) or self:createValue('nil')
end
- self.scope:pop()
self:setFunctionArgs(value, values)
end
elseif tp == 'string' then