More debug-mode stuff

This commit is contained in:
Łukasz Magiera 2016-02-11 21:45:46 +01:00
parent b06532228c
commit 574eed69e3
3 changed files with 23 additions and 5 deletions

View File

@ -10,9 +10,11 @@ local componentCallback = {
__tostring = function(self) return (components[self.address] ~= nil and components[self.address].doc[self.name] ~= nil) and components[self.address].doc[self.name] or "function" end
}
--Debug only
local start = native.uptime()
local last = native.uptime()
if native.debug then
local start = native.uptime()
local last = native.uptime()
componentCallback.__call = function(self, ...)
local t = {}
for k,v in pairs({...}) do
@ -89,6 +91,20 @@ function api.invoke(address, method, ...)
if not components[address].rawproxy[method] then
error("No such method: " .. tostring(components[address].type) .. "." .. tostring(method))
end
if native.debug then --TODO: This may generate little performance hit
local t = {}
for k,v in pairs({...}) do
if type(v) == "string" then
v = "\"" .. v .. "\""
end
t[k] = tostring(v)
end
local caller = debug.getinfo(2)
local msg = tostring((native.uptime() - start) / 1000) .. " [+" .. native.uptime() - last .. "] " .. caller.short_src .. ":".. caller.currentline .. " > c.invoke(" .. address .. "): "
.. components[address].type .. "." .. method
.. "(" .. table.concat(t, ", ") .. ")"
end
return components[address].rawproxy[method](...)
end

View File

@ -50,7 +50,7 @@ local function concat(pathA, pathB, ...)
return canonical(_concat(2, pathA, pathB, ...))
end
function filesystem.register(basePath)
function filesystem.register(basePath, uuid)
checkArg(1, basePath, "string")
if not native.fs_exists(basePath) then
@ -156,7 +156,7 @@ function filesystem.register(basePath)
checkArg(1, value, "number")
return value --TODO: Implement, use real labels
end
return modules.component.api.register(nil, "filesystem", fs)
return modules.component.api.register(uuid, "filesystem", fs)
end
return filesystem

View File

@ -77,7 +77,9 @@ function main()
modules.eeprom.register()
modules.internet.start()
modules.filesystem.register("root")
modules.filesystem.register("/") --TODO: remove from release
if native.debug then
modules.filesystem.register("/", "11111111-1111-1111-1111-111111111111")
end
modules.computer.tmp = modules.filesystem.register("/tmp/lupi-" .. modules.random.uuid())
modules.textgpu.start()