当前位置: 首页 > news >正文

教科院网站建设/新河seo怎么做整站排名

教科院网站建设,新河seo怎么做整站排名,怎么做属于自己的售卡网站,推广网站联盟lua debug调试 debug 调试 相关函数 # debug.debug():调试模式 命令行进入调试模式,可调试函数、表达式等,输入cont退出debug模式# debug.gethook(optional thread) 返回三个表示线程钩子设置的值: 当前钩子函数,当前…

lua debug调试

        

                      

                               

debug 调试

      

相关函数

# debug.debug():调试模式
命令行进入调试模式,可调试函数、表达式等,输入cont退出debug模式# debug.gethook(optional thread)
返回三个表示线程钩子设置的值: 当前钩子函数,当前钩子掩码,当前钩子计数# debug.getinfo([thread,] f [, what]): 返回函数的表信息 
f:函数、或者用一个数字f表示
数字f(f可为任意数字)表示运行在指定线程的调用栈对应层次上的函数: 
0层表示当前函数(getinfo 自身); 
1层表示调用 getinfo 的函数 (除非是尾调用,这种情况不计入栈);
如果f是一个比活动函数数量还大的数字, getinfo返回 nil# debug.getmetatable(value):返回给定对象的元表,如果不存在返回nil
Returns the metatable of the given value 
or nil if it does not have a metatable.# debug.getregistry():返回注册表
Returns the registry table# debug.getuservalue(u, n):获取第n个user值,还有boolean值,找到返回true,没找到返回false
Returns the n-th user value associated to the userdata u plus a boolean, 
false if the userdata does not have that value. # debug.sethook ([thread,] hook, mask [, count]):将一个函数作为钩子函数设入
字符串 mask 以及数字 count 决定了钩子将在何时调用,mask可选值:'c': 每当 Lua 调用一个函数时,调用钩子'r': 每当 Lua 从一个函数内返回时,调用钩子'l': 每当 Lua 进入新的一行时,调用钩子# debug.setlocal ([thread,] level, local, value):
将value赋给栈上第level层函数的第local个局部变量
如果没有那个变量,函数返回nil
如果level越界,抛出一个错误# debug.setmetatable (value, table):将value的元表设为 table(可以是 nil),返回value
Sets the metatable for the given value to the given table 
(which can be nil). Returns value. # debug.setuservalue (udata, value, n):设置用户自定义变量的第n个值为value
Sets the given value as the n-th user value associated to the given udata. 
udata must be a full userdata.
Returns udata, or fail if the userdata does not have that value# debug.traceback ([thread,] [message [, level]])
如果有message,且不是字符串或nil,函数不做任何处理直接返回message,否则返回调用栈的栈回溯信息
message如果是字符串,会被添加在栈回溯信息的开头
level(可选)指明从栈的哪一层开始回溯(默认为 1 ,即调用 traceback 的那里)# debug.upvalueid (f, n):从给定函数中返回第n个upvalue的标识符
Returns a unique identifier (as a light userdata) for the 
upvalue numbered n from the given function. # debug.upvaluejoin (f1, n1, f2, n2)
Make the n1-th upvalue of the Lua closure f1 
refer to the n2-th upvalue of the Lua closure f2. 

       

debug.getlocal([thread,] f, local):获取函数内部设置的局部变量

This function returns the name and the value of the local 
variable with index local of the function at level f of the 
stack. This function accesses not only explicit local variables, 
but also parameters and temporary values.
* 返回索引为local的局部变量的name、value
* 该函数可获取局部变量、参数、临时变量The first parameter or local variable has index 1, and so on, 
following the order that they are declared in the code, counting 
only the variables that are active in the current scope of the function. 
* 第一个局部变量的索引为1Compile-time constants may not appear in this listing, if they were 
optimized away by the compiler. Negative indices refer to vararg arguments; 
-1 is the first vararg argument. 
* 负数表示参数:-1表示第一个参数The function returns fail if there is no variable with the given index, 
and raises an error when called with a level out of range. (You can call 
debug.getinfo to check whether the level is valid.)
* 如果没有对应的局部变量,会报错Variable names starting with '(' (open parenthesis) represent variables with no 
known names (internal variables such as loop control variables, and variables from 
chunks saved without debug information).
* 以"("开头的变量名表示没有显示的名称The parameter f may also be a function. In that case, getlocal returns only the 
name of function parameters. 
* f可以是函数,表示获取指定函数的参数

          

