From f49a70c5a28ef163ffaf8fdc17dd0dbe3816c4e2 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, 10 Dec 2019 21:55:52 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=AD=A3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/vm/eachDef.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'script-beta/vm/eachDef.lua') diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua index 54460942..d1cba2ae 100644 --- a/script-beta/vm/eachDef.lua +++ b/script-beta/vm/eachDef.lua @@ -20,6 +20,7 @@ end function vm.eachDef(source, callback) local results = {} local valueUris = {} + local valueInfos = {} local sourceUri = guide.getRoot(source).uri vm.eachRef(source, function (info) if info.mode == 'declare' @@ -28,6 +29,7 @@ function vm.eachDef(source, callback) or info.mode == 'value' or info.mode == 'library' then results[#results+1] = info + valueInfos[info.source] = info local src = info.source if info.mode == 'return' then local uri = guide.getRoot(src).uri @@ -37,9 +39,15 @@ function vm.eachDef(source, callback) end) local res + local used = {} for _, info in ipairs(results) do local src = info.source - local destUri = guide.getRoot(src).uri + local destUri + if used[src] then + goto CONTINUE + end + used[src] = true + destUri = guide.getRoot(src).uri -- 如果是library,则直接放行 if src.library then res = callback(info) @@ -53,6 +61,10 @@ function vm.eachDef(source, callback) or src.type == 'tableindex' or src.type == 'setglobal' then res = callback(info) + if src.value and valueInfos[src.value] then + used[src.value] = true + res = callback(valueInfos[src.value]) + end goto CONTINUE end -- 如果是同一个文件,则检查位置关系后放行 -- cgit v1.2.3