From b63286f959f6a07c8901b0e3f0e03e81a935ac4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 31 Oct 2019 19:24:43 +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/searcher/eachRef.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'server-beta') diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua index b490f0a2..2d9d64b6 100644 --- a/server-beta/src/searcher/eachRef.lua +++ b/server-beta/src/searcher/eachRef.lua @@ -69,6 +69,35 @@ local function ofSelf(searcher, loc, callback) -- 2. 调用该方法时传入的对象 end +--- 自己作为赋值的值 +local function asValue(searcher, source, callback) + local parent = source.parent + if parent and parent.value == source then + if guide.getKeyName(parent) == 's|__index' then + if parent.type == 'tablefield' + or parent.type == 'tableindex' then + local t = parent.parent + local args = t.parent + if args[2] == t then + local call = args.parent + local func = call.node + if searcher:getSpecialName(func) == 'setmetatable' then + searcher:eachRef(args[1], callback) + end + end + end + end + end +end + +--- 自己作为函数的参数 +local function asArg(searcher, source, callback) + local parent = source.parent + if parent == 'callargs' then + print(parent) + end +end + local function ofLocal(searcher, loc, callback) -- 方法中的 self 使用了一个虚拟的定义位置 if loc.tag ~= 'self' then @@ -86,6 +115,7 @@ local function ofLocal(searcher, loc, callback) source = ref, mode = 'get', } + asValue(searcher, ref, callback) elseif ref.type == 'setlocal' then callback { searcher = searcher, @@ -224,4 +254,5 @@ return function (searcher, source, callback) source = source, } end + asArg(searcher, source, callback) end -- cgit v1.2.3