summaryrefslogtreecommitdiff
path: root/script/vm/global-manager.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-03-02 20:50:54 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-03-02 20:50:54 +0800
commitbbf4d92a166bb8676f8c7e9a5f735a81c5ed2b03 (patch)
tree098967104307f729ccd3042a7fe059013fd212cb /script/vm/global-manager.lua
parent112788ca2c7d73ab5a261e1333090b08c6ac4fc4 (diff)
downloadlua-language-server-bbf4d92a166bb8676f8c7e9a5f735a81c5ed2b03.zip
update
Diffstat (limited to 'script/vm/global-manager.lua')
-rw-r--r--script/vm/global-manager.lua42
1 files changed, 23 insertions, 19 deletions
diff --git a/script/vm/global-manager.lua b/script/vm/global-manager.lua
index 4c2a535e..fb84ffcd 100644
--- a/script/vm/global-manager.lua
+++ b/script/vm/global-manager.lua
@@ -37,7 +37,7 @@ local compilerGlobalMap = util.switch()
: call(function (source)
local uri = guide.getUri(source)
local name = guide.getKeyName(source)
- local global = m.declareGlobal(name, uri)
+ local global = m.declareGlobal('variable', name, uri)
global:addSet(uri, source)
source._globalNode = global
end)
@@ -45,7 +45,7 @@ local compilerGlobalMap = util.switch()
: call(function (source)
local uri = guide.getUri(source)
local name = guide.getKeyName(source)
- local global = m.declareGlobal(name, uri)
+ local global = m.declareGlobal('variable', name, uri)
global:addGet(uri, source)
source._globalNode = global
@@ -78,7 +78,7 @@ local compilerGlobalMap = util.switch()
return
end
local uri = guide.getUri(source)
- local global = m.declareGlobal(name, uri)
+ local global = m.declareGlobal('variable', name, uri)
global:addSet(uri, source)
source._globalNode = global
end)
@@ -99,7 +99,7 @@ local compilerGlobalMap = util.switch()
name = guide.getKeyName(source)
end
local uri = guide.getUri(source)
- local global = m.declareGlobal(name, uri)
+ local global = m.declareGlobal('variable', name, uri)
global:addGet(uri, source)
source._globalNode = global
@@ -118,7 +118,7 @@ local compilerGlobalMap = util.switch()
local name = guide.getKeyName(key)
if name then
local uri = guide.getUri(source)
- local global = m.declareGlobal(name, uri)
+ local global = m.declareGlobal('variable', name, uri)
if source.node.special == 'rawset' then
global:addSet(uri, source)
source.value = source.args[3]
@@ -138,25 +138,29 @@ local compilerGlobalMap = util.switch()
: getMap()
----@param name string
----@param uri uri
+---@param cat '"variable"' | '"type"' | '"alias"'
+---@param name string
+---@param uri uri
---@return vm.node.global
-function m.declareGlobal(name, uri)
- m.globalSubs[uri][name] = true
- if not m.globals[name] then
- m.globals[name] = globalBuilder(name)
+function m.declareGlobal(cat, name, uri)
+ local key = cat .. '|' .. name
+ m.globalSubs[uri][key] = true
+ if not m.globals[key] then
+ m.globals[key] = globalBuilder(name)
end
- return m.globals[name]
+ return m.globals[key]
end
----@param name string
+---@param cat '"variable"' | '"type"' | '"alias"'
+---@param name string
---@param field? string
---@return vm.node.global?
-function m.getGlobal(name, field)
+function m.getGlobal(cat, name, field)
+ local key = cat .. '|' .. name
if field then
- name = name .. m.ID_SPLITE .. field
+ key = key .. m.ID_SPLITE .. field
end
- return m.globals[name]
+ return m.globals[key]
end
---@param source parser.object
@@ -196,11 +200,11 @@ end
function m.dropUri(uri)
local globalSub = m.globalSubs[uri]
m.globalSubs[uri] = nil
- for name in pairs(globalSub) do
- local global = m.globals[name]
+ for key in pairs(globalSub) do
+ local global = m.globals[key]
global:dropUri(uri)
if not global:isAlive() then
- m.globals[name] = nil
+ m.globals[key] = nil
end
end
end