From 5c7f8776c839bc6898953affb0d94ec99e435cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 29 Oct 2019 15:05:01 +0800 Subject: =?UTF-8?q?setmetatable=20=E5=8F=82=E6=95=B01=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20=5F=5Findex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/searcher/eachField.lua | 59 +++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 23 deletions(-) (limited to 'server-beta/src/searcher/eachField.lua') diff --git a/server-beta/src/searcher/eachField.lua b/server-beta/src/searcher/eachField.lua index 98f7fd69..3db2375f 100644 --- a/server-beta/src/searcher/eachField.lua +++ b/server-beta/src/searcher/eachField.lua @@ -46,6 +46,41 @@ local function ofENV(searcher, source, callback) end end +local function ofSpecialArg(searcher, source, callback) + local args = source.parent + local call = args.parent + local func = call.node + local name = searcher:getSpecialName(func) + if name == 'rawset' then + if args[1] == source and args[2] then + callback { + searcher = searcher, + source = call, + key = guide.getKeyName(args[2]), + value = args[3], + mode = 'set', + } + end + elseif name == 'rawget' then + if args[1] == source and args[2] then + callback { + searcher = searcher, + source = call, + key = guide.getKeyName(args[2]), + mode = 'get', + } + end + elseif name == 'setmetatable' then + if args[1] == source and args[2] then + searcher:eachField(args[2], function (info) + if info.key == 's|__index' and info.value then + info.searcher:eachField(info.value, callback) + end + end) + end + end +end + local function ofVar(searcher, source, callback) local parent = source.parent if not parent then @@ -75,29 +110,7 @@ local function ofVar(searcher, source, callback) return end if parent.type == 'callargs' then - local call = parent.parent - local func = call.node - local name = searcher:getSpecialName(func) - if name == 'rawset' then - if parent[1] == source then - callback { - searcher = searcher, - source = call, - key = guide.getKeyName(parent[2]), - value = parent[3], - mode = 'set', - } - end - elseif name == 'rawget' then - if parent[1] == source then - callback { - searcher = searcher, - source = call, - key = guide.getKeyName(parent[2]), - mode = 'get', - } - end - end + ofSpecialArg(searcher, source, callback) end end -- cgit v1.2.3