summaryrefslogtreecommitdiff
path: root/test/dump
diff options
context:
space:
mode:
authorLua Team <team@lua.org>1994-07-08 12:00:00 +0000
committerrepogen <>1994-07-08 12:00:00 +0000
commit944fc7d7d95575f2b8023c1f3d4ac19e1369fc76 (patch)
treeeabf0822f2058229cd0d49c7928683b8cf0ed88e /test/dump
parent8b5979a7e8b9732aa2883d2384f853d87b594770 (diff)
downloadlua-github-1.1.tar.gz
Lua 1.11.1
Diffstat (limited to 'test/dump')
-rw-r--r--test/dump37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/dump b/test/dump
new file mode 100644
index 00000000..d5feb2b4
--- /dev/null
+++ b/test/dump
@@ -0,0 +1,37 @@
+
+
+function savevar (n,v)
+ if v = nil then return end;
+ if type(v) = "number" then print(n.."="..v) return end
+ if type(v) = "string" then print(n.."='"..v.."'") return end
+ if type(v) = "table" then
+ if v.__visited__ ~= nil then
+ print(n .. "=" .. v.__visited__);
+ else
+ print(n.."=@()")
+ v.__visited__ = n;
+ local r,f;
+ r,f = next(v,nil);
+ while r ~= nil do
+ if r ~= "__visited__" then
+ if type(r) = 'string' then
+ savevar(n.."."..r,f)
+ else
+ savevar(n.."["..r.."]",f)
+ end
+ end
+ r,f = next(v,r)
+ end
+ end
+ end
+end
+
+function save ()
+ local n,v = nextvar(nil)
+ while n ~= nil do
+ savevar(n,v);
+ n,v = nextvar(n)
+ end
+end
+
+save()