From 7bf48ded2644c706bd91e20420fe94bba05d2b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 14 Jun 2022 20:54:24 +0800 Subject: update runner --- script/vm/runner.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'script/vm/runner.lua') diff --git a/script/vm/runner.lua b/script/vm/runner.lua index 0ec26bef..a9c38a87 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -132,6 +132,7 @@ function mt:_lookInto(action, topNode, outNode) self:_launchBlock(action, blockNode:copy()) topNode = mainNode elseif action.type == 'if' then + local hasElse local mainNode = topNode:copy() local blockNodes = {} for _, subBlock in ipairs(action) do @@ -140,6 +141,7 @@ function mt:_lookInto(action, topNode, outNode) blockNode, mainNode = self:_lookInto(subBlock.filter, blockNode, mainNode) self:_fastWard(subBlock.filter.finish, blockNode) else + hasElse = true mainNode:clear() end blockNode = self:_launchBlock(subBlock, blockNode:copy()) @@ -150,6 +152,9 @@ function mt:_lookInto(action, topNode, outNode) blockNodes[#blockNodes+1] = blockNode end end + if not hasElse and not topNode:hasKnownType() then + mainNode:merge(vm.declareGlobal('type', 'unknown')) + end for _, blockNode in ipairs(blockNodes) do mainNode:merge(blockNode) end -- cgit v1.2.3