Skip to content

Commit a27fe75

Browse files
committed
improve some type definitions
1 parent 5476bc2 commit a27fe75

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

nattlua/definitions/lua/jit.nlua

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ type jit_attach_texit = function=(
2020
ngpr: number, -- the number of general-purpose and floating point registers that are active at the exit
2121
nfpr: number -- the number of general-purpose and floating point registers that are active at the exit
2222
)>(nil)
23+
type jit_util_funcinfo = {
24+
linedefined = number,
25+
lastlinedefined = number,
26+
params = number,
27+
stackslots = number,
28+
upvalues = number,
29+
bytecodes = number,
30+
gcconsts = number,
31+
nconsts = number,
32+
children = boolean,
33+
currentline = number,
34+
isvararg = boolean,
35+
source = string,
36+
loc = string,
37+
ffid = nil | number,
38+
addr = nil | number,
39+
}
2340
type Modules["jit.dis_x86"] = {}
2441
type Modules["jit.dis_x64"] = {}
2542
type Modules["jit.dis_arm"] = {}
@@ -33,9 +50,9 @@ type Modules["jit.opt"] = {
3350
start = function=(...string)>(nil),
3451
}
3552
type jit = {
53+
attach = (function=(jit_attach_bc, "bc")>(nil) | function=(jit_attach_trace, "trace")>(nil) | function=(jit_attach_record, "record")>(nil) | function=(jit_attach_texit, "texit")>(nil) | function=(Function, nil | "bc" | "trace" | "record" | "texit")>(nil)),
3654
os = "Windows" | "Linux" | "OSX" | "BSD" | "POSIX" | "Other",
3755
arch = "x86" | "x64" | "arm" | "arm64" | "ppc" | "mips" | "mips64" | "mips64el" | "riscv64",
38-
attach = (function=(jit_attach_bc, "bc")>(nil) | function=(jit_attach_trace, "trace")>(nil) | function=(jit_attach_record, "record")>(nil) | function=(jit_attach_texit, "texit")>(nil) | function=(Function, nil | "bc" | "trace" | "record" | "texit")>(nil)),
3956
tracebarrier = function=()>(nil),
4057
version_num = number,
4158
version = string,
@@ -63,25 +80,7 @@ type Modules["jit.profile"] = {
6380
}
6481
type Modules["jit.util"] = {
6582
-- Retrieves LuaJIT information about a given function, similarly to debug.getinfo
66-
funcinfo = function=(Function, position: number | nil)>(
67-
{
68-
linedefined = number,
69-
lastlinedefined = number,
70-
params = number,
71-
stackslots = number,
72-
upvalues = number,
73-
bytecodes = number,
74-
gcconsts = number,
75-
nconsts = number,
76-
children = boolean,
77-
currentline = number,
78-
isvararg = boolean,
79-
source = string,
80-
loc = string,
81-
ffid = nil | number,
82-
addr = nil | number,
83-
}
84-
),
83+
funcinfo = function=(Function, position: number | nil)>(jit_util_funcinfo),
8584
-- Get bytecode instruction at given position
8685
funcbc = function=(func: Function, pc: number)>(number, number), -- returns (ins, m)
8786
-- Get upvalue name for function
@@ -110,4 +109,4 @@ type Modules["jit.util"] = {
110109
ircalladdr = function=(index: number)>(number),
111110
-- Get trace machine code
112111
tracemc = function=(tr: number)>(string, number, number), -- returns (mcode, addr, loop)
113-
}
112+
}

nattlua/definitions/lua/table.nlua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ type Modules["table.clear"] = function=(Table)>()
44

55
do -- Basic table manipulation functions
66
analyzer function table.concat(tbl: List<|string|>, separator: string | nil)
7+
if tbl.Type == "any" then return types.String() end
8+
79
return tbl:Concat(separator)
810
end
911

0 commit comments

Comments
 (0)