From 75509a89ecc69c683c015a97c9844746c81e6057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 14 Apr 2022 22:23:32 +0800 Subject: cheanup --- script/parser/guide.lua | 4 +++- script/parser/luadoc.lua | 3 ++- script/parser/newparser.lua | 21 ++++++++++----------- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'script/parser') diff --git a/script/parser/guide.lua b/script/parser/guide.lua index c4b0b1db..c0f33c28 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -21,7 +21,6 @@ local type = type ---@field specials parser.object[] ---@field labels parser.object[] ---@field node parser.object ----@field dummy boolean ---@field field parser.object ---@field method parser.object ---@field index parser.object @@ -833,6 +832,7 @@ end local isSetMap = { ['setglobal'] = true, ['local'] = true, + ['self'] = true, ['setlocal'] = true, ['setfield'] = true, ['setmethod'] = true, @@ -931,6 +931,7 @@ function m.getKeyName(obj) or tp == 'setglobal' then return obj[1] elseif tp == 'local' + or tp == 'self' or tp == 'getlocal' or tp == 'setlocal' then return obj[1] @@ -999,6 +1000,7 @@ function m.getKeyType(obj) or tp == 'setglobal' then return 'string' elseif tp == 'local' + or tp == 'self' or tp == 'getlocal' or tp == 'setlocal' then return 'local' diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index bbfd3ab4..22a2df1b 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -1367,6 +1367,7 @@ local function bindDocsBetween(sources, binded, bindSources, start, finish) end if src.start >= start then if src.type == 'local' + or src.type == 'self' or src.type == 'setglobal' or src.type == 'tablefield' or src.type == 'tableindex' @@ -1437,7 +1438,7 @@ end local bindDocAccept = { 'local' , 'setlocal' , 'setglobal', 'setfield' , 'setmethod' , 'setindex' , - 'tablefield', 'tableindex', + 'tablefield', 'tableindex', 'self' , 'function' , 'table' , '...' , } diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index 5245b94d..ea4ad2c7 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -1749,15 +1749,15 @@ local function addDummySelf(node, call) parent = call, } end - local newNode = {} - for k, v in next, call.node.node do - newNode[k] = v - end - newNode.mirror = call.node.node - newNode.dummy = true - newNode.parent = call.args - call.node.node.mirror = newNode - tinsert(call.args, 1, newNode) + local self = createLocal { + start = node.colon.start, + finish = node.colon.finish, + method = node, + parent = call.args, + [1] = 'self', + } + self.type = 'self' + tinsert(call.args, 1, self) end local function parseSimple(node, funcName) @@ -2303,10 +2303,9 @@ local function parseFunction(isLocal, isAction) finish = funcRight, method = func.name, parent = params, - tag = 'self', - dummy = true, [1] = 'self', } + params[1].type = 'self' end end if hasLeftParen then -- cgit v1.2.3