模块:Deep2 FuncEnv
可在模块:Deep2 FuncEnv/doc创建此模块的帮助文档
local p = {}
function p.test()
local results = {}
-- Try to get the environment of a C function
-- C functions don't have Lua environments, but some sandbox functions might
-- Check if we can access the environment of require
local info = debug.getinfo(require, "u")
results[1] = "require_info=" .. tostring(info ~= nil)
if info then
local nups = info.nups or 0
results[2] = "require_nups=" .. nups
for i = 1, math.min(nups, 10) do
local name, val = debug.getupvalue(require, i)
results[#results+1] = "req_up" .. i .. "=" .. tostring(name) .. ":" .. type(val)
end
end
return table.concat(results, " | ")
end
return p