The Sol Programming Language!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
755 B

func dump(obj, indent, seen = {})
if None == indent then
indent = 0
seen = {}
end
io.stdout:write(" "*indent)
if type(obj) == "list" then
buf = buffer.fromobject(obj)
addr = buf:address()
if None != seen[obj] then
print("...("+addr+")")
return
end
seen[obj] = 1
print("[")
for elem in obj do
dump(elem, indent+2)
end
print(" "*indent+"] =("+addr+")")
return
end
if type(obj) == "map" then
buf = buffer.fromobject(obj)
addr = buf:address()
if None != seen[obj] then
print("...("+addr+")")
return
end
seen[obj] = 1
print("{")
for key in obj do
io.stdout:write(" "*(indent+2))
prepr(key, ":")
dump(obj[key], indent+4)
end
print(" "*indent+"} =("+addr+")")
return
end
prepr(obj)
end