From 8860d1a77c820e017ee82d6ba9ce2ff2b8d90e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 14 Dec 2018 16:46:50 +0800 Subject: =?UTF-8?q?=E6=95=B4=E7=90=86=E4=B8=80=E4=B8=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/matcher/vm.lua | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'server') diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index d3f5da70..df722501 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -102,13 +102,7 @@ function mt:buildTable(source) end end else - local value - if obj.type == '...' then - value = { type = 'list' } - self:unpackDots(value, 1) - else - value = self:getExp(obj) - end + local value = self:getExp(obj) if value.type == 'list' then if index == #source then for i, v in ipairs(value) do @@ -852,6 +846,10 @@ function mt:getExp(exp) return self:buildFunction(exp) elseif tp == 'table' then return self:buildTable(exp) + elseif tp == '...' then + local value = { type = 'list' } + self:unpackDots(value) + return value end error('Unkown exp type: ' .. tostring(tp)) end @@ -864,15 +862,13 @@ end function mt:doReturn(action) for i, exp in ipairs(action) do - if exp.type == '...' then - local values = {} - self:unpackDots(values) - for x, v in ipairs(values) do + local value = self:getExp(exp) + if value.type == 'list' then + for x, v in ipairs(value) do self:setFunctionReturn(self:getCurrentFunction(), i + x - 1, v) end break else - local value = self:getExp(exp) self:setFunctionReturn(self:getCurrentFunction(), i, value) end end -- cgit v1.2.3