summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-19 03:23:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-19 03:23:43 +0800
commitc8a4a575caf8e1cc4a44b26dd824112e790782ac (patch)
tree19e323387059cb56073b607301d3a5c8b305e878 /script
parentfa191ea61477047c4754b730f129f96239ddb93e (diff)
downloadlua-language-server-c8a4a575caf8e1cc4a44b26dd824112e790782ac.zip
cleanup
Diffstat (limited to 'script')
-rw-r--r--script/vm/compiler.lua7
-rw-r--r--script/vm/local-compiler.lua16
-rw-r--r--script/vm/node.lua5
3 files changed, 16 insertions, 12 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index ba1559be..5ed7d069 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -870,7 +870,7 @@ local compilerSwitch = util.switch()
local hasMark = vm.getNode(source):getData 'hasDefined'
local runner = vm.createRunner(source)
- runner:launch(function (src, loc)
+ runner:launch(function (src, node)
if src.type == 'setlocal' then
if src.value and not hasMark then
if src.value.type == 'table' then
@@ -879,11 +879,10 @@ local compilerSwitch = util.switch()
vm.setNode(src, vm.compileNode(src.value))
end
else
- vm.setNode(src, vm.getNode(loc))
+ vm.setNode(src, node)
end
- loc = src
elseif src.type == 'getlocal' then
- vm.setNode(src, vm.getNode(loc), true)
+ vm.setNode(src, node, true)
end
end)
diff --git a/script/vm/local-compiler.lua b/script/vm/local-compiler.lua
index 6065229f..844acc18 100644
--- a/script/vm/local-compiler.lua
+++ b/script/vm/local-compiler.lua
@@ -24,10 +24,10 @@ local function sortRefs(source)
end)
end
----@param loc parser.object
+---@param node vm.node
---@param currentFunc parser.object
----@param callback fun(src: parser.object, loc: parser.object)
-function mt:_runFunction(loc, currentFunc, callback)
+---@param callback fun(src: parser.object, node: vm.node)
+function mt:_runFunction(node, currentFunc, callback)
while true do
local ref = self.loc.ref[self.index]
if not ref then
@@ -38,20 +38,20 @@ function mt:_runFunction(loc, currentFunc, callback)
end
local func = guide.getParentFunction(ref)
if func == currentFunc then
- callback(ref, loc)
+ callback(ref, node)
self.index = self.index + 1
if ref.type == 'setlocal' then
- loc = ref
+ node = vm.getNode(ref)
end
else
- self:_runFunction(loc, func, callback)
+ self:_runFunction(node, func, callback)
end
end
end
----@param callback fun(src: parser.object, loc: parser.object)
+---@param callback fun(src: parser.object, node: vm.node)
function mt:launch(callback)
- self:_runFunction(self.loc, self.mainFunc, callback)
+ self:_runFunction(vm.getNode(self.loc), self.mainFunc, callback)
end
---@param loc parser.object
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 81405c48..99bc3340 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -93,6 +93,10 @@ function mt:isFalsy()
return false
end
+function mt:removeFalsy()
+
+end
+
---@return fun():vm.object
function mt:eachObject()
local i = 0
@@ -133,6 +137,7 @@ function vm.setNode(source, node, cover)
end
end
+---@param source vm.object
---@return vm.node?
function vm.getNode(source)
return vm.nodeCache[source]