今天看xlua源码的时候发现了一个表 _G,如图所示:
那它到底啥呢?
应该是保存了lua所有用到的全局变量和局部变量
比如:
这三种用法是一样的
_G.print("测试")
_G["print"]("测试")
print("测试")
那里面到底有啥呢?
全部输出为:
function: 00007FFFFB9ECA60
setfenv function: 000001718A717510
rawset function: 00007FFFFB9EC6B0
_VERSION Lua 5.3
print function: 0000016E8893FC90
_G table: 000001718A716390
|--load function: 00007FFFFB9ECA60
|--setfenv function: 000001718A717510
|--rawset function: 00007FFFFB9EC6B0
|--_VERSION Lua 5.3
|--print function: 0000016E8893FC90
|--_G table: 000001718A716390
|--getmetatable function: 00007FFFFB9EC4B0
|--xpcall function: 00007FFFFB9EC0D0
|--tostring function: 00007FFFFB9EC190
|--rawequal function: 00007FFFFB9EC5B0
|--coroutine table: 000001718A7177D0
|--pcall function: 00007FFFFB9EC040
|--type function: 00007FFFFB9EC7E0
|--setmetatable function: 00007FFFFB9EC510
|--pairs function: 00007FFFFB9EC8A0
|--table table: 000001718A7179D0
|--io table: 000001718A717C90
|--tonumber function: 00007FFFFB9EC300
|--CS table: 000001718A717490
|--error function: 00007FFFFB9EC430
|--next function: 00007FFFFB9EC840
|--getfenv function: 000001718A717890
|--assert function: 00007FFFFB9EBF10
|--cast function: 0000016E88940AA0
|--typeof function: 00000171739A7190
|--math table: 000001718A717390
|--select function: 00007FFFFB9EBF90
|--debug table: 000001718A7175D0
|--uint64 table: 000001718A7171D0
|--string table: 000001718A717DD0
|--template table: 000001718A717B50
|--utf8 table: 000001718A717ED0
|--package table: 000001718A716E50
|--rawlen function: 00007FFFFB9EC600
|--xlua table: 000001718A717E50
|--loadfile function: 00007FFFFB9EC980
|--os table: 000001718A717450
|--dofile function: 00007FFFFB9EBE90
|--ipairs function: 00007FFFFB9EC930
|--collectgarbage function: 00007FFFFB9EC710
|--base function: 000001718A717550
|--rawget function: 00007FFFFB9EC660
|--require function: 000001718A717310
getmetatable function: 00007FFFFB9EC4B0
xpcall function: 00007FFFFB9EC0D0
tostring function: 00007FFFFB9EC190
rawequal function: 00007FFFFB9EC5B0
coroutine table: 000001718A7177D0
|--create function: 00007FFFFB9ECF40
|--resume function: 00007FFFFB9ECE90
|--isyieldable function: 00007FFFFB9ED120
|--wrap function: 00007FFFFB9ECFA0
|--yield function: 00007FFFFB9ED010
|--status function: 00007FFFFB9ED040
|--running function: 00007FFFFB9ED150
pcall function: 00007FFFFB9EC040
type function: 00007FFFFB9EC7E0
setmetatable function: 00007FFFFB9EC510
pairs function: 00007FFFFB9EC8A0
table table: 000001718A7179D0
|--sort function: 00007FFFFB9F58D0
|--remove function: 00007FFFFB9F5140
|--unpack function: 00007FFFFB9F57E0
|--move function: 00007FFFFB9F52C0
|--pack function: 00007FFFFB9F5730
|--insert function: 00007FFFFB9F4FB0
|--concat function: 00007FFFFB9F5510
io table: 000001718A717C90
|--open function: 00007FFFFB9EEC70
|--popen function: 00007FFFFB9EED50
|--stdout file (00007FFFFBA4A908)
|--lines function: 00007FFFFB9EE590
|--read function: 00007FFFFB9EE690
|--stdin file (00007FFFFBA4A8B0)
|--stderr file (00007FFFFBA4A960)
|--input function: 00007FFFFB9EEE80
|--close function: 00007FFFFB9EEBD0
|--write function: 00007FFFFB9EE760
|--type function: 00007FFFFB9EEA90
|--tmpfile function: 00007FFFFB9EEE00
|--output function: 00007FFFFB9EEF10
|--flush function: 00007FFFFB9EE9C0
tonumber function: 00007FFFFB9EC300
CS table: 000001718A717490
|--System table: 000001718A718D90
|--System.RuntimeType: -1546318608 table: 000001718A718050
error function: 00007FFFFB9EC430
next function: 00007FFFFB9EC840
getfenv function: 000001718A717890
assert function: 00007FFFFB9EBF10
cast function: 0000016E88940AA0
typeof function: 00000171739A7190
math table: 000001718A717390
|--sin function: 00007FFFFB9EFE80
|--sqrt function: 00007FFFFB9F02F0
|--huge inf
|--floor function: 00007FFFFB9F0030
|--ceil function: 00007FFFFB9F00B0
|--mininteger -9223372036854775808
|--tan function: 00007FFFFB9EFEE0
|--rad function: 00007FFFFB9F0480
|--pi 3.1415926535898
|--log function: 00007FFFFB9F0370
|--fmod function: 00007FFFFB9F0130
|--asin function: 00007FFFFB9EFF10
|--abs function: 00007FFFFB9EFE10
|--random function: 00007FFFFB9F05E0
|--deg function: 00007FFFFB9F0440
|--ult function: 00007FFFFB9F0320
|--atan function: 00007FFFFB9EFF70
|--modf function: 00007FFFFB9F0210
|--randomseed function: 00007FFFFB9F0710
|--maxinteger 9223372036854775807
|--cos function: 00007FFFFB9EFEB0
|--type function: 00007FFFFB9F0740
|--acos function: 00007FFFFB9EFF40
|--min function: 00007FFFFB9F04C0
|--tointeger function: 00007FFFFB9EFFD0
|--exp function: 00007FFFFB9F0410
|--max function: 00007FFFFB9F0550
select function: 00007FFFFB9EBF90
debug table: 000001718A7175D0
|--getmetatable function: 00007FFFFB9ED3A0
|--getlocal function: 00007FFFFB9ED8B0
|--traceback function: 00007FFFFB9EE390
|--setmetatable function: 00007FFFFB9ED3E0
|--setupvalue function: 00007FFFFB9EDBF0
|--getuservalue function: 00007FFFFB9ED440
|--upvalueid function: 00007FFFFB9EDC80
|--getregistry function: 00007FFFFB9ED380
|--getupvalue function: 00007FFFFB9EDB70
|--upvaluejoin function: 00007FFFFB9EDD00
|--setlocal function: 00007FFFFB9EDA20
|--sethook function: 00007FFFFB9EDE20
|--gethook function: 00007FFFFB9EE020
|--debug function: 00007FFFFB9EE1A0
|--getinfo function: 00007FFFFB9ED4D0
|--setuservalue function: 00007FFFFB9ED480
uint64 table: 000001718A7171D0
|--tostring function: 00007FFFFB9FF8E0
|--divide function: 00007FFFFB9FF7C0
|--remainder function: 00007FFFFB9FF870
|--parse function: 00007FFFFB9FF830
|--compare function: 00007FFFFB9FF760
string table: 000001718A717DD0
|--format function: 00007FFFFB9F1DF0
|--gmatch function: 00007FFFFB9F1B00
|--upper function: 00007FFFFB9F2570
|--gsub function: 00007FFFFB9F1BC0
|--find function: 00007FFFFB9F1AE0
|--byte function: 00007FFFFB9F2DF0
|--packsize function: 00007FFFFB9F1580
|--reverse function: 00007FFFFB9F23F0
|--len function: 00007FFFFB9F22E0
|--match function: 00007FFFFB9F1AF0
|--unpack function: 00007FFFFB9F1720
|--pack function: 00007FFFFB9F27D0
|--char function: 00007FFFFB9F13E0
|--lower function: 00007FFFFB9F24A0
|--sub function: 00007FFFFB9F2310
|--rep function: 00007FFFFB9F2640
|--dump function: 00007FFFFB9F14C0
template table: 000001718A717B50
|--execute function: 0000016E88940500
|--compile function: 0000016E8893FB50
utf8 table: 000001718A717ED0
|--offset function: 00007FFFFB9F64C0
|--char function: 00007FFFFB9F63A0
|--codes function: 00007FFFFB9F6640
|--charpattern [
网友评论