diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-09-08 18:00:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-09-08 18:00:22 +0800 |
commit | a1af5107dd53388d86902c13ae2e0125ebcbc158 (patch) | |
tree | 56be529436205b76abbf6fa892e06ec771054519 /meta | |
parent | 16b9ce9bafbf0f432ab7d1d063e2f18b1ed0c947 (diff) | |
download | lua-language-server-a1af5107dd53388d86902c13ae2e0125ebcbc158.zip |
update whimsical
Diffstat (limited to 'meta')
-rw-r--r-- | meta/whimsical/basic.lua | 14 | ||||
-rw-r--r-- | meta/whimsical/rule.lua | 56 |
2 files changed, 44 insertions, 26 deletions
diff --git a/meta/whimsical/basic.lua b/meta/whimsical/basic.lua index 8f25d19f..9075a0e9 100644 --- a/meta/whimsical/basic.lua +++ b/meta/whimsical/basic.lua @@ -11,7 +11,7 @@ arg = {} ---@param ... any ---@return T ---@return any ... => args[reti + 1] ----@error => args[1].istruly +---@throw => args[1].isFalsy ---@narrow v => args[1].truly function assert(v, message, ...) end @@ -36,3 +36,15 @@ function assert(v, message, ...) end ---@prototype ]] function collectgarbage(...) end + +---#DES 'dofile' +---@param filename? string +---@return any +---@custom dofile +function dofile(filename) end + +---#DES 'error' +---@param message any +---@param level? integer +---@throw +function error(message, level) end diff --git a/meta/whimsical/rule.lua b/meta/whimsical/rule.lua index 2cfe865f..0715d78f 100644 --- a/meta/whimsical/rule.lua +++ b/meta/whimsical/rule.lua @@ -1,81 +1,81 @@ local cat -cat.rule.inner.default = function (self) - self.istruly = true +cat.rule.default = function (self) + self.isTruly = true self.truly = self self.falsy = cat.class 'never' self.view = self.name end -cat.rule.inner.never = function (self) - self.istruly = nil +cat.rule.never = function (self) + self.isTruly = nil end -cat.rule.inner.any = function (self) - self.istruly = nil +cat.rule.any = function (self) + self.isTruly = nil self.truly = cat.class 'truly' self.falsy = cat.boolean(false) | cat.class 'nil' end -cat.rule.inner['nil'] = function (self) - self.istruly = false +cat.rule['nil'] = function (self) + self.isTruly = false self.truly = cat.class 'never' self.falsy = self end -cat.rule.inner.boolean = function (self) +cat.rule.boolean = function (self) if self.value == true then - self.istruly = true + self.isTruly = true self.truly = self self.falsy = cat.class 'never' elseif self.value == false then - self.istruly = false + self.isTruly = false self.truly = cat.class 'never' self.falsy = self else - self.istruly = nil + self.isTruly = nil self.truly = cat.boolean(true) self.falsy = cat.boolean(false) end end -cat.rule.inner.number = function (self) - self.istruly = true +cat.rule.number = function (self) + self.isTruly = true self.truly = self self.falsy = cat.class 'never' self.view = tostring(self.value) end -cat.rule.inner.integer = function (self) - self.istruly = true +cat.rule.integer = function (self) + self.isTruly = true self.truly = self self.falsy = cat.class 'never' self.view = tostring(self.value) end -cat.rule.inner.string = function (self) - self.istruly = true +cat.rule.string = function (self) + self.isTruly = true self.truly = self self.falsy = cat.class 'never' self.view = cat.util.viewString(self.value, self.quotation) end -cat.rule.inner.union = function (self) - self.istruly = function (union) - local istruly = union.subs[1].istruly - if istruly == nil then +cat.rule.union = function (self) + self.isTruly = function (union) + local isTruly = union.subs[1].isTruly + if isTruly == nil then return nil end - if istruly == true then + if isTruly == true then for i = 2, #union.subs do - if union.subs[i].istruly ~= true then + if union.subs[i].isTruly ~= true then return nil end end return true else for i = 2, #union.subs do - if union.subs[i].istruly ~= false then + if union.subs[i].isTruly ~= false then return nil end end @@ -120,3 +120,9 @@ cat.rule.inner.union = function (self) return table.concat(views, '|') end end + +cat.custom.dofile.onReturn = function (context) + local filename = context.args[1].asString + local file = cat.files[filename] + return file.returns[1] +end |