summaryrefslogtreecommitdiff
path: root/test/dump.lua
diff options
context:
space:
mode:
authorLua Team <team@lua.org>1995-02-07 12:00:00 +0000
committerrepogen <>1995-02-07 12:00:00 +0000
commita8b6ba0954edb9e0e669e1f451b9a8f145ce5166 (patch)
tree35e9e9999968c4f13a25a5f647203456f044274a /test/dump.lua
parent944fc7d7d95575f2b8023c1f3d4ac19e1369fc76 (diff)
downloadlua-github-2.1.tar.gz
Lua 2.12.1
Diffstat (limited to 'test/dump.lua')
-rw-r--r--test/dump.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/dump.lua b/test/dump.lua
new file mode 100644
index 00000000..fa0aa4fb
--- /dev/null
+++ b/test/dump.lua
@@ -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()