summaryrefslogtreecommitdiff
path: root/meta/template/debug.lua
blob: 87f9c1182b6178c8c529b8c6eb4e2fe97085a459 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---@meta

---@class debug*
debug = {}

---@class debuginfo
---@field name            string
---@field namewhat        string
---@field source          string
---@field short_src       string
---@field linedefined     integer
---@field lastlinedefined integer
---@field what            string
---@field currentline     integer
---@field istailcall      boolean
---@field nups            integer
---@field nparams         integer
---@field isvararg        boolean
---@field func            function
---@field ftransfer       integer
---@field ntransfer       integer
---@field activelines     table

function debug.debug() end

---@param o any
---@return table
function debug.getfenv(o) end

---@param co thread?
---@return function hook
---@return string mask
---@return integer count
function debug.gethook(co) end

---@alias infowhat string
---|+'"n"' # `name` 和 `namewhat`
---|+'"S"' # `source`,`short_src`,`linedefined`,`lalinedefined`,和 `what`
---|+'"l"' # `currentline`
---|+'"t"' # `istailcall`
---|+'"u"' # `nups`,`nparams` 和 `isvararg`
---|+'"f"' # `func`
---|+'"r"' # `ftransfer` 和 `ntransfer`
---|+'"L"' # `activelines`

---@overload fun(f: integer|function, what: infowhat?):debuginfo
---@param thread thread
---@param f integer|function
---@param what infowhat?
---@return debuginfo
function debug.getinfo(thread, f, what) end

---@overload fun(f: integer|function, index: integer):string, any
---@param thread thread
---@param f integer|function
---@param index integer
---@return string name
---@return any value
function debug.getlocal(thread, f, index) end

---@param object any
---@return table metatable
function debug.getmetatable(object) end

---@return table
function debug.getregistry() end

---@param f integer|function
---@param up integer
---@return string name
---@return any value
function debug.getupvalue(f, up) end

---@param u userdata
---@param n integer
---@return any
---@return boolean
function debug.getuservalue(u, n) end

---@deprecated
---@param limit integer
---@return integer|boolean
function debug.setcstacklimit(limit) end

---@generic T
---@param object T
---@param env table
---@return T object
function debug.setfenv(object, env) end

---@alias hookmask string
---|+'"c"'
---|+'"r"'
---|+'"l"'

---@overload fun(hook: function, mask: hookmask, count: integer?)
---@param thread thread
---@param hook function
---@param mask hookmask
---@param count integer?
function debug.sethook(thread, hook, mask, count) end

---@overload fun(level: integer, index: integer, value: any):string
---@param thread thread
---@param level integer
---@param index integer
---@param value any
---@return string name
function debug.setlocal(thread, level, index, value) end

---@generic T
---@param value T
---@param meta table
---@return T value
function debug.setmetatable(value, meta) end

---@param f function
---@param up integer
---@param value any
---@return string name
function debug.setupvalue(f, up, value) end

---@param udata userdata
---@param value any
---@param n integer
---@return userdata udata
function debug.setuservalue(udata, value, n) end

---@param thread thread
---@param message any?
---@param level integer?
---@return string message
function debug.traceback(thread, message, level) end

---@param f function
---@param n integer
---@return lightuserdata id
function debug.upvalueid(f, n) end

---@param f1 function
---@param n1 integer
---@param f2 function
---@param n2 integer
function debug.upvaluejoin(f1, n1, f2, n2) end

return debug