summaryrefslogtreecommitdiff
path: root/script/vm/compiler.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-11-18 11:56:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-11-18 11:56:22 +0800
commite13503e871ade8422e5a44d5c582f05769fe8dde (patch)
tree065b82b7398123f23f6d78972683efa347687a6c /script/vm/compiler.lua
parent8d383d5d34ce25faa32f421560632de21239bed5 (diff)
downloadlua-language-server-e13503e871ade8422e5a44d5c582f05769fe8dde.zip
resolve recursive runner
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r--script/vm/compiler.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 6dbe41fe..ef0f7157 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -567,6 +567,7 @@ local function matchCall(source)
local newNode = myNode:copy()
newNode:removeNode(needRemove)
newNode:setData('originNode', myNode)
+ newNode:setData('hasResolved', true)
vm.setNode(source, newNode, true)
end
end
@@ -640,7 +641,9 @@ local function bindAs(source)
local doc = ases[index]
if doc and doc.touch == source.finish then
- vm.setNode(source, vm.compileNode(doc.as), true)
+ local asNode = vm.compileNode(doc.as)
+ asNode:setData 'hasResolved'
+ vm.setNode(source, asNode, true)
return true
end
@@ -1186,6 +1189,7 @@ local compilerSwitch = util.switch()
end)
: case 'local'
: case 'self'
+ ---@async
---@param source parser.object
: call(function (source)
compileLocal(source)
@@ -1222,6 +1226,7 @@ local compilerSwitch = util.switch()
return
end
vm.setNode(src, node, true)
+ node:setData('hasResolved', true)
matchCall(src)
end
end)
@@ -1244,11 +1249,13 @@ local compilerSwitch = util.switch()
vm.compileNode(source.node)
end)
: case 'getlocal'
+ ---@async
: call(function (source)
if bindAs(source) then
return
end
vm.compileNode(source.node)
+ vm.waitResolveRunner(source)
end)
: case 'setfield'
: case 'setmethod'
@@ -1929,6 +1936,13 @@ function vm.compileNode(source)
end
end
+ if source.type == 'getlocal' then
+ ---@cast source parser.object
+ vm.storeWaitingRunner(source)
+ ---@diagnostic disable-next-line: await-in-sync
+ vm.waitResolveRunner(source)
+ end
+
local cache = vm.getNode(source)
if cache ~= nil then
return cache