summaryrefslogtreecommitdiff
path: root/xmake/core/base/dump.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2019-07-26 09:23:24 +0800
committerGitHub <[email protected]>2019-07-26 09:23:24 +0800
commita77e8ad6db511c7adbb6b982cd5958febcb989cf (patch)
tree1fccf65b87e1d1ae89390d2292855fdd3c7deb2d /xmake/core/base/dump.lua
parentb03883547d69d2173ffc46f2c8b9e4d579247a60 (diff)
parent7d4023cf698bff82b2c0f2b4aad86286d4890b49 (diff)
Merge pull request #509 from OpportunityLiu/dev
Improve string.serialize; add unit test
Diffstat (limited to 'xmake/core/base/dump.lua')
-rw-r--r--xmake/core/base/dump.lua23
1 files changed, 12 insertions, 11 deletions
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)