# HG changeset patch # User Matthew Wild # Date 1256524868 0 # Node ID 258aedad056ca5f15d018035a7c1a5aba9502159 # Parent ab49e2e3d709c689ce55d5a670a9c5f485ecab6c Clear up the confusing key/value/name issue diff -r ab49e2e3d709 -r 258aedad056c luatraverse.lua --- a/luatraverse.lua Mon Oct 26 02:37:49 2009 +0000 +++ b/luatraverse.lua Mon Oct 26 02:41:08 2009 +0000 @@ -68,7 +68,7 @@ -- marks and inserts on the list edge(env, nil, "_G", "isname", nil) - edge(env, nil, _G, "key", "_G") + edge(env, nil, _G, "value", "_G") -- traverses the active thread -- inserts the local variables @@ -103,8 +103,8 @@ if f then f(obj) end for key, value in pairs(obj) do - edge(env, obj, key, "iskey", nil) - edge(env, obj, value, "key", key) + edge(env, obj, key, "key", nil) + edge(env, obj, value, "value", key) end local mtable = debug.getmetatable(obj) @@ -173,10 +173,10 @@ -- 'how' is a string that identifies the content of 'to' and 'value': --- if 'how' is "iskey", then 'to' is a key and 'value' is nil. --- if 'how' is "key", then 'to' is an object and 'value' is the name of the +-- if 'how' is "key", then 'to' is a key and 'name' is nil. +-- if 'how' is "value", then 'to' is an object and 'name' is the name of the -- key. -function edge(env, from, to, how, value) +function edge(env, from, to, how, name) local t = type(to) @@ -188,7 +188,7 @@ end local f = env.funcs.edge - if f then f(from, to, how, value) end + if f then f(from, to, how, name) end end end