diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-14 18:25:41 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-14 18:25:41 +0800 |
commit | eb7363f1c70e62d0f27c675f49b0d28113d4afa4 (patch) | |
tree | 6de7a143ddaa18685a567ec7046db2afa18cf817 /script/vm/runner.lua | |
parent | 2b0fcec7b17c2c01942a277e938f918dc52ff62c (diff) | |
download | lua-language-server-eb7363f1c70e62d0f27c675f49b0d28113d4afa4.zip |
update
Diffstat (limited to 'script/vm/runner.lua')
-rw-r--r-- | script/vm/runner.lua | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/script/vm/runner.lua b/script/vm/runner.lua index 2e301ed3..c0218a44 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -127,21 +127,27 @@ function mt:_lookInto(action, topNode, outNode) self:_launchBlock(action, blockNode:copy()) topNode = mainNode elseif action.type == 'if' then - local mainNode = topNode:copy() - local blockNode = topNode:copy() + local mainNode = topNode:copy() + local blockNodes = {} for _, subBlock in ipairs(action) do - if subBlock.type == 'ifblock' then + local blockNode = mainNode:copy() + if subBlock.filter then blockNode, mainNode = self:_lookInto(subBlock.filter, blockNode, mainNode) self:_fastWard(subBlock.filter.finish, blockNode) - blockNode = self:_launchBlock(subBlock, blockNode:copy()) - local neverReturn = subBlock.hasReturn - or subBlock.hasGoTo - or subBlock.hasBreak - if not neverReturn then - mainNode:merge(blockNode) - end + else + mainNode:clear() + end + blockNode = self:_launchBlock(subBlock, blockNode:copy()) + local neverReturn = subBlock.hasReturn + or subBlock.hasGoTo + or subBlock.hasBreak + if not neverReturn then + blockNodes[#blockNodes+1] = blockNode end end + for _, blockNode in ipairs(blockNodes) do + mainNode:merge(blockNode) + end topNode = mainNode elseif action.type == 'getlocal' then if action.node == self._loc then @@ -184,6 +190,7 @@ function mt:_lookInto(action, topNode, outNode) end end if loc then + self:_fastWard(loc.finish, topNode) if guide.isLiteral(checker) then local checkerNode = vm.compileNode(checker) if action.op.type == '==' then |