From 43a8d3587622c9fe55996ca22fb13c7d3897a600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 9 Oct 2019 17:47:21 +0800 Subject: =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/core/engineer.lua | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'server-beta/src') diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index 192de506..9fc771b2 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -72,7 +72,7 @@ mt['local'] = function (self, source, mode, callback) self:eachRef(node, 'field', callback) end if source.value then - self:eachRef(source.value, 'field', callback) + self:eachField(source.value, nil, 'ref', callback) end end end @@ -196,25 +196,19 @@ mt['table'] = function (self, source, mode, callback) end end end -mt['select'] = function (self, source, mode, callback) - local vararg = source.vararg - if vararg.type == 'call' then - local func = vararg.node - self:specialreturn(func, source.index, mode, callback) - end -end - -function mt:specialreturn(source, index, mode, callback) +mt['call'] = function (self, source, mode, callback) local name = self:getSpecial(source) if not name then return end - local call = source.parent + local parent = source.parent if name == 's|setmetatable' then - if index ~= 1 then + if parent.index ~= 1 then return end - self:eachField(call.args[2], 's|__index', 'def', callback) + self:eachField(source.args[2], 's|__index', 'def', function (src) + self:eachField(src, nil, 'ref', callback) + end) return end end @@ -251,7 +245,7 @@ end function mt:eachField(node, key, mode, callback) self:eachRef(node, 'field', function (src) - if key == guide.getKeyName(src) then + if not key or key == guide.getKeyName(src) then if mode == 'def' then if src.type == 'setfield' or src.type == 'tablefield' then @@ -262,6 +256,22 @@ function mt:eachField(node, key, mode, callback) elseif src.type == 'setmethod' then callback(src.method, 'set') end + elseif mode == 'ref' then + if src.type == 'setfield' + or src.type == 'tablefield' then + callback(src.field, 'set') + elseif src.type == 'setindex' + or src.type == 'tableindex' then + callback(src.index, 'set') + elseif src.type == 'setmethod' then + callback(src.method, 'set') + elseif src.type == 'getfield' then + callback(src.field, 'get') + elseif src.type == 'getindex' then + callback(src.index, 'get') + elseif src.type == 'getmethod' then + callback(src.method, 'get') + end end end end) -- cgit v1.2.3