diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-13 23:29:19 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-13 23:29:19 +0800 |
commit | a02828b3c1d3582d73e44f36bc34e8d86f9b0295 (patch) | |
tree | 9f4a7e634f76374b59ed599653e1dc9f69e5d39c /script/vm/runner.lua | |
parent | 32fbab2b26bdb6b4c00ed8f467f12e5161ba4c31 (diff) | |
download | lua-language-server-a02828b3c1d3582d73e44f36bc34e8d86f9b0295.zip |
update runner
Diffstat (limited to 'script/vm/runner.lua')
-rw-r--r-- | script/vm/runner.lua | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/script/vm/runner.lua b/script/vm/runner.lua index 38b0b66c..87630512 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -72,15 +72,28 @@ function mt:_fastWard(pos, node) self._index = i return obj, node end - if obj.type == 'getlocal' - or obj.type == 'setlocal' then - node = self._callback(obj, node) or node + if obj.type == 'getlocal' then + self._callback(obj, node) + elseif obj.type == 'setlocal' then + local newNode = self._callback(obj, node) + if newNode then + node = newNode:copy() + end else error('unexpected type: ' .. obj.type) end end end +---@param action parser.object +---@param topNode vm.node +function mt:_lookInto(action, topNode) + action = vm.getObjectValue(action) or action + if action.type == 'function' then + self:_launchBlock(action, topNode:copy()) + end +end + ---@param block parser.object ---@param node vm.node function mt:_launchBlock(block, node) @@ -89,16 +102,18 @@ function mt:_launchBlock(block, node) return end for _, action in ipairs(block) do - if action.finish < top.start then + local finish = action.range or action.finish + if finish < top.start then goto CONTINUE end + self:_lookInto(action, topNode) top, topNode = self:_fastWard(action.finish, topNode) if not top then return end ::CONTINUE:: end - self:_fastWard(math.huge, topNode) + self:_fastWard(block.finish, topNode) end ---@param loc parser.object @@ -116,5 +131,5 @@ function vm.launchRunner(loc, callback) return end - self:_launchBlock(guide.getParentBlock(loc), vm.getNode(loc)) + self:_launchBlock(guide.getParentBlock(loc), vm.getNode(loc):copy()) end |