From f2444b757331ddf8df16a39a86b0ce8608338d77 Mon Sep 17 00:00:00 2001 From: sumneko Date: Mon, 29 Apr 2019 19:45:38 +0800 Subject: emmy.generic --- server/src/vm/function.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'server/src/vm/function.lua') diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua index 4c2f0be5..5c9019aa 100644 --- a/server/src/vm/function.lua +++ b/server/src/vm/function.lua @@ -259,6 +259,13 @@ function mt:run(vm) -- 向局部变量中填充参数 for i, loc in ipairs(self.args) do loc:setValue(self.argValues[i]) + local emmyParam = self:findEmmyParamByName(loc:getName()) + if emmyParam then + local genericObj = emmyParam:bindGeneric() + if genericObj then + genericObj:setValue(loc:getValue()) + end + end end if self._dots then self._dots = createMulti() @@ -271,7 +278,17 @@ function mt:run(vm) if self._emmyReturns then for i, rtn in ipairs(self._emmyReturns) do local value = vm:createValue('nil', rtn:getSource()) - value:setEmmy(rtn:bindType()) + local typeObj = rtn:bindType() + if typeObj then + value:setEmmy(typeObj) + end + local genericObj = rtn:bindGeneric() + if genericObj then + local destValue = genericObj:getValue() + if destValue then + value:mergeType(destValue) + end + end self:setReturn(i, value) end end @@ -307,7 +324,10 @@ function mt:createArg(vm, arg) local emmyParam = self:findEmmyParamByName(arg[1]) local value = valueMgr.create('nil', arg) if emmyParam then - value:setEmmy(emmyParam:bindType()) + local typeObj = emmyParam:bindType() + if typeObj then + value:setEmmy(typeObj) + end end local loc = localMgr.create(arg[1], arg, value) self:saveUpvalue(arg[1], loc) -- cgit v1.2.3