diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-06-01 10:29:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-01 10:29:25 +0800 |
commit | f8f04e73c55d2586c6dde55e2fe02a3c06a96558 (patch) | |
tree | 71256586dbf13086de1266a851d1c567ef04c2f0 | |
parent | 19bf34c10f2760c8284fb4ce3160ccbb4593ec92 (diff) | |
parent | 0c3e35427e70cf83178e338e854f70e9f8124bf9 (diff) | |
download | lua-language-server-f8f04e73c55d2586c6dde55e2fe02a3c06a96558.zip |
Merge pull request #2106 from fesily/meta-support-metable
meta:support metatable
-rw-r--r-- | meta/template/basic.lua | 39 | ||||
-rw-r--r-- | script/vm/compiler.lua | 2 |
2 files changed, 40 insertions, 1 deletions
diff --git a/meta/template/basic.lua b/meta/template/basic.lua index c024b222..62ab999e 100644 --- a/meta/template/basic.lua +++ b/meta/template/basic.lua @@ -209,9 +209,46 @@ function select(index, ...) end ---@return function function setfenv(f, table) end + +---@class metatable +---@field __mode 'v'|'k'|'kv'|nil +---@field __metatable any|nil +---@field __tostring fun(t):string|nil +---@field __gc fun(t)|nil +---@field __add fun(t1,t2):any|nil +---@field __sub fun(t1,t2):any|nil +---@field __mul fun(t1,t2):any|nil +---@field __div fun(t1,t2):any|nil +---@field __mod fun(t1,t2):any|nil +---@field __pow fun(t1,t2):any|nil +---@field __unm fun(t):any|nil +---#if VERSION >= 5.3 then +---@field __idiv fun(t1,t2):any|nil +---@field __band fun(t1,t2):any|nil +---@field __bor fun(t1,t2):any|nil +---@field __bxor fun(t1,t2):any|nil +---@field __bnot fun(t):any|nil +---@field __shl fun(t1,t2):any|nil +---@field __shr fun(t1,t2):any|nil +---#end +---@field __concat fun(t1,t2):any|nil +---@field __len fun(t):integer|nil +---@field __eq fun(t1,t2):boolean|nil +---@field __lt fun(t1,t2):boolean|nil +---@field __le fun(t1,t2):boolean|nil +---@field __index table|fun(t,k)|nil +---@field __newindex table|fun(t,k,v)|nil +---@field __call fun(t,...)|nil +---#if VERSION > 5.1 or VERSION == JIT then +---@field __pairs fun(t):fun(t,k,v)|nil +---#end +---#if VERSION == JIT or VERSION == 5.2 then +---@field __ipairs fun(t):fun(t,k,v)|nil +---#end + ---#DES 'setmetatable' ---@param table table ----@param metatable? table +---@param metatable? metatable|table ---@return table function setmetatable(table, metatable) end diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index f455d6da..6b4636fc 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -522,6 +522,8 @@ local function getReturnOfSetMetaTable(args) end end) end + --过滤nil + node:remove 'nil' return node end |