lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, Jan 23, 2013 at 12:56 PM, Luiz Henrique de Figueiredo
<> wrote:
> Nice. See also

Well, 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

-- globs2.lua
next = 3

table.who = 1

function ()
    local k = 1

$ globals globs2.lua
globals: globs2.lua:2: redefining global next
globals: globs2.lua:4: redefining global table.who
globals: globs2.lua:6: redefining global

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.