summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-23 23:36:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-23 23:36:30 +0800
commit0652fa586d62408e28d8f7d253aa96381d357bc8 (patch)
treeaa2f37d508318e976f2ee17aef919883321cdf12 /script/vm
parent3f815c836beb054a13f8d250f6f05a54778b72ba (diff)
downloadlua-language-server-0652fa586d62408e28d8f7d253aa96381d357bc8.zip
infer by `if not x then return end`
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/runner.lua35
1 files changed, 22 insertions, 13 deletions
diff --git a/script/vm/runner.lua b/script/vm/runner.lua
index 9384ec01..5c92dcbe 100644
--- a/script/vm/runner.lua
+++ b/script/vm/runner.lua
@@ -180,19 +180,28 @@ function mt:_compileBlock(block)
order = 3,
}
self:_compileNarrowByFilter(childBlock.filter, childBlock[1].start - 1)
- local finalState = {
- type = 'save',
- pos = childBlock.finish,
- order = 1,
- }
- finals[#finals+1] = finalState
- self.steps[#self.steps+1] = finalState
- self.steps[#self.steps+1] = {
- type = 'load',
- ref1 = outState,
- pos = childBlock.finish,
- order = 2,
- }
+ if childBlock.returns then
+ self.steps[#self.steps+1] = {
+ type = 'load',
+ ref1 = outState,
+ pos = childBlock.finish,
+ order = 1,
+ }
+ else
+ local finalState = {
+ type = 'save',
+ pos = childBlock.finish,
+ order = 1,
+ }
+ finals[#finals+1] = finalState
+ self.steps[#self.steps+1] = finalState
+ self.steps[#self.steps+1] = {
+ type = 'load',
+ ref1 = outState,
+ pos = childBlock.finish,
+ order = 2,
+ }
+ end
end
end
for i, final in ipairs(finals) do