diff options
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/emmy.lua | 7 | ||||
-rw-r--r-- | server/src/vm/function.lua | 10 | ||||
-rw-r--r-- | server/src/vm/manager.lua | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/server/src/vm/emmy.lua b/server/src/vm/emmy.lua index 4c611d59..34312831 100644 --- a/server/src/vm/emmy.lua +++ b/server/src/vm/emmy.lua @@ -44,6 +44,13 @@ function mt:addEmmyParam(param) self._emmyParams[#self._emmyParams+1] = param end +function mt:addEmmyReturn(rtn) + if not self._emmyReturns then + self._emmyReturns = {} + end + self._emmyReturns[#self._emmyReturns+1] = rtn +end + function mt:getEmmyParams() local params = self._emmyParams self._emmyParams = nil diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua index 3fb3db69..4c2f0be5 100644 --- a/server/src/vm/function.lua +++ b/server/src/vm/function.lua @@ -227,6 +227,7 @@ function mt:needSkip() return self._runed > 3 end +---@param vm VM function mt:run(vm) if self._removed then return @@ -265,6 +266,15 @@ function mt:run(vm) self._dots:push(self.argValues[i]) end end + + -- 填充返回值 + if self._emmyReturns then + for i, rtn in ipairs(self._emmyReturns) do + local value = vm:createValue('nil', rtn:getSource()) + value:setEmmy(rtn:bindType()) + self:setReturn(i, value) + end + end end function mt:setArgs(values) diff --git a/server/src/vm/manager.lua b/server/src/vm/manager.lua index 2016465b..5f6a9b6a 100644 --- a/server/src/vm/manager.lua +++ b/server/src/vm/manager.lua @@ -1,3 +1,4 @@ +---@class VM local mt = {} mt.__index = mt mt.type = 'vm' |