-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlua.lua
More file actions
48 lines (39 loc) · 992 Bytes
/
lua.lua
File metadata and controls
48 lines (39 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local T = require("types")
local Array, Enum, Fn, Generic, Map, Struct, Union, Var = T.Array, T.Enum, T.Fn, T.Generic, T.Map, T.Struct, T.Union, T.Var
local BOOL, DOUBLE, NIL, INT, STR, TOP = T.BOOL, T.DOUBLE, T.NIL, T.INT, T.STR, T.TOP
local M = {}
-- TODO: Fix this.
M["print"] = Fn({TOP}, NIL)
M["comp_print"] = Fn({TOP}, NIL)
M["type"] = Fn({TOP}, STR)
-- TODO: Move to std.lua
M["map"] = Generic(
{Var("a"), Var("b")},
{
Fn({Var("a")}, Var("b"), true),
Array(Var("a"))
},
Array(Var("b"))
)
-- TODO: Move to std.lua
M["push"] = Generic(
{Var("a")},
{
Array(Var("a")),
Var("a")
},
NIL
)
M["string"] = Struct("string", {}, {
["sub"] = Fn({STR, INT, INT}, STR),
["lower"] = Fn({STR}, STR),
})
-- TODO: Fix later.
M["io"] = Struct("io", {}, {
["write"] = Fn({STR}, STR),
["read"] = Fn({}, Union({STR, NIL})),
})
-- TODO: Fix later.
M["tonumber"] = Fn({STR}, INT)
M["tostring"] = Fn({TOP}, STR)
return M