lua-users home
lua-l archive

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

On 18-12-2019 20:46, Roberto Ierusalimschy wrote:

The indices of locals in the list of locals are not equal to their
indices. Consider the next example:

    local a, b, c
    local x, y, z

Because registers are reused, local 'x' has index 0, but it is not
in position 0 in the list of locals: it is in position 3 (after 'a',
'b', and 'c'). To find a local at a given index and given PC, you
must do what luaF_getlocalname does, counting the variables that
are active at the given PC until you find the one with the index you
are looking for. (Have a look at luaF_getlocalname in file 'lfunc.c'.)

-- Roberto

Ah, thank you. That confirms how I currently try to get the local name for an index. I will have a look at luaF_getlocalname.