Skip to content

Commit a1af510

Browse files
committed
update whimsical
1 parent 16b9ce9 commit a1af510

File tree

2 files changed

+44
-26
lines changed

2 files changed

+44
-26
lines changed

meta/whimsical/basic.lua

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ arg = {}
1111
---@param ... any
1212
---@return T
1313
---@return any ... => args[reti + 1]
14-
---@error => args[1].istruly
14+
---@throw => args[1].isFalsy
1515
---@narrow v => args[1].truly
1616
function assert(v, message, ...) end
1717

@@ -36,3 +36,15 @@ function assert(v, message, ...) end
3636
---@prototype
3737
]]
3838
function collectgarbage(...) end
39+
40+
---#DES 'dofile'
41+
---@param filename? string
42+
---@return any
43+
---@custom dofile
44+
function dofile(filename) end
45+
46+
---#DES 'error'
47+
---@param message any
48+
---@param level? integer
49+
---@throw
50+
function error(message, level) end

meta/whimsical/rule.lua

+31-25
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
11
local cat
22

3-
cat.rule.inner.default = function (self)
4-
self.istruly = true
3+
cat.rule.default = function (self)
4+
self.isTruly = true
55
self.truly = self
66
self.falsy = cat.class 'never'
77
self.view = self.name
88
end
99

10-
cat.rule.inner.never = function (self)
11-
self.istruly = nil
10+
cat.rule.never = function (self)
11+
self.isTruly = nil
1212
end
1313

14-
cat.rule.inner.any = function (self)
15-
self.istruly = nil
14+
cat.rule.any = function (self)
15+
self.isTruly = nil
1616
self.truly = cat.class 'truly'
1717
self.falsy = cat.boolean(false) | cat.class 'nil'
1818
end
1919

20-
cat.rule.inner['nil'] = function (self)
21-
self.istruly = false
20+
cat.rule['nil'] = function (self)
21+
self.isTruly = false
2222
self.truly = cat.class 'never'
2323
self.falsy = self
2424
end
2525

26-
cat.rule.inner.boolean = function (self)
26+
cat.rule.boolean = function (self)
2727
if self.value == true then
28-
self.istruly = true
28+
self.isTruly = true
2929
self.truly = self
3030
self.falsy = cat.class 'never'
3131
elseif self.value == false then
32-
self.istruly = false
32+
self.isTruly = false
3333
self.truly = cat.class 'never'
3434
self.falsy = self
3535
else
36-
self.istruly = nil
36+
self.isTruly = nil
3737
self.truly = cat.boolean(true)
3838
self.falsy = cat.boolean(false)
3939
end
4040
end
4141

42-
cat.rule.inner.number = function (self)
43-
self.istruly = true
42+
cat.rule.number = function (self)
43+
self.isTruly = true
4444
self.truly = self
4545
self.falsy = cat.class 'never'
4646
self.view = tostring(self.value)
4747
end
4848

49-
cat.rule.inner.integer = function (self)
50-
self.istruly = true
49+
cat.rule.integer = function (self)
50+
self.isTruly = true
5151
self.truly = self
5252
self.falsy = cat.class 'never'
5353
self.view = tostring(self.value)
5454
end
5555

56-
cat.rule.inner.string = function (self)
57-
self.istruly = true
56+
cat.rule.string = function (self)
57+
self.isTruly = true
5858
self.truly = self
5959
self.falsy = cat.class 'never'
6060
self.view = cat.util.viewString(self.value, self.quotation)
6161
end
6262

63-
cat.rule.inner.union = function (self)
64-
self.istruly = function (union)
65-
local istruly = union.subs[1].istruly
66-
if istruly == nil then
63+
cat.rule.union = function (self)
64+
self.isTruly = function (union)
65+
local isTruly = union.subs[1].isTruly
66+
if isTruly == nil then
6767
return nil
6868
end
69-
if istruly == true then
69+
if isTruly == true then
7070
for i = 2, #union.subs do
71-
if union.subs[i].istruly ~= true then
71+
if union.subs[i].isTruly ~= true then
7272
return nil
7373
end
7474
end
7575
return true
7676
else
7777
for i = 2, #union.subs do
78-
if union.subs[i].istruly ~= false then
78+
if union.subs[i].isTruly ~= false then
7979
return nil
8080
end
8181
end
@@ -120,3 +120,9 @@ cat.rule.inner.union = function (self)
120120
return table.concat(views, '|')
121121
end
122122
end
123+
124+
cat.custom.dofile.onReturn = function (context)
125+
local filename = context.args[1].asString
126+
local file = cat.files[filename]
127+
return file.returns[1]
128+
end

0 commit comments

Comments
 (0)