diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-23 14:28:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-23 14:28:11 +0800 |
commit | 62a3e74b5467ca3bc0879e73e8fc8b129c0bec6a (patch) | |
tree | ec1c6d8a7c0e8492547a94f3740e8e0756834f49 /server-beta | |
parent | e88478fa7a42085484d2f9175a720e2a41feb041 (diff) | |
download | lua-language-server-62a3e74b5467ca3bc0879e73e8fc8b129c0bec6a.zip |
更新 LuaParser
Diffstat (limited to 'server-beta')
-rw-r--r-- | server-beta/src/parser/ast.lua | 4 | ||||
-rw-r--r-- | server-beta/src/parser/compile.lua | 34 |
2 files changed, 32 insertions, 6 deletions
diff --git a/server-beta/src/parser/ast.lua b/server-beta/src/parser/ast.lua index f22033db..3ee264c1 100644 --- a/server-beta/src/parser/ast.lua +++ b/server-beta/src/parser/ast.lua @@ -898,6 +898,7 @@ local Defs = { end local loc = createLocal(name, start, actions) + loc.localfunction = true return loc end, @@ -1038,6 +1039,9 @@ local Defs = { elseif key.type == 'getfield' then key.type = 'setfield' key.value = getValue(values, i) + elseif key.type == 'getindex' then + key.type = 'setindex' + key.value = getValue(values, i) end end return tableUnpack(keys) diff --git a/server-beta/src/parser/compile.lua b/server-beta/src/parser/compile.lua index 0e6b4848..457af42c 100644 --- a/server-beta/src/parser/compile.lua +++ b/server-beta/src/parser/compile.lua @@ -120,6 +120,21 @@ local vmMap = { end return id end, + ['setindex'] = function (obj) + Root[#Root+1] = obj + local id = #Root + local node = obj.node + obj.node = Compile(node, id) + local index = obj.index + if index then + obj.index = Compile(index, id) + end + local value = obj.value + if value then + obj.value = Compile(value, id) + end + return id + end, ['getmethod'] = function (obj) Root[#Root+1] = obj local id = #Root @@ -259,11 +274,20 @@ local vmMap = { end Block.locals[#Block.locals+1] = id end - local value = obj.value - if value then - obj.value = Compile(value, id) + if obj.localfunction then + obj.localfunction = nil + Cache[obj] = id + local value = obj.value + if value then + obj.value = Compile(value, id) + end + else + local value = obj.value + if value then + obj.value = Compile(value, id) + end + Cache[obj] = id end - Cache[obj] = id return id end, ['localattr'] = function (obj) @@ -274,10 +298,8 @@ local vmMap = { Root[#Root+1] = obj local id = #Root local node = obj.node - local field = obj.field local value = obj.value obj.node = Compile(node, id) - obj.field = Compile(field, id) obj.value = Compile(value, id) return id end, |