From 70da60a80f2d00c235560f235d3f5ded703dfe4e 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, 21 Dec 2018 16:07:21 +0800 Subject: =?UTF-8?q?=E8=BF=98=E6=98=AF=E8=A6=81=E7=94=A8merge=EF=BC=8C?= =?UTF-8?q?=E5=90=A6=E5=88=99child=E7=9A=84=E5=BC=95=E7=94=A8=E4=BC=9A?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/matcher/vm.lua | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'server') diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 647b99c3..413b9291 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -35,24 +35,6 @@ local function orderTable() }) end -local function deepCopy(t, mark, new) - mark = mark or {} - new = new or orderTable() - for k, v in pairs(t) do - if type(v) == 'table' then - if mark[v] then - new[k] = mark[v] - else - mark[v] = orderTable() - new[k] = deepCopy(v, mark, mark[v]) - end - else - new[k] = v - end - end - return new -end - local mt = {} mt.__index = mt @@ -189,18 +171,6 @@ function mt:buildTable(source) return tbl end -function mt:coverValue(a, b) - if a == b then - return - end - for k in pairs(a) do - a[k] = nil - end - for k, v in pairs(b) do - a[k] = v - end -end - function mt:mergeValue(a, b, mark) if a == b then return @@ -1263,7 +1233,7 @@ function mt:mergeRequire(value, strValue, destVM) else mainValue = main.returns[1] end - self:coverValue(value, mainValue) + self:mergeValue(value, mainValue) -- 支持 require 'xxx' 的转到定义 local strSource = strValue.source @@ -1276,7 +1246,7 @@ function mt:mergeLoadFile(value, strValue, destVM) local main = destVM.results.main -- loadfile 的返回值就是对方的主函数 local mainValue = main - self:coverValue(value, mainValue) + self:mergeValue(value, mainValue) -- 支持 loadfile 'xxx.lua' 的转到定义 local strSource = strValue.source -- cgit v1.2.3