From 9774a017a3baadd3caf3b442f4a22a0bf151d4c9 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 24 Jul 2019 18:36:49 +0800 Subject: Improve string.serialize; add unit test --- xmake/core/base/dump.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'xmake/core/base/dump.lua') diff --git a/xmake/core/base/dump.lua b/xmake/core/base/dump.lua index 199dc1e19..ce3b87b91 100644 --- a/xmake/core/base/dump.lua +++ b/xmake/core/base/dump.lua @@ -72,16 +72,19 @@ end -- print function function dump._print_function(func, as_key) + io.write(dump._translate("${reset}${color.dump.function}")) if as_key then - return dump._print_default(func) - end - local funcinfo = debug.getinfo(func) - local srcinfo = funcinfo.short_src - if funcinfo.linedefined >= 0 then - srcinfo = srcinfo .. ":" .. funcinfo.linedefined + io.write(dump._format("text.dump.default_format", "%s", func)) + else + local funcinfo = debug.getinfo(func) + local srcinfo = funcinfo.short_src + if funcinfo.linedefined >= 0 then + srcinfo = srcinfo .. ":" .. funcinfo.linedefined + end + local funcname = funcinfo.name and (funcinfo.name .. " ") or "" + io.write(dump._translate("function ${bright}"), funcname, dump._translate("${reset}${dim}"), srcinfo) end - local funcname = funcinfo.name and (funcinfo.name .. " ") or "" - io.write(dump._translate("${reset}${color.dump.function}function ${bright}"), funcname, dump._translate("${reset}${dim}"), srcinfo) + io.write(dump._translate("${reset}")) end -- print value with default format @@ -101,9 +104,7 @@ end -- print scalar value function dump._print_scalar(value, as_key) - if type(value) == "nil" then - dump._print_keyword("nil") - elseif type(value) == "boolean" then + if type(value) == "nil" or type(value) == "boolean" then dump._print_keyword(value) elseif type(value) == "number" then dump._print_number(value) -- cgit v1.3.1