diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-08-22 14:44:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-08-22 14:44:25 +0800 |
commit | a5c3b64c217fb2691a23ca3b849567474b653ddf (patch) | |
tree | d0540eb47754ee6a5cd65c5b49d7a40785390089 /meta/whimsical | |
parent | 1cc261f303969e6be99f139224869e300fdffc2f (diff) | |
download | lua-language-server-a5c3b64c217fb2691a23ca3b849567474b653ddf.zip |
whimsical
Diffstat (limited to 'meta/whimsical')
-rw-r--r-- | meta/whimsical/basic.lua | 38 | ||||
-rw-r--r-- | meta/whimsical/builtin.lua | 116 |
2 files changed, 154 insertions, 0 deletions
diff --git a/meta/whimsical/basic.lua b/meta/whimsical/basic.lua new file mode 100644 index 00000000..8f25d19f --- /dev/null +++ b/meta/whimsical/basic.lua @@ -0,0 +1,38 @@ +---@meta _ + +---#DES 'arg' +---@type string[] +arg = {} + +---#DES 'assert' +---@generic T +---@param v? T +---@param message? any +---@param ... any +---@return T +---@return any ... => args[reti + 1] +---@error => args[1].istruly +---@narrow v => args[1].truly +function assert(v, message, ...) end + +--[[@@@ +---@overload fun(opt: 'collect') # ---#DESTAIL 'cgopt.collect' +---@overload fun(opt: 'stop') # ---#DESTAIL 'cgopt.stop' +---@overload fun(opt: 'restart') # ---#DESTAIL 'cgopt.restart' +---@overload fun(opt: 'count'): integer # ---#DESTAIL 'cgopt.count' +---@overload fun(opt: 'step'): boolean # ---#DESTAIL 'cgopt.step' +---@overload fun(opt: 'isrunning'): boolean # ---#DESTAIL 'cgopt.isrunning' +---#if VERSION >= 5.4 then +---@overload fun(opt: 'incremental' + , pause?: integer + , stepmul?: integer + , stepsize?: integer) # ---#DESTAIL 'cgopt.incremental' +---@overload fun(opt: 'generational' + , minor?: integer + , major?: integer) # ---#DESTAIL 'cgopt.generational' +---#end +---@overload fun(opt: 'setpause', arg: integer) # ---#DESTAIL 'cgopt.setpause' +---@overload fun(opt: 'setstepmul', arg: integer) # ---#DESTAIL 'cgopt.setstepmul' +---@prototype +]] +function collectgarbage(...) end diff --git a/meta/whimsical/builtin.lua b/meta/whimsical/builtin.lua new file mode 100644 index 00000000..6521bb4b --- /dev/null +++ b/meta/whimsical/builtin.lua @@ -0,0 +1,116 @@ +---@meta _ + +--[[@@@ +---@inner class -> { + self.istruly = true + self.truly = self + self.falsy = Class 'never' + self.view = self.name +} +---@inner integer -> { + self.istruly = true + self.truly = self + self.falsy = Class 'never' + self.view = tostring(self.value) +} +---@inner string -> { + self.istruly = true + self.truly = self + self.falsy = Class 'never' + self.view = cat.util.viewString(self.value, self.quotation) +} +---@inner union -> { + self.istruly = function (subs) + local istruly = subs[1].istruly + if istruly == nil then + return nil + end + if istruly == true then + for i = 2, #subs do + if subs[i].istruly ~= true then + return nil + end + end + return true + else + for i = 2, #subs do + if subs[i].istruly ~= false then + return nil + end + end + return false + end + return nil + end + self.truly = function (subs) + local union = Union() + for i = 1, #subs do + union:add(subs[i].truly) + end + if union:len() == 0 then + return Class 'never' + end + if union:len() == 1 then + return union:first() + end + return union + end + self.falsy = function (subs) + local union = Union() + for i = 1, #subs do + union:add(subs[i].falsy) + end + if union:len() == 0 then + return Class 'never' + end + if union:len() == 1 then + return union:first() + end + return union + end + self.view = function (subs) + local views = {} + for i = 1, #subs do + views[i] = subs[i].view + end + if #views == 0 then + return 'never' + end + return table.concat(views, '|') + end +} +---@class nil -> { + self.istruly = false + self.truly = Class 'never' + self.falsy = self +} +---@class never -> { + self.istruly = nil +} +---@class true -> { + self.istruly = true + self.truly = self + self.falsy = Class 'never' +} +---@class false -> { + self.istruly = false + self.truly = Class 'never' + self.falsy = self +} +---@class any: { [unknown]: any } -> { + self.istruly = nil + self.truly = Class 'truly' + self.falsy = Class 'false' | Class 'nil' +} +---@class truly: { [unknown]: any } +---@class unknown: truly | false +---@class boolean: true | false +---@class number +---@class thread +---@class table: { [unknown]: any } +---@class table<K, V>: { [K]: V } +---@class string: stringlib +---@class userdata: { [unknown]: any } +---@class lightuserdata +---@class function: fun(...): ... +]] |