diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-28 21:06:53 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-28 21:06:53 +0800 |
commit | 08b9dd387a9b912c68749018b7dfe3c1df7094d5 (patch) | |
tree | 46c81598c214b10643f3d8083bb7b64b9e2ba21c /script/vm/runner.lua | |
parent | 9ad317f2a1eb8dc5715103c8c62e0fcff88a482b (diff) | |
download | lua-language-server-08b9dd387a9b912c68749018b7dfe3c1df7094d5.zip |
cleanup
Diffstat (limited to 'script/vm/runner.lua')
-rw-r--r-- | script/vm/runner.lua | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/script/vm/runner.lua b/script/vm/runner.lua index fcd0f681..9f9a53a2 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -117,20 +117,20 @@ end ---@return vm.node outNode function mt:_lookInto(action, topNode, outNode) if not action then - return topNode, outNode + return topNode, outNode or topNode end if self._mark[action] then - return topNode, outNode + return topNode, outNode or topNode end self._mark[action] = true local top = self._objs[self._index] if not top then - return topNode, outNode + return topNode, outNode or topNode end if not guide.isInRange(action, top.finish) -- trick for `local tp = type(x);if tp == 'string' then` and action.type ~= 'binary' then - return topNode, outNode + return topNode, outNode or topNode end local set local value = vm.getObjectValue(action) @@ -151,7 +151,9 @@ function mt:_lookInto(action, topNode, outNode) self:_fastWard(action.filter.finish, blockNode) end blockNode = self:_launchBlock(action, blockNode:copy()) - topNode = mainNode:merge(blockNode) + if mainNode then + topNode = mainNode:merge(blockNode) + end elseif action.type == 'if' then local hasElse local mainNode = topNode:copy() @@ -314,7 +316,7 @@ function mt:_lookInto(action, topNode, outNode) if set then topNode = self:_fastWard(set.range or set.finish, topNode) end - return topNode, outNode + return topNode, outNode or topNode end ---@param block parser.object @@ -356,7 +358,10 @@ function vm.launchRunner(loc, callback) if #self._objs == 0 then return end - - local topNode = self:_launchBlock(guide.getParentBlock(loc), vm.getNode(loc):copy()) + local main = guide.getParentBlock(loc) + if not main then + return + end + local topNode = self:_launchBlock(main, vm.getNode(loc):copy()) self:_fastWard(math.maxinteger, topNode) end |