From 574eed69e31460a4e6e24dd031c27cb13f060540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 11 Feb 2016 21:45:46 +0100 Subject: [PATCH] More debug-mode stuff --- src/lua/core/component.lua | 20 ++++++++++++++++++-- src/lua/core/filesystem.lua | 4 ++-- src/lua/core/init.lua | 4 +++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/lua/core/component.lua b/src/lua/core/component.lua index e429f7a..ae16845 100644 --- a/src/lua/core/component.lua +++ b/src/lua/core/component.lua @@ -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 diff --git a/src/lua/core/filesystem.lua b/src/lua/core/filesystem.lua index 6ee750d..045b4b3 100644 --- a/src/lua/core/filesystem.lua +++ b/src/lua/core/filesystem.lua @@ -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 \ No newline at end of file diff --git a/src/lua/core/init.lua b/src/lua/core/init.lua index 9d9bc83..b66abf6 100644 --- a/src/lua/core/init.lua +++ b/src/lua/core/init.lua @@ -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()