summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/vm/getDef.lua2
-rw-r--r--script/vm/global-manager.lua42
-rw-r--r--script/vm/node/class.lua11
-rw-r--r--script/vm/node/compiler.lua2
-rw-r--r--script/vm/node/union.lua2
5 files changed, 26 insertions, 33 deletions
diff --git a/script/vm/getDef.lua b/script/vm/getDef.lua
index e661b861..7f9acb04 100644
--- a/script/vm/getDef.lua
+++ b/script/vm/getDef.lua
@@ -86,7 +86,7 @@ local searchFieldMap = util.switch()
end)
: case 'global'
: call(function (node, key, pushResult)
- local newGlobal = globalMgr.getGlobal(node.name, key)
+ local newGlobal = globalMgr.getGlobal('variable', node.name, key)
if not newGlobal then
return
end
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
diff --git a/script/vm/node/class.lua b/script/vm/node/class.lua
deleted file mode 100644
index ee8b1ca8..00000000
--- a/script/vm/node/class.lua
+++ /dev/null
@@ -1,11 +0,0 @@
----@class vm.node.class
-local mt = {}
-mt.__index = mt
-mt.type = 'class'
-
----@return vm.node.class
-return function ()
- local class = setmetatable({
- }, mt)
- return class
-end
diff --git a/script/vm/node/compiler.lua b/script/vm/node/compiler.lua
index dd151e4f..156c4a74 100644
--- a/script/vm/node/compiler.lua
+++ b/script/vm/node/compiler.lua
@@ -65,7 +65,7 @@ local searchFieldMap = util.switch()
: case 'global'
---@param node vm.node.global
: call(function (node, key, pushResult)
- local global = globalMgr.getGlobal(node.name, key)
+ local global = globalMgr.getGlobal('variable', node.name, key)
if global then
pushResult(global)
end
diff --git a/script/vm/node/union.lua b/script/vm/node/union.lua
index 538e7586..f0c259df 100644
--- a/script/vm/node/union.lua
+++ b/script/vm/node/union.lua
@@ -5,7 +5,7 @@ local mt = {}
mt.__index = mt
mt.type = 'union'
----@param node vm.node
+---@param node vm.node
function mt:merge(node)
if not node then
return