diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-24 20:32:09 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-02-24 20:32:09 +0800 |
commit | e4606599ee4f6d5c8d10fd4e7ecbe315e4b65c3b (patch) | |
tree | 1310fa89c3a8789b2b13161be6f9afee2fae96a9 /script | |
parent | 38f1b173dd57e163ee7821560566cb59e1ac95cd (diff) | |
download | lua-language-server-e4606599ee4f6d5c8d10fd4e7ecbe315e4b65c3b.zip |
update
Diffstat (limited to 'script')
-rw-r--r-- | script/vm/getDef.lua | 2 | ||||
-rw-r--r-- | script/vm/global-manager.lua | 7 | ||||
-rw-r--r-- | script/vm/node/compiler.lua | 17 |
3 files changed, 17 insertions, 9 deletions
diff --git a/script/vm/getDef.lua b/script/vm/getDef.lua index c37c1323..82fa84eb 100644 --- a/script/vm/getDef.lua +++ b/script/vm/getDef.lua @@ -84,7 +84,7 @@ local searchFieldMap = util.switch() if not newGlobal then return end - for set in ipairs(newGlobal:getSets()) do + for _, set in ipairs(newGlobal:getSets()) do pushResult(set) end end) diff --git a/script/vm/global-manager.lua b/script/vm/global-manager.lua index 86f6be9f..b9f22b43 100644 --- a/script/vm/global-manager.lua +++ b/script/vm/global-manager.lua @@ -31,7 +31,6 @@ local compilerGlobalMap = util.switch() local name = guide.getKeyName(source) local global = m.declareGlobal(name, uri) global:addSet(uri, source) - m.globalSubs[uri][name] = true source._globalNode = global end) : case 'getglobal' @@ -39,7 +38,6 @@ local compilerGlobalMap = util.switch() local name = guide.getKeyName(source) local global = m.declareGlobal(name, uri) global:addGet(uri, source) - m.globalSubs[uri][name] = true source._globalNode = global local nxt = source.next @@ -60,7 +58,7 @@ local compilerGlobalMap = util.switch() local name = parent:getName() .. m.ID_SPLITE .. guide.getKeyName(source) local global = m.declareGlobal(name, uri) global:addSet(uri, source) - m.globalSubs[uri][name] = true + source._globalNode = global end) : case 'getfield' : case 'getmethod' @@ -73,8 +71,7 @@ local compilerGlobalMap = util.switch() return end local name = parent:getName() .. m.ID_SPLITE .. guide.getKeyName(source) - local global = m.getGlobal(name) - m.globalSubs[uri][name] = true + local global = m.declareGlobal(name, uri) global:addGet(uri, source) source._globalNode = global diff --git a/script/vm/node/compiler.lua b/script/vm/node/compiler.lua index 33b9b05e..f91f90ae 100644 --- a/script/vm/node/compiler.lua +++ b/script/vm/node/compiler.lua @@ -25,6 +25,9 @@ function m.setNode(source, node) source._node = node return end + if me == node then + return + end if me.type == 'union' or me.type == 'cross' then me:merge(node) @@ -91,11 +94,19 @@ local searchFieldMap = util.switch() if field.type == 'tablefield' or field.type == 'tableindex' then if guide.getKeyName(field) == key then - pushResult(field) + pushResult(m.compileNode(field)) end end end end) + : case 'global' + ---@param node vm.node.global + : call(function (node, key, pushResult) + local global = globalMgr.getGlobal(node.name, key) + if global then + pushResult(global) + end + end) : getMap() local function compileByParentNode(source) @@ -106,8 +117,8 @@ local function compileByParentNode(source) local key = guide.getKeyName(source) local f = searchFieldMap[parentNode.type] if f then - f(parentNode, key, function (field) - m.setNode(source, m.compileNode(field.value)) + f(parentNode, key, function (fieldNode) + m.setNode(source, fieldNode) end) end end |