diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-07 19:46:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-07 19:46:14 +0800 |
commit | f5f0620a09708c07acbb024a0a98bd8595658116 (patch) | |
tree | 197d68944ec38099a5d1d611545d316180b7335d /script/vm | |
parent | d10e3b99be56ed6ae598a2c13892324f6994fb5c (diff) | |
download | lua-language-server-f5f0620a09708c07acbb024a0a98bd8595658116.zip |
update
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/compiler.lua | 45 | ||||
-rw-r--r-- | script/vm/generic.lua | 2 |
2 files changed, 43 insertions, 4 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 75575fc4..59ef9cbe 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -335,7 +335,7 @@ local function selectNode(source, list, index) if exp.type == '...' then -- TODO end - return m.compileNode(exp) + return nodeMgr.setNode(source, m.compileNode(exp)) end local compilerMap = util.switch() @@ -396,6 +396,10 @@ local compilerMap = util.switch() nodeMgr.setNode(source, m.compileNode(setfield.node)) end end + -- for x in ... do + if source.parent.type == 'in' then + m.compileNode(source.parent) + end end) : case 'getlocal' : call(function (source) @@ -459,7 +463,7 @@ local compilerMap = util.switch() end if func.returns and not hasMarkDoc then for _, rtn in ipairs(func.returns) do - nodeMgr.setNode(source, selectNode(source, rtn, index)) + selectNode(source, rtn, index) end end end) @@ -467,7 +471,26 @@ local compilerMap = util.switch() : call(function (source) local vararg = source.vararg if vararg.type == 'call' then - nodeMgr.setNode(source, getReturn(vararg.node, source.sindex, source, vararg.args)) + getReturn(vararg.node, source.sindex, source, vararg.args) + end + end) + : case 'in' + : call(function (source) + if not source._iterator then + -- for k, v in pairs(t) do + --> for k, v in iterator, status, initValue do + --> local k, v = iterator(status, initValue) + source._iterator = {} + source._iterArgs = {{}, {}} + -- iterator + selectNode(source._iterator, source.exps, 1) + -- status + selectNode(source._iterArgs[1], source.exps, 2) + -- initValue + selectNode(source._iterArgs[2], source.exps, 3) + end + for i, loc in ipairs(source.keys) do + getReturn(source._iterator, i, loc, source._iterArgs) end end) : case 'doc.type' @@ -557,6 +580,22 @@ local function compileByGlobal(source) end end end + if source._globalNode.cate == 'type' then + for _, set in ipairs(source._globalNode:getSets()) do + if set.type == 'doc.class' then + if set.extends then + for _, ext in ipairs(set.extends) do + if ext.type == 'doc.type.table' then + nodeMgr.setNode(source, m.compileNode(ext)) + end + end + end + end + if set.type == 'doc.alias' then + nodeMgr.setNode(source, m.compileNode(set.extends)) + end + end + end return end end diff --git a/script/vm/generic.lua b/script/vm/generic.lua index c3e1ecbc..6d5a19da 100644 --- a/script/vm/generic.lua +++ b/script/vm/generic.lua @@ -80,7 +80,7 @@ local function cloneObject(node, resolved) end return newDocFunc end - return nil + return node end ---@param argNodes vm.node[] |