|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- http://angg.twu.net/LUA/Prosody1.lua.html
-- http://angg.twu.net/LUA/Prosody1.lua
-- (find-angg "LUA/Prosody1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/GetInfo2.lua"))
-- (defun p () (interactive) (find-angg "LUA/Prosody1.lua"))
-- Test: (find-angg "LUA/DGetInfo1.lua" "DGetInfos-tests")
-- «.Prosody» (to "Prosody")
-- «.Prosody-tests» (to "Prosody-tests")
-- «Prosody» (to ".Prosody")
-- Adapted from (the middle part of) the traceback function
-- of Prosody. See the message by Matthew Wild in lua-l:
-- http://lua-users.org/lists/lua-l/2022-03/msg00071.html
-- https://groups.google.com/g/lua-l/c/Axtv6REO_wo Old archive: not yet
-- My notes of Prosody are here:
-- (find-es "lua5" "prosody-traceback")
--
Prosody = Class {
type = "Prosody",
traceback1 = function (dgi)
local line
local func_type = dgi.namewhat.." "
local source_desc = (dgi.short_src == "[C]" and "C code")
or dgi.short_src or "Unknown"
if func_type == " "
then func_type = ""
end
if dgi.short_src == "[C]" then
line = "[ C ] "
..func_type
.."C function "
..(dgi.name and ("%q"):format(dgi.name) or "(unknown name)")
elseif dgi.what == "main" then
line = "[Lua] "
..dgi.short_src
.." line "
..dgi.currentline
else
local name = dgi.name or " "
if name ~= " "
then name = ("%q"):format(name)
end
if func_type == "global " or func_type == "local "
then func_type = func_type.."function "
end
line = "[Lua] "
..dgi.short_src
.." line "
..dgi.currentline
.." in "
..func_type
..name
.." (defined on line "
..dgi.linedefined
..")"
end
return line
end,
__index = {
},
}
-- «Prosody-tests» (to ".Prosody-tests")
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "Prosody1.lua"
require "Repl3" -- (find-angg "LUA/Repl3.lua" "Repl-tests")
-- (find-angg "LUA/lua50init.lua" "DGetFrame")
-- (find-angg "LUA/PreTraceback1.lua" "DGetFrame")
run_repl = function () r = Repl.new(); r:repl() end
stop_repl = function () r.STOP = "please" end
run_repl()
-- Use Prosody to print each stack frame
DGetFrame.__index.tostring = function (dgf)
return Prosody.traceback1(dgf)
end
print(2+
nil) -- shows a traceback using Prosody.
-- Use PrintFunction to print each stack frame.
DGetFrame.__index.tostring = function (dgf)
return tostring(dgf:toprintfunction())
end
= ptb -- shows the pretraceback in ptb using PrintFunction.
stop_repl()
--]]
-- Local Variables:
-- coding: utf-8-unix
-- End: