summaryrefslogtreecommitdiff
path: root/script/vm/runner.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-15 16:29:20 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-15 16:29:20 +0800
commite88c7d0e1a0ce37b9377f86b37d6ed963fd935b0 (patch)
tree4fae828ed6652ec5e6d84e67e9d198e8333f6433 /script/vm/runner.lua
parent96b4e0ba089c717aa5455a7f6fcf6caee863a74e (diff)
downloadlua-language-server-e88c7d0e1a0ce37b9377f86b37d6ed963fd935b0.zip
resolve #1154 resolve #1165
infer type by `t and t.x`
Diffstat (limited to 'script/vm/runner.lua')
-rw-r--r--script/vm/runner.lua21
1 files changed, 17 insertions, 4 deletions
diff --git a/script/vm/runner.lua b/script/vm/runner.lua
index 5d561677..05dcbb7a 100644
--- a/script/vm/runner.lua
+++ b/script/vm/runner.lua
@@ -8,6 +8,7 @@ local guide = require 'parser.guide'
---@field _loc parser.object
---@field _objs parser.object[]
---@field _callback vm.runner.callback
+---@field _mark table
local mt = {}
mt.__index = mt
mt._index = 1
@@ -117,6 +118,17 @@ function mt:_lookInto(action, topNode, outNode)
if not action then
return topNode, outNode
end
+ if self._mark[action] then
+ return
+ end
+ self._mark[action] = true
+ local top = self._objs[self._index]
+ if not top then
+ return topNode, outNode
+ end
+ if not guide.isInRange(action, top.finish) then
+ return topNode, outNode
+ end
local set
local value = vm.getObjectValue(action)
if value then
@@ -232,10 +244,10 @@ function mt:_lookInto(action, topNode, outNode)
self:_lookInto(arg, topNode)
end
end
- elseif action.type == 'return' then
- for _, rtn in ipairs(action) do
- self:_lookInto(rtn, topNode)
- end
+ else
+ guide.eachSourceContain(action, top.finish, function(source)
+ self:_lookInto(source, topNode)
+ end)
end
::RETURN::
topNode = self:_fastWard(action.finish, topNode)
@@ -275,6 +287,7 @@ function vm.launchRunner(loc, callback)
local self = setmetatable({
_loc = loc,
_objs = {},
+ _mark = {},
_callback = callback,
}, mt)