summaryrefslogtreecommitdiff
path: root/server/src/matcher
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/matcher')
-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