From 8a28e876dd001daec94eb12cf037968f99dc4efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sat, 14 Dec 2019 17:42:31 +0800 Subject: =?UTF-8?q?eachDef=E7=9A=84=E4=B8=80=E4=BA=9B=E6=83=B3=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/parser/guide.lua | 8 ++++---- script-beta/vm/eachDef.lua | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 2592955a..7680168d 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -588,9 +588,9 @@ end ---@return string|boolean mode ---@return table|nil pathA ---@return table|nil pathB -function m.getPath(a, b) +function m.getPath(a, b, sameFunction) --- 首先测试双方在同一个函数内 - if m.getParentFunction(a) ~= m.getParentFunction(b) then + if not sameFunction and m.getParentFunction(a) ~= m.getParentFunction(b) then return false end local mode @@ -612,14 +612,14 @@ function m.getPath(a, b) for _ = 1, 1000 do objA = m.getParentBlock(objA) pathA[#pathA+1] = objA - if objA.type == 'function' or objA.type == 'main' then + if (not sameFunction and objA.type == 'function') or objA.type == 'main' then break end end for _ = 1, 1000 do objB = m.getParentBlock(objB) pathB[#pathB+1] = objB - if objB.type == 'function' or objB.type == 'main' then + if (not sameFunction and objA.type == 'function') or objB.type == 'main' then break end end diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua index 19b0f3bd..cf865384 100644 --- a/script-beta/vm/eachDef.lua +++ b/script-beta/vm/eachDef.lua @@ -27,6 +27,10 @@ local function checkPath(source, info) return true end +-- TODO +-- 只搜索本文件中的引用 +-- 跨文件时,选确定入口(main的return),然后递归搜索本文件中的引用 +-- 如果类型为setfield等,要确定tbl相同 function vm.eachDef(source, callback) local results = {} local returns = {} -- cgit v1.2.3