diff options
Diffstat (limited to 'test/dump.lua')
-rw-r--r-- | test/dump.lua | 37 |
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() |