diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-28 00:43:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-28 00:43:59 +0800 |
commit | 4774c8ce50f0c971f9e9efde44c083c606f3105a (patch) | |
tree | caef79104f1bdef992ced4584fd37137f8f4e5b7 /script/vm | |
parent | f9b3b65445e86ae0e9c1026ea1fac44bf5d884da (diff) | |
parent | a824f07a2df80f66a8017fd1d6dac8c3df5cf6e2 (diff) | |
download | lua-language-server-4774c8ce50f0c971f9e9efde44c083c606f3105a.zip |
Merge pull request #1241 from FAForever/array-contents-support
Array contents support
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/compiler.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 9968c4b9..d39c9c61 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -805,7 +805,7 @@ local function isValidCallArgNode(source, node) return node.type == 'doc.type.function' end if source.type == 'table' then - return node.type == 'doc.type.table' + return node.type == 'doc.type.table' or node.type == 'doc.type.array' or ( node.type == 'global' and node.cate == 'type' ---@cast node vm.global @@ -1274,6 +1274,7 @@ local compilerSwitch = util.switch() or source.parent.type == 'setlocal' or source.parent.type == 'tablefield' or source.parent.type == 'tableindex' + or source.parent.type == 'tableexp' or source.parent.type == 'setfield' or source.parent.type == 'setindex' then local parentNode = vm.compileNode(source.parent) @@ -1284,7 +1285,7 @@ local compilerSwitch = util.switch() if not guide.isBasicType(pn.name) then vm.setNode(source, pn) end - elseif pn.type == 'doc.type.table' then + elseif pn.type == 'doc.type.table' or pn.type == 'doc.type.array' then vm.setNode(source, pn) end end @@ -1490,6 +1491,14 @@ local compilerSwitch = util.switch() end) : case 'tableexp' : call(function (source) + if (source.parent.type == 'table') then + local node = vm.compileNode(source.parent) + for n in node:eachObject() do + if n.type == 'doc.type.array' then + vm.setNode(source, vm.compileNode(n.node)) + end + end + end vm.setNode(source, vm.compileNode(source.value)) end) : case 'function.return' |