Clear up the confusing key/value/name issue

Mon, 26 Oct 2009 02:41:08 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 26 Oct 2009 02:41:08 +0000
changeset 7
258aedad056c
parent 6
ab49e2e3d709
child 8
b75900150167

Clear up the confusing key/value/name issue

luatraverse.lua file | annotate | diff | comparison | revisions
--- 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

mercurial