summaryrefslogtreecommitdiff
path: root/server-beta/src
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src')
-rw-r--r--server-beta/src/core/definition.lua3
-rw-r--r--server-beta/src/parser/compile.lua15
-rw-r--r--server-beta/src/searcher/eachRef.lua13
3 files changed, 28 insertions, 3 deletions
diff --git a/server-beta/src/core/definition.lua b/server-beta/src/core/definition.lua
index 305bb868..8a808e23 100644
--- a/server-beta/src/core/definition.lua
+++ b/server-beta/src/core/definition.lua
@@ -5,7 +5,8 @@ local files = require 'files'
local function findDef(searcher, source, callback)
searcher:eachRef(source, function (info)
if info.mode == 'declare'
- or info.mode == 'set' then
+ or info.mode == 'set'
+ or info.mode == 'return' then
local src = info.source
local uri = info.uri
if src.type == 'setfield'
diff --git a/server-beta/src/parser/compile.lua b/server-beta/src/parser/compile.lua
index 2bcb7e46..51803753 100644
--- a/server-beta/src/parser/compile.lua
+++ b/server-beta/src/parser/compile.lua
@@ -194,6 +194,13 @@ local vmMap = {
finish = obj.finish,
}
end
+ local func = guide.getParentFunction(obj)
+ if func then
+ if not func.returns then
+ func.returns = {}
+ end
+ func.returns[#func.returns+1] = obj
+ end
end,
['label'] = function (obj)
local block = guide.getBlock(obj)
@@ -281,7 +288,13 @@ local vmMap = {
Block = lastBlock
end,
['break'] = function (obj)
- if not guide.getBreakBlock(obj) then
+ local block = guide.getBreakBlock(obj)
+ if block then
+ if not block.breaks then
+ block.breaks = {}
+ end
+ block.breaks[#block.breaks+1] = obj
+ else
pushError {
type = 'BREAK_OUTSIDE',
start = obj.start,
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua
index 93a05079..ab3de029 100644
--- a/server-beta/src/searcher/eachRef.lua
+++ b/server-beta/src/searcher/eachRef.lua
@@ -4,8 +4,19 @@ local function ofCall(searcher, func, index, callback)
searcher:eachRef(func, function (info)
local src = info.source
local funcDef = src.value
- if funcDef and funcDef.type == 'function' then
+ if funcDef and funcDef.returns then
-- 搜索函数第 index 个返回值
+ for _, rtn in ipairs(funcDef.returns) do
+ local val = rtn[index]
+ if val then
+ callback {
+ searcher = info.searcher,
+ source = val,
+ mode = 'return',
+ }
+ info.searcher:eachRef(val, callback)
+ end
+ end
end
end)
end