Skip to content

Commit b7efcd1

Browse files
committed
show class name when dumping in front of {
1 parent 29d8ccc commit b7efcd1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

moonscript/util.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ dump = function(what)
102102
lines = _accum_0
103103
end
104104
seen[what] = false
105-
return "{\n" .. concat(lines) .. (" "):rep((depth - 1) * 4) .. "}\n"
105+
local class_name
106+
if what.__class then
107+
class_name = "<" .. tostring(what.__class.__name) .. ">"
108+
end
109+
return tostring(class_name or "") .. "{\n" .. concat(lines) .. (" "):rep((depth - 1) * 4) .. "}\n"
106110
else
107111
return tostring(what) .. "\n"
108112
end

moonscript/util.moon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ dump = (what) ->
7070

7171
seen[what] = false
7272

73-
"{\n" .. concat(lines) .. (" ")\rep((depth - 1)*4) .. "}\n"
73+
class_name = if what.__class
74+
"<#{what.__class.__name}>"
75+
76+
"#{class_name or ""}{\n" .. concat(lines) .. (" ")\rep((depth - 1)*4) .. "}\n"
7477
else
7578
tostring(what).."\n"
7679

0 commit comments

Comments
 (0)