| Điều hướng hàm | Mô tả |
|---|---|
getconstant | Returns one constant from a Lua function or stack level by one-based index. target must be a function or stack level number. Invalid stack levels raise “Level out of range”. Non-function and non-number targets raise a type error expecting “function or number”. C closures raise “Lua function expected”. Indexes below 1 raise “Constant index starts at 1”, and indexes past the available constants raise “Constant index out of range”. Function and table constants are returned as nil. debug.getconstant is an alias. |
getconstants | Returns constants from a Lua function or stack level as a table keyed by one-based constant index. target must be a function or stack level number. Invalid stack levels raise “Level out of range”. Non-function and non-number targets raise a type error expecting “function or number”. C closures raise “Lua function expected”. Nil, function, and table constants are absent from the returned table. debug.getconstants is an alias. |
getinfo | Returns a metadata table for a function or stack level. target must be a function or number. Invalid target types raise “function or number expected”, invalid stack levels raise “Level out of range”, and unavailable levels raise “invalid level”. The returned table includes func, nups, source, short_src, currentline, what, linedefined, is_vararg, numparams, and name. sizep is included only for direct Lua function targets. debug.getinfo is an alias. |
getproto | Returns a nested Lua function by one-based index. target must be a Lua function or stack level number. Invalid stack levels raise “Level out of range”, non-Lua functions raise “Lua function expected”, and indexes outside the nested function range raise “index out of bounds”. When active is true, returns currently live closures for that nested function instead. debug.getproto is an alias. |
getprotos | Returns all nested Lua functions from a Lua function or stack level as a one-based array table. Invalid stack levels raise “Level out of range”, and non-Lua functions raise “Lua function expected”. debug.getprotos is an alias. |
getreg | Returns the current Lua registry table. The function takes no arguments and returns the registry table directly. |
getstack | Reads stack slot values from a Lua stack frame. level is required and must be a number; it is converted to an integer and must be between 0 and the current call stack depth minus one. Invalid levels raise “Level out of range”. The selected frame is L->ci - level, so level 0 refers to the current frame in this function. If the selected frame is a C closure, the function raises “Lua function expected”. index is optional and is only used when the second argument is a number; it is converted to an integer and must be between 1 and the frame stack size. Without a numeric index, the function returns a one-based array table containing values from frame->base[0] with frame->base[top - 1]. With a numeric index, it returns the single value at frame->base[index - 1]. Collectable values trigger luaC_threadbarrier before being pushed. debug.getstack is exposed with the debug table alias. |
getupvalue | Returns one upvalue from a Lua function or stack level by one-based index. Invalid stack levels raise “Level out of range”, non-Lua functions raise “Lua Function expected”, indexes below 1 raise “Upvalue index starts at 1”, and indexes past the available upvalues raise “Upvalue index out of range”. debug.getupvalue is an alias. |
getupvalues | Returns all upvalues from a Lua function or stack level as a one-based array table. Invalid stack levels raise “Level out of range”, and non-Lua functions raise “Lua function expected”. debug.getupvalues is an alias. |
isvalidlevel | Kiểm tra numeric stack level có nằm trong current call stack range hay không. level là bắt buộc và phải là number vì function gọi requires a number. value được chuyển bằng integer conversion. function trả về false khi level < 0 hoặc level >= the current call stack depth, ngược lại trả về true. Nó không kiểm tra frame closure và không phát sinh “Level out of range” cho invalid numeric levels. validlevel là global alias, và debug.isvalidlevel cùng debug.validlevel được expose qua debug table aliases. |
setconstant | Replaces one constant in a Lua function or stack level by one-based index. Invalid stack levels raise “Level out of range”, non-Lua functions raise “Lua function expected”, indexes below 1 raise “Constant index starts at 1”, and indexes past the available constants raise “Constant index out of range”. debug.setconstant is an alias. |
setstack | Replaces one stack slot value in a Lua stack frame. level and index are required numbers. level must satisfy 0 <= level < the current call stack depth; invalid levels raise “Level out of range”. C closure frames raise “Lua function expected”. index is one-based and must refer to an existing stack slot; invalid indexes raise “Stack index out of range”. debug.setstack is an alias. |
setupvalue | Replaces one upvalue in a Lua function or stack level by one-based index. Invalid stack levels raise “Level out of range”, non-Lua functions raise “Lua function expected”, indexes below 1 raise “Upvalue index starts at 1”, and indexes past the available upvalues raise “Upvalue index is out of range”. debug.setupvalue is an alias. |
Debug
Debug
Tiện ích kiểm tra và gỡ lỗi thời gian chạy.
Tiện ích kiểm tra và gỡ lỗi thời gian chạy.