|
https://github.com/hjelmeland/globalsThis is a Lua program that list reports global variable usage in Lua files. It uses 'luac', and parses the bytecode listing. No other dependencies. Works with both Lua 5.1 and 5.2. It builds on test/global.lua in the lua-5.1.4 distribution. Lines where a global is written to are marked with 's' Globals not preloaded in Lua are marked with '!!!' Name of 'luac' can be overridden with environment variable LUAC Egil Hjelmeland, 2012; License MIT $ globals.lua /usr/local/bin/globals.lua /usr/local/bin/globals.lua _G : 9 arg : 9 io : 9 ipairs : 9 os : 9 string : 9 table : 9 tonumber : 9 local _G,arg,io,ipairs,os,string,table,tonumber = _G,arg,io,ipairs,os,string,table,tonumber $ globals.lua lua-5.1.4/test/life.lua lua-5.1.4/test/life.lua !!! ALIVE : 8s 9s 59 !!! ARRAY2D : 16s 68 !!! BUTTERFLY : 82s !!! CELLS : 67s 87 88 !!! DEAD : 8s 9s 59 !!! EXPLODE : 80s 93 !!! FISH : 81s 94 !!! GLIDER : 79s 92 !!! HEART : 78s !!! LIFE : 85s 111 !!! _CELLS : 27s 30 39 55 69 70 71 !!! delay : 11s io : 6 local ALIVE,ARRAY2D,BUTTERFLY,CELLS,DEAD,EXPLODE,FISH,GLIDER,HEART,LIFE,_CELLS,delay,io = ALIVE,ARRAY2D,BUTTERFLY,CELLS,DEAD,EXPLODE,FISH,GLIDER,HEART,LIFE,_CELLS,delay,io $ globals.lua lua-5.1.4/test/*.lua ... |