summaryrefslogtreecommitdiff
path: root/script/vm/global-manager.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-02-25 16:29:11 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-02-25 16:29:11 +0800
commitee408986c37082c981cb2689d71e4d77d4079a23 (patch)
tree2eb6bbd6faddaf94ff2c9cb43b6bf4a14a2ea07f /script/vm/global-manager.lua
parent88253d2cc1f9d1c5042c5a93692abbdda0667333 (diff)
downloadlua-language-server-ee408986c37082c981cb2689d71e4d77d4079a23.zip
update
Diffstat (limited to 'script/vm/global-manager.lua')
-rw-r--r--script/vm/global-manager.lua37
1 files changed, 32 insertions, 5 deletions
diff --git a/script/vm/global-manager.lua b/script/vm/global-manager.lua
index 8176a2af..5267aea1 100644
--- a/script/vm/global-manager.lua
+++ b/script/vm/global-manager.lua
@@ -53,11 +53,6 @@ local compilerGlobalMap = util.switch()
if nxt then
m.compileObject(nxt)
end
-
- if source.special == 'rawset'
- or source.special == 'rawget' then
- m.compileObject(source.parent)
- end
end)
: case 'setfield'
: case 'setmethod'
@@ -109,6 +104,32 @@ local compilerGlobalMap = util.switch()
m.compileObject(nxt)
end
end)
+ : case 'call'
+ : call(function (source)
+ if source.node.special == 'rawset'
+ or source.node.special == 'rawget' then
+ local g = source.args[1]
+ local key = source.args[2]
+ if g and key and g.special == '_G' then
+ local name = guide.getKeyName(key)
+ if name then
+ local uri = guide.getUri(source)
+ local global = m.declareGlobal(name, uri)
+ if source.node.special == 'rawset' then
+ global:addSet(uri, source)
+ else
+ global:addGet(uri, source)
+ end
+ source._globalNode = global
+
+ local nxt = source.next
+ if nxt then
+ m.compileObject(nxt)
+ end
+ end
+ end
+ end
+ end)
: getMap()
@@ -149,6 +170,12 @@ end
function m.compileAst(source)
local env = guide.getENV(source)
m.compileObject(env)
+ guide.eachSpecialOf(source, 'rawset', function (src)
+ m.compileObject(src.parent)
+ end)
+ guide.eachSpecialOf(source, 'rawget', function (src)
+ m.compileObject(src.parent)
+ end)
end
---@return vm.node.global