diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-14 20:30:06 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-14 20:30:06 +0800 |
commit | 9c084cd0bf6b83bb235a60dd2353b775c379ac6e (patch) | |
tree | 96af3e33c60ab542581f05d8690d928d9e13aa50 /script/vm/compiler.lua | |
parent | 484cbb5fd17ef0620c9b926d1726dafc82401f1d (diff) | |
download | lua-language-server-9c084cd0bf6b83bb235a60dd2353b775c379ac6e.zip |
cleanup
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r-- | script/vm/compiler.lua | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 20f0e4e3..1b786cb8 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -13,7 +13,7 @@ local vm = require 'vm.vm' ---@class parser.object ---@field _compiledNodes boolean ---@field _node vm.node ----@field _localBaseNode vm.node? +---@field _localBase table local searchFieldSwitch = util.switch() : case 'table' @@ -686,10 +686,19 @@ end ---@param source parser.object ---@return vm.node local function compileLocalBase(source) - if source._localBaseNode then - return source._localBaseNode + if not source._localBase then + source._localBase = { + type = 'localbase', + parent = source, + } end - source._localBaseNode = vm.createNode() + local baseNode = vm.getNode(source._localBase) + if baseNode then + return baseNode + end + baseNode = vm.createNode() + vm.setNode(source._localBase, baseNode, true) + vm.setNode(source, source) local hasMarkDoc if source.bindDocs then @@ -750,12 +759,12 @@ local function compileLocalBase(source) vm.setNode(source, globalMgr.getGlobal('type', 'integer')) end - source._localBaseNode:merge(vm.getNode(source)) + baseNode:merge(vm.getNode(source)) vm.removeNode(source) - source._localBaseNode:setData('hasDefined', hasMarkDoc or hasMarkParam or hasMarkValue) + baseNode:setData('hasDefined', hasMarkDoc or hasMarkParam or hasMarkValue) - return source._localBaseNode + return baseNode end local compilerSwitch = util.switch() |