返回介绍

debug.getinfo ([thread,] function [, what])

发布于 2019-08-25 13:17:03 字数 1279 浏览 1146 评论 0 收藏 0

Returns a table with information about a function.
You can give the function directly,
or you can give a number as the value of function,
which means the function running at level function of the call stack
of the given thread:
level 0 is the current function (getinfo itself);
level 1 is the function that called getinfo;
and so on.
If function is a number larger than the number of active functions,
then getinfo returns nil.

The returned table may 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.

For instance, the expression debug.getinfo(1,"n").name returns
a name of the current function, if a reasonable name can be found,
and debug.getinfo(print) returns a table with all available information
about the print function.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文