diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-11 20:45:20 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-11 20:45:20 +0800 |
commit | 9f8cc1de6737edfb3dbb3e092fa7ce892b06761d (patch) | |
tree | 72bd08b3a39c1250ecd727d51112cd43ce40ec34 /script | |
parent | 3e0959b8a9f61d1db07f78cc94909d68c191f3bd (diff) | |
download | lua-language-server-9f8cc1de6737edfb3dbb3e092fa7ce892b06761d.zip |
update generic
Diffstat (limited to 'script')
-rw-r--r-- | script/core/generic.lua | 31 | ||||
-rw-r--r-- | script/core/linker.lua | 16 |
2 files changed, 43 insertions, 4 deletions
diff --git a/script/core/generic.lua b/script/core/generic.lua index ad91b2f9..61ce55c4 100644 --- a/script/core/generic.lua +++ b/script/core/generic.lua @@ -71,14 +71,14 @@ local function createValue(closure, proto, callback, road) local args = {} local returns = {} for i, arg in ipairs(proto.args) do - local value = instantValue(closure, arg) + local value = createValue(closure, arg, callback, road) if value then hasGeneric = true end args[i] = value or arg end for i, rtn in ipairs(proto.returns) do - local value = instantValue(closure, rtn) + local value = createValue(closure, rtn, callback, road) if value then hasGeneric = true end @@ -95,6 +95,30 @@ local function createValue(closure, proto, callback, road) linker.pushSource(value) return value end + if proto.type == 'doc.type.array' then + road[#road+1] = linker.SPLIT_CHAR + local node = createValue(closure, proto.node, callback, road) + road[#road] = nil + if not node then + return nil + end + local value = instantValue(closure, proto) + value.node = node + return value + end + if proto.type == 'doc.type.table' then + local tkey = createValue(closure, proto.key, callback, road) + road[#road+1] = linker.SPLIT_CHAR + local tvalue = createValue(closure, proto.value, callback, road) + road[#road] = nil + if not tkey and not tvalue then + return nil + end + local value = instantValue(closure, proto) + value.key = tkey or proto.key + value.value = tvalue or proto.value + return value + end end local function buildValue(road, key, proto, param, upvalues) @@ -114,8 +138,7 @@ local function buildValue(road, key, proto, param, upvalues) if not upvalues[key] then upvalues[key] = {} end - -- TODO - upvalues[key][#upvalues[key]+1] = paramID + upvalues[key][#upvalues[key]+1] = paramID .. table.concat(road) end -- 为所有的 param 与 return 创建副本 diff --git a/script/core/linker.lua b/script/core/linker.lua index 4a031abe..f2a9e572 100644 --- a/script/core/linker.lua +++ b/script/core/linker.lua @@ -609,6 +609,22 @@ function m.compileLink(source) pushBackward(getID(tp), id) end end + if proto.type == 'doc.type.array' then + local nodeID = ('%s%s'):format( + id, + SPLIT_CHAR + ) + pushForward(nodeID, getID(source.node)) + end + if proto.type == 'doc.type.table' then + if source.value then + local valueID = ('%s%s'):format( + id, + SPLIT_CHAR + ) + pushForward(valueID, getID(source.value)) + end + end end end |