diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-03 21:15:09 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-03 21:15:09 +0800 |
commit | 57a164bf73714f5a4f9d3eb65eb0f0361d21eed7 (patch) | |
tree | 39aa2c5e6880ceb1d299bcfaeb11f0ab72991078 /script/vm/compiler.lua | |
parent | 33a60bea7e39d134b3086aafb80c7724bcb1d1b4 (diff) | |
download | lua-language-server-57a164bf73714f5a4f9d3eb65eb0f0361d21eed7.zip |
暂存
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r-- | script/vm/compiler.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 35fefd01..dba97932 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -178,6 +178,17 @@ local function selectNode(source, list, index) return m.compileNode(exp) end +local function bindDocs(source) + local isParam = source.parent.type == 'funcargs' + for _, doc in ipairs(source.bindDocs) do + if doc.type == 'doc.type' then + if not isParam then + m.setNode(source, m.compileNode(doc)) + end + end + end +end + local compilerMap = util.switch() : case 'boolean' : case 'table' @@ -205,6 +216,9 @@ local compilerMap = util.switch() if source.dummy then m.setNode(source, m.compileNode(source.method.node)) end + if source.bindDocs then + bindDocs(source) + end -- function x.y(self, ...) --> function x:y(...) if source[1] == 'self' and source.parent.type == 'funcargs' @@ -263,6 +277,20 @@ local compilerMap = util.switch() m.setNode(source, getReturn(vararg.node, source.sindex, source, vararg.args)) end end) + : case 'doc.type' + : call(function (source) + for _, typeUnit in ipairs(source.types) do + m.setNode(source, m.compileNode(typeUnit)) + end + end) + : case 'doc.type.name' + : call(function (source) + local name = source[1] + local uri = guide.getUri(source) + local type = globalMgr.declareGlobal('type', name, uri) + type:addGet(uri, source) + m.setNode(source, type) + end) : getMap() ---@param source parser.object |