diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-31 10:42:27 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-31 10:42:27 +0800 |
commit | 51a43979dc277e1a4418725cd001b5520d84588d (patch) | |
tree | eefbf7dc228820ff9aea59134022a0bbe5ecf7e5 /script/parser/compile.lua | |
parent | d36ceb32aeb95261be630157cbf7389c0d3c8085 (diff) | |
download | lua-language-server-51a43979dc277e1a4418725cd001b5520d84588d.zip |
#450 add dummy param into param list
Diffstat (limited to 'script/parser/compile.lua')
-rw-r--r-- | script/parser/compile.lua | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua index 392f0682..04fc19c7 100644 --- a/script/parser/compile.lua +++ b/script/parser/compile.lua @@ -1,6 +1,8 @@ -local guide = require 'core.guide' -local type = type -local os = os +local guide = require 'parser.guide' +local type = type +local tableInsert = table.insert +local pairs = pairs +local os = os local specials = { ['_G'] = true, @@ -73,6 +75,24 @@ local vmMap = { end, ['call'] = function (obj) Compile(obj.node, obj) + if obj.node and obj.node.type == 'getmethod' then + if not obj.args then + obj.args = { + type = 'callargs', + start = obj.start, + finish = obj.finish, + parent = obj, + } + end + local newNode = {} + for k, v in pairs(obj.node.node) do + newNode[k] = v + end + newNode.mirror = obj.node.node + newNode.dummy = true + obj.node.node.mirror = newNode + tableInsert(obj.args, 1, newNode) + end Compile(obj.args, obj) end, ['callargs'] = function (obj) @@ -126,15 +146,24 @@ local vmMap = { Compile(obj.node, obj) Compile(obj.method, obj) local value = obj.value - value.localself = { + local localself = { type = 'local', start = 0, finish = 0, method = obj, effect = obj.finish, tag = 'self', + dummy = true, [1] = 'self', } + if not value.args then + value.args = { + type = 'funcargs', + start = obj.start, + finish = obj.finish, + } + end + tableInsert(value.args, 1, localself) Compile(value, obj) end, ['function'] = function (obj) @@ -142,10 +171,6 @@ local vmMap = { local LastLocalCount = LocalCount Block = obj LocalCount = 0 - if obj.localself then - Compile(obj.localself, obj) - obj.localself = nil - end Compile(obj.args, obj) for i = 1, #obj do Compile(obj[i], obj) |