You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Starts or continues the execution of coroutine co. The first time you resume a coroutine, it starts running its body. The values val1, ... are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values val1, ... are passed as the results from the yield.
17
+
* Starts or continues the execution of coroutine co. The first time you
18
+
* resume a coroutine, it starts running its body. The values val1, ... are
19
+
* passed as the arguments to the body function. If the coroutine has yielded,
20
+
* resume restarts it; the values val1, ... are passed as the results from the
21
+
* yield.
16
22
*
17
-
* If the coroutine runs without any errors, resume returns true plus any values passed to yield (when the coroutine yields) or any values returned by the body function (when the coroutine terminates). If there is any error, resume returns false plus the error message.
23
+
* If the coroutine runs without any errors, resume returns true plus any
24
+
* values passed to yield (when the coroutine yields) or any values returned
25
+
* by the body function (when the coroutine terminates). If there is any
26
+
* error, resume returns false plus the error message.
* Returns the status of coroutine co, as a string: "running", if the coroutine is running (that is, it called status); "suspended", if the coroutine is suspended in a call to yield, or if it has not started running yet; "normal" if the coroutine is active but not running (that is, it has resumed another coroutine); and "dead" if the coroutine has finished its body function, or if it has stopped with an error.
32
+
* Returns the status of coroutine co, as a string: "running", if the
33
+
* coroutine is running (that is, it called status); "suspended", if the
34
+
* coroutine is suspended in a call to yield, or if it has not started running
35
+
* yet; "normal" if the coroutine is active but not running (that is, it has
36
+
* resumed another coroutine); and "dead" if the coroutine has finished its
37
+
* body function, or if it has stopped with an error.
* Creates a new coroutine, with body f. f must be a function. Returns a function that resumes the coroutine each time it is called. Any arguments passed to the function behave as the extra arguments to resume. Returns the same values returned by resume, except the first boolean. In case of error, propagates the error.
42
+
* Creates a new coroutine, with body f. f must be a function. Returns a
43
+
* function that resumes the coroutine each time it is called. Any arguments
44
+
* passed to the function behave as the extra arguments to resume. Returns the
45
+
* same values returned by resume, except the first boolean. In case of error,
Copy file name to clipboardExpand all lines: core/debug.d.ts
+81-22Lines changed: 81 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -3,20 +3,35 @@
3
3
/** @noSelfInFile */
4
4
5
5
/**
6
-
* This library provides the functionality of the debug interface (§4.9) to Lua programs. You should exert care when using this library. Several of its functions violate basic assumptions about Lua code (e.g., that variables local to a function cannot be accessed from outside; that userdata metatables cannot be changed by Lua code; that Lua programs do not crash) and therefore can compromise otherwise secure code. Moreover, some functions in this library may be slow.
6
+
* This library provides the functionality of the debug interface (§4.9) to Lua
7
+
* programs. You should exert care when using this library. Several of its
8
+
* functions violate basic assumptions about Lua code (e.g., that variables
9
+
* local to a function cannot be accessed from outside; that userdata metatables
10
+
* cannot be changed by Lua code; that Lua programs do not crash) and therefore
11
+
* can compromise otherwise secure code. Moreover, some functions in this
12
+
* library may be slow.
7
13
*
8
-
* All functions in this library are provided inside the debug table. All functions that operate over a thread have an optional first argument which is the thread to operate over. The default is always the current thread.
14
+
* All functions in this library are provided inside the debug table. All
15
+
* functions that operate over a thread have an optional first argument which is
16
+
* the thread to operate over. The default is always the current thread.
9
17
*/
10
18
declarenamespacedebug{
11
19
/**
12
-
* Enters an interactive mode with the user, running each string that the user enters. Using simple commands and other debug facilities, the user can inspect global and local variables, change their values, evaluate expressions, and so on. A line containing only the word cont finishes this function, so that the caller continues its execution.
20
+
* Enters an interactive mode with the user, running each string that the user
21
+
* enters. Using simple commands and other debug facilities, the user can
22
+
* inspect global and local variables, change their values, evaluate
23
+
* expressions, and so on. A line containing only the word cont finishes this
24
+
* function, so that the caller continues its execution.
13
25
*
14
-
* Note that commands for debug.debug are not lexically nested within any function and so have no direct access to local variables.
26
+
* Note that commands for debug.debug are not lexically nested within any
27
+
* function and so have no direct access to local variables.
15
28
*/
16
29
functiondebug(): void;
17
30
18
31
/**
19
-
* Returns the current hook settings of the thread, as three values: the current hook function, the current hook mask, and the current hook count (as set by the debug.sethook function).
32
+
* Returns the current hook settings of the thread, as three values: the
33
+
* current hook function, the current hook mask, and the current hook count
* What the `name` field means. The empty string means that Lua did not find a name for the function.
50
+
* What the `name` field means. The empty string means that Lua did not find
51
+
* a name for the function.
36
52
*/
37
53
namewhat: 'global'|'local'|'method'|'field'|'';
38
54
39
55
source: string;
40
56
/**
41
-
* A short version of source (up to 60 characters), useful for error messages.
57
+
* A short version of source (up to 60 characters), useful for error
58
+
* messages.
42
59
*/
43
60
short_src: string;
44
61
linedefined: number;
@@ -57,11 +74,25 @@ declare namespace debug {
57
74
}
58
75
59
76
/**
60
-
* Returns a table with information about a function. You can give the function directly or you can give a number as the value of f, which means the function running at level f of the call stack of the given thread: level 0 is the current function (getinfo itself); level 1 is the function that called getinfo (except for tail calls, which do not count on the stack); and so on. If f is a number larger than the number of active functions, then getinfo returns nil.
77
+
* Returns a table with information about a function. You can give the
78
+
* function directly or you can give a number as the value of f, which means
79
+
* the function running at level f of the call stack of the given thread:
80
+
* level 0 is the current function (getinfo itself); level 1 is the function
81
+
* that called getinfo (except for tail calls, which do not count on the
82
+
* stack); and so on. If f is a number larger than the number of active
83
+
* functions, then getinfo returns nil.
61
84
*
62
-
* The returned table can contain all the fields returned by lua_getinfo, with the string what describing which fields to fill in. The default for what is to get all information available, except the table of valid lines. If present, the option 'f' adds a field named func with the function itself. If present, the option 'L' adds a field named activelines with the table of valid lines.
85
+
* The returned table can contain all the fields returned by lua_getinfo, with
86
+
* the string what describing which fields to fill in. The default for what is
87
+
* to get all information available, except the table of valid lines. If
88
+
* present, the option 'f' adds a field named func with the function itself.
89
+
* If present, the option 'L' adds a field named activelines with the table of
90
+
* valid lines.
63
91
*
64
-
* For instance, the expression debug.getinfo(1,"n").name returns a name for the current function, if a reasonable name can be found, and the expression debug.getinfo(print) returns a table with all available information about the print function.
92
+
* For instance, the expression debug.getinfo(1,"n").name returns a name for
93
+
* the current function, if a reasonable name can be found, and the expression
94
+
* debug.getinfo(print) returns a table with all available information about
* This function returns the name and the value of the upvalue with index up of the function f. The function returns nil if there is no upvalue with the given index.
122
+
* This function returns the name and the value of the upvalue with index up
123
+
* of the function f. The function returns nil if there is no upvalue with the
124
+
* given index.
91
125
*
92
-
* Variable names starting with '(' (open parenthesis) represent variables with no known names (variables from chunks saved without debug information).
126
+
* Variable names starting with '(' (open parenthesis) represent variables
127
+
* with no known names (variables from chunks saved without debug
* Returns the Lua value associated to u. If u is not a full userdata, returns nil.
134
+
* Returns the Lua value associated to u. If u is not a full userdata, returns
135
+
* nil.
99
136
*/
100
137
functiongetuservalue(u: LuaUserdata): any;
101
138
102
139
/**
103
-
* Sets the given function as a hook. The string mask and the number count describe when the hook will be called. The string mask may have any combination of the following characters, with the given meaning:
140
+
* Sets the given function as a hook. The string mask and the number count
141
+
* describe when the hook will be called. The string mask may have any
142
+
* combination of the following characters, with the given meaning:
104
143
*
105
144
* * 'c': the hook is called every time Lua calls a function;
106
145
* * 'r': the hook is called every time Lua returns from a function;
107
146
* * 'l': the hook is called every time Lua enters a new line of code.
108
147
*
109
-
* Moreover, with a count different from zero, the hook is called also after every count instructions.
148
+
* Moreover, with a count different from zero, the hook is called also after
149
+
* every count instructions.
110
150
*
111
151
* When called without arguments, debug.sethook turns off the hook.
112
152
*
113
-
* When the hook is called, its first parameter is a string describing the event that has triggered its call: "call" (or "tail call"), "return", "line", and "count". For line events, the hook also gets the new line number as its second parameter. Inside a hook, you can call getinfo with level 2 to get more information about the running function (level 0 is the getinfo function, and level 1 is the hook function).
153
+
* When the hook is called, its first parameter is a string describing the
154
+
* event that has triggered its call: "call" (or "tail call"), "return",
155
+
* "line", and "count". For line events, the hook also gets the new line
156
+
* number as its second parameter. Inside a hook, you can call getinfo with
157
+
* level 2 to get more information about the running function (level 0 is the
158
+
* getinfo function, and level 1 is the hook function).
114
159
*/
115
160
functionsethook(): void;
116
161
functionsethook(
@@ -126,7 +171,12 @@ declare namespace debug {
126
171
): void;
127
172
128
173
/**
129
-
* This function assigns the value value to the local variable with index local of the function at level level of the stack. The function returns nil if there is no local variable with the given index, and raises an error when called with a level out of range. (You can call getinfo to check whether the level is valid.) Otherwise, it returns the name of the local variable.
174
+
* This function assigns the value value to the local variable with index
175
+
* local of the function at level level of the stack. The function returns nil
176
+
* if there is no local variable with the given index, and raises an error
177
+
* when called with a level out of range. (You can call getinfo to check
178
+
* whether the level is valid.) Otherwise, it returns the name of the local
179
+
* variable.
130
180
*
131
181
* See debug.getlocal for more information about variable indices and names.
132
182
*/
@@ -139,24 +189,33 @@ declare namespace debug {
139
189
): string|undefined;
140
190
141
191
/**
142
-
* Sets the metatable for the given value to the given table (which can be nil). Returns value.
192
+
* Sets the metatable for the given value to the given table (which can be
* This function assigns the value value to the upvalue with index up of the function f. The function returns nil if there is no upvalue with the given index. Otherwise, it returns the name of the upvalue.
198
+
* This function assigns the value value to the upvalue with index up of the
199
+
* function f. The function returns nil if there is no upvalue with the given
200
+
* index. Otherwise, it returns the name of the upvalue.
* If message is present but is neither a string nor nil, this function returns message without further processing. Otherwise, it returns a string with a traceback of the call stack. The optional message string is appended at the beginning of the traceback. An optional level number tells at which level to start the traceback (default is 1, the function calling traceback).
213
+
* If message is present but is neither a string nor nil, this function
214
+
* returns message without further processing. Otherwise, it returns a string
215
+
* with a traceback of the call stack. The optional message string is appended
216
+
* at the beginning of the traceback. An optional level number tells at which
217
+
* level to start the traceback (default is 1, the function calling
0 commit comments