debug.setlocal( [thread,] level, local, value ):设置函数的内部局部变量、调用该函数的函数的局部变量

This function assigns the value value to the local variable 
with index local of the function at level level of the stack. 
* 设置函数的局部变量,local为索引,level为所在函数的栈The function returns fail 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. 
* 如果没有对应的局部变量,会报错

           

debug.getupvalue(f, up):返回函数使用的外部局部变量,索引up表示第几个外部变量

This function returns the name and the value of the 
upvalue with index up of the function f. The function 
returns fail if there is no upvalue with the given index.
* 返回指定函数f的索引为up的upvalue(外部变量)的name、value
* 如果没有返回nilFor Lua functions, upvalues are the external local variables 
that the function uses, and that are consequently included 
in its closure.
* 如果是lua函数,upvalues是函数使用的外部局部变量For C functions, this function uses the empty string "" 
as a name for all upvalues.
* 如果是c函数,所有upvalue的name都是""Variable name '?' (interrogation mark) represents variables 
with no known names (variables from chunks saved without 
debug information). 
* ?表示变量没有显示的名称

        

debug.setupvalue(f, up, value):设置函数第up个外部变量的值

This function assigns the value value to the upvalue with index up of the 
function f. The function returns fail if there is no upvalue with the given 
index. Otherwise, it returns the name of the upvalue. 
* 设置函数第up个外部局部变量的value,设置成功返回该局部变量的name
* 如果没有该变量,返回nil

        

                          

                               

使用示例

      

示例:debug命令行调试

Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
-- 进入命令行调试模式
> debug.debug()-- 自定义函数
lua_debug> function fun(a,b) print(a+b) end-- 调试函数:fun(1)
lua_debug> fun(1)
(debug command):1: attempt to perform arithmetic on a nil value (local 'b')-- 调试函数:fun(1,2)
lua_debug> fun(1,2)
3-- 退出命令行调试模式
lua_debug> cont

         

示例:traceback

-- debug脚本
huli@hudeMacBook-Pro lua % cat debug.lua
function fun()print(debug.traceback("traceback ==> "))
endfun()-- 运行脚本
huli@hudeMacBook-Pro lua % lua debug.lua
traceback ==> 
stack traceback:debug.lua:2: in function 'fun'debug.lua:5: in main chunk[C]: in ?

           

示例:getinfo

huli@hudeMacBook-Pro lua % cat debug.lua
-- 自定义的函数
function fun()i=0j=0print(i,j)
end-- 获取函数信息
for key,value in pairs(debug.getinfo(fun)) do print(key,value)
end-- 执行脚本
huli@hudeMacBook-Pro lua % lua debug.lua
func	function: 0x600002b08cf0
short_src	de.lua
namewhat	
nups	1
currentline	-1
istailcall	false
ntransfer	0
isvararg	false
nparams	0
ftransfer	0
lastlinedefined	5
linedefined	1
source	@de.lua
what	Lua

        

示例:getupvalue、setupvalue

-- lua脚本
huli@hudeMacBook-Pro lua % cat debug.lua
-- 外部局部变量(非局部变量debug.getupvalue不会读取)
local i=0
local j=0function fun()i=i+1j=j+1print(i,j)
end-- 读取函数fun使用的外部局部变量
print(debug.getupvalue(fun,1))
print(debug.getupvalue(fun,2))-- 执行函数
fun()-- 读取函数fun使用的外部局部变量
print(debug.getupvalue(fun,1))
print(debug.getupvalue(fun,2))-- 设置函数fun使用的外部局部变量
debug.setupvalue(fun,1,10)
debug.setupvalue(fun,2,10)-- 执行函数
fun()-- 执行脚本
huli@hudeMacBook-Pro lua % lua debug.lua
i	0
j	0
1	1
i	1
j	1
11	11

       

示例:upvalueid

