summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/vm/function.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua
index ed5c1306..24990448 100644
--- a/server/src/vm/function.lua
+++ b/server/src/vm/function.lua
@@ -1,6 +1,7 @@
local createDots = require 'vm.dots'
local createMulti = require 'vm.multi'
local createValue = require 'vm.value'
+local createLocal = require 'vm.local'
local mt = {}
mt.__index = mt
@@ -130,6 +131,11 @@ function mt:run()
return
end
+ -- 第一次运行函数时,创建函数的参数
+ if self._runed == 1 then
+ self:createArgs()
+ end
+
--local index = 0
--if func.object then
-- local var = self:createArg('self', func.colon, self:getValue--(func.object, func.colon))
@@ -178,6 +184,31 @@ function mt:setArgs(values)
end
end
+function mt:createArg(arg)
+ if arg.type == 'name' then
+ local loc = createLocal(arg[1], arg, createValue('any', arg))
+ self:saveLocal(arg[1], loc)
+ elseif arg.type == '...' then
+ end
+end
+
+function mt:createArgs()
+ if not self.source then
+ return
+ end
+ local args = self.source.arg
+ if not args then
+ return
+ end
+ if args.type == 'list' then
+ for _, arg in ipairs(args) do
+ self:createArg(arg)
+ end
+ else
+ self:createArg(args)
+ end
+end
+
return function (source)
local self = setmetatable({
source = source,