From 4e01c062182d333ea7d7007c2f44d036993d9c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 30 Sep 2019 17:07:36 +0800 Subject: =?UTF-8?q?=E6=94=AF=E6=8C=81method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/core/engineer.lua | 9 ++++++++- server-beta/src/parser/ast.lua | 5 ++--- server-beta/src/parser/compile.lua | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'server-beta/src') diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index c5ed636c..6baa0d20 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -14,7 +14,9 @@ mt.type = 'engineer' mt['local'] = function (self, source, mode, callback) if mode == 'def' then - callback(source, 'local') + if source.tag ~= 'self' then + callback(source, 'local') + end if source.ref then for _, ref in ipairs(source.ref) do if ref.type == 'setlocal' then @@ -22,6 +24,11 @@ mt['local'] = function (self, source, mode, callback) end end end + if source.tag == 'self' then + local method = source.method + local node = method.node + self:search(node, node.type, mode, callback) + end end end mt['getlocal'] = function (self, source, mode, callback) diff --git a/server-beta/src/parser/ast.lua b/server-beta/src/parser/ast.lua index c9ae7078..47a8d4d1 100644 --- a/server-beta/src/parser/ast.lua +++ b/server-beta/src/parser/ast.lua @@ -824,16 +824,15 @@ local Defs = { if name.type == 'getname' then name.type = 'setname' name.value = actions - return name elseif name.type == 'getfield' then name.type = 'setfield' name.value = actions - return name elseif name.type == 'getmethod' then name.type = 'setmethod' name.value = actions - return name end + name.range = actions.finish + return name end, LocalFunction = function (start, name, args, actions, finish) actions.type = 'function' diff --git a/server-beta/src/parser/compile.lua b/server-beta/src/parser/compile.lua index ead4b882..2bcb7e46 100644 --- a/server-beta/src/parser/compile.lua +++ b/server-beta/src/parser/compile.lua @@ -89,6 +89,7 @@ local vmMap = { finish = 0, method = obj, effect = obj.finish, + tag = 'self', [1] = 'self', } Compile(value, obj) -- cgit v1.2.3