-- upvalueid 脚本
huli@hudeMacBook-Pro lua % cat debug.lua
local i=0
local j=0function fun()i=i+1j=j+1print(i,j)
endprint(debug.upvalueid(fun,1))
print(debug.upvalueid(fun,2))-- 执行脚本,返回userdata数据
huli@hudeMacBook-Pro lua % lua debug.lua
userdata: 0x600000ed8d20
userdata: 0x600000ed8d50

         

示例:getlocal、setlocal

huli@hudeMacBook-Pro lua % cat debug.lua
local a=0
local b=0print("主函数局部变量debug前")
print('a',a)
print('b',b)function fun()local i=0local j=0print("\n函数局部变量debug前")print("debug.getlocal(1,1)", debug.getlocal(1, 1))print("debug.getlocal(1,2)", debug.getlocal(1, 2))debug.setlocal(1,1,1)    --设置1层(fun函数)的局部变量,index=1的局部变量值为4debug.setlocal(1,2,2)    --设置1层(fun函数)的局部变量,index=1的局部变量值为4debug.setlocal(2,1,3)    --设置2层(调用fun函数的main函数)的局部变量,index=1的局部变量值为4debug.setlocal(2,2,4)    --设置2层调用fun函数的main函数)的局部变量,index=2的局部变量值为4print("\n函数局部变量debug后:")print("debug.getlocal(1,1)", debug.getlocal(1,1))print("debug.getlocal(1,2)", debug.getlocal(1,2))
endprint()
--print(debug.setlocal(2,1,1))
--print(debug.setlocal(2,2,2))fun()print("\n主函数局部变量debug后")
print("a",a)
print("b",b)-- 执行脚本
huli@hudeMacBook-Pro lua % lua debug.lua
主函数局部变量debug前
a	0
b	0函数局部变量debug前
debug.getlocal(1,1)	i	0
debug.getlocal(1,2)	j	0函数局部变量debug后:
debug.getlocal(1,1)	i	1
debug.getlocal(1,2)	j	2主函数局部变量debug后
a	3
b	4

             

                         

http://www.lbrq.cn/news/1471591.html

相关文章:

  • discuz可以做公司网站/哪些网站可以发广告
  • 常州云之家网站建设网络公司怎么样/百度推广代理商名单
  • 建设购物网站多少钱/个人网页设计
  • wordpress后台html/燃灯seo
  • 如何查看网站空间商/优化设计的答案
  • 提供家居企业网站建设/专门做网站的公司
  • 国外做糖网站/百度一下的网址
  • 关注网站怎么做/外包网
  • 网站建设艾瑞市场分析/阿里指数网站
  • 如何域名解析网站建设/2345网址导航主页
  • uc投放广告网站要自己做吗/深圳关键词推广优化
  • 上海网站建设 微信开发公司/电脑优化大师
  • 做网站必须有主机吗/google搜索优化
  • 青岛网站制作公司/在线客服系统
  • 搜索引擎优化的英文缩写是什么/运城seo
  • 中山外贸营销网站建设/网店产品seo如何优化
  • 明星网站怎么设计/绍兴百度seo
  • 深圳网站设计有哪些/大数据是干什么的
  • 微店网站链接怎么做/女孩子做运营是不是压力很大
  • wordpress下载站主题/seo实战培训
  • 沈阳网站建设三好街/快手推广网站
  • 洪梅镇仿做网站/杭州10大软件开发公司
  • 浏览器怎么打开网站服务器设置/杭州网站外包
  • 信誉好的镇江网站建设/如何优化搜索关键词
  • 全国送花网站/如何在百度免费发布广告
  • 插画师个人网站是怎么做的/跨界营销案例
  • 在百度云上做网站/河南做网站的
  • 网站关键词排名怎么做/html期末大作业个人网站制作
  • 织梦wap手机网站模板/引擎优化是什么意思
  • 网站支付功能怎么做/抖音关键词优化排名
  • Google机器学习基础(语言模型)
  • Django模型查询与性能调优:告别N+1问题
  • 登录校验一
  • Redis深度剖析:从基础到实战(上)
  • Coze开源版本地部署指南
  • node.js之Koa框架