summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-02-25 18:08:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-02-25 18:08:05 +0800
commit4508b4018dced01fe5420e008e813199d0ce856f (patch)
tree4c1938a91270f91945be20a5e0bd489ff08a3994 /script/vm
parent674eb3f23cc00d2f679281abe16634f6b1663d31 (diff)
downloadlua-language-server-4508b4018dced01fe5420e008e813199d0ce856f.zip
update
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/node/compiler.lua35
1 files changed, 28 insertions, 7 deletions
diff --git a/script/vm/node/compiler.lua b/script/vm/node/compiler.lua
index 6c51db86..dbfc54d1 100644
--- a/script/vm/node/compiler.lua
+++ b/script/vm/node/compiler.lua
@@ -179,6 +179,15 @@ local compilerMap = util.switch()
if source.dummy then
m.setNode(source, m.compileNode(source.method.node))
end
+ -- function x.y(self, ...) --> function x:y(...)
+ if source[1] == 'self'
+ and source.parent.type == 'funcargs'
+ and source.parent[1] == source then
+ local setfield = source.parent.parent.parent
+ if setfield.type == 'setfield' then
+ m.setNode(source, m.compileNode(setfield.node))
+ end
+ end
end)
: case 'getlocal'
: call(function (source)
@@ -228,20 +237,32 @@ local compilerMap = util.switch()
: getMap()
---@param source parser.object
----@return vm.node
-function m.compileNode(source)
- if source._node ~= nil then
- return source._node
- end
- source._node = false
+local function compileByNode(source)
local compiler = compilerMap[source.type]
if compiler then
compiler(source)
end
- localMgr.subscribeLocal(source, source._node)
+end
+
+---@param source parser.object
+local function compileByGlobal(source)
if source._globalNode then
m.setNode(source, source._globalNode)
end
+end
+
+---@param source parser.object
+---@return vm.node
+function m.compileNode(source)
+ if source._node ~= nil then
+ return source._node
+ end
+ source._node = false
+ compileByNode(source)
+ compileByGlobal(source)
+
+ localMgr.subscribeLocal(source, source._node)
+
return source._node
end