aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-21 20:59:39 +1000
committerDavid Walter Seikel2014-04-21 20:59:39 +1000
commit9621add2918cc4943e6693b74ae85d51dd264fcf (patch)
treefff1edf2c69d7a08a0e12885eecc9b96ed847a6a /LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua
parentLuaSL_test's window doesn't need to be so huge. (diff)
downloadSledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.zip
SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.gz
SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.bz2
SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.xz
We don't need the testlua directory any more.
Diffstat (limited to 'LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua')
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua38
1 files changed, 0 insertions, 38 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua
deleted file mode 100644
index 295e670..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua
+++ /dev/null
@@ -1,38 +0,0 @@
1-- trace assigments to global variables
2
3do
4 -- a tostring that quotes strings. note the use of the original tostring.
5 local _tostring=tostring
6 local tostring=function(a)
7 if type(a)=="string" then
8 return string.format("%q",a)
9 else
10 return _tostring(a)
11 end
12 end
13
14 local log=function (name,old,new)
15 local t=debug.getinfo(3,"Sl")
16 local line=t.currentline
17 io.write(t.short_src)
18 if line>=0 then io.write(":",line) end
19 io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n")
20 end
21
22 local g={}
23 local set=function (t,name,value)
24 log(name,g[name],value)
25 g[name]=value
26 end
27 setmetatable(getfenv(),{__index=g,__newindex=set})
28end
29
30-- an example
31
32a=1
33b=2
34a=10
35b=20
36b=nil
37b=200
38print(a,b,c)