This commit is contained in:
2020-11-15 16:49:42 -05:00
parent a784f12aed
commit f690fb147b
12 changed files with 431 additions and 168 deletions

View File

@@ -28,12 +28,12 @@
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--
local inspect = class('inspect')
local inspect = {}
local tostring = tostring
inspect.KEY = setmetatable({}, {__tostring = function() return 'inspect.KEY' end})
inspect.METATABLE = setmetatable({}, {__tostring = function() return 'inspect.METATABLE' end})
inspect.KEY = {}
inspect.METATABLE = {}
local function rawpairs(t)
return next, t, nil
@@ -236,8 +236,10 @@ function Inspector:putKey(k)
end
function Inspector:putTable(t)
if t == inspect.KEY or t == inspect.METATABLE then
self:puts(tostring(t))
if t == inspect.KEY then
self:puts("inspect.KEY")
elseif t == inspect.METATABLE then
self:puts("inspect.METATABLE")
elseif self:alreadyVisited(t) then
self:puts('<table ', self:getId(t), '>')
elseif self.level >= self.depth then
@@ -331,5 +333,12 @@ function inspect.inspect(root, options)
return table.concat(inspector.buffer)
end
_G.inspect = inspect.inspect
function inspect.iprint(...)
local n = select("#", ...)
for i = 1,n do
local v = select(i, ...)
print(inspect.inspect(v))
end
end
_G.iprint = inspect.iprint