Den 2013-01-23 13:45, skrev steve donovan:
Also see https://github.com/hjelmeland/globals previously announced.On Wed, Jan 23, 2013 at 12:56 PM, Luiz Henrique de Figueiredo <firstname.lastname@example.org> wrote:Nice. See also http://lua-users.org/lists/lua-l/2012-12/msg00397.htmlWell, it was not difficult to update the code to work with both 5.1 and 5.2, using the interestingly named GETTABUP instruction instead, and allowing for a somewhat different instruction presentation. One of the cool things about this script is that it can detect more than plain undeclared access, but warn against potentially evil things: -- globs2.lua next = 3 table.who = 1 function table.boo () local k = 1 end $ globals globs2.lua globals: globs2.lua:2: redefining global next globals: globs2.lua:4: redefining global table.who globals: globs2.lua:6: redefining global table.boo This required a further extension of David's trick for detecting field access (by relaxing the requirement that the SETTABLE instruction had to _immediately_ follow any global table access.) Behaves almost identically for 5.1 or 5.2, but please change 'luac52' to 'luac' (this was only way I could keep testing sane on my side) BTW, I note that GETTABUP is not only used for _ENV? There are definite limits on how far one can track variable usage, once everything becomes locals, and I was wondering if we had extra information that could be used. steve d.
It does not follow require/loads, has no options. But it does allow passing a list of files as arguments , so you can do
The name of luac can be overridden with environment variable LUAC. So to use luac52, from a usable shell do
LUAC=luac52 globals.lua /usr/local/share/lua/5.1/pl/*.lua