lua-users home
lua-l archive

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


> I worded it wrong - if for example (in general) a register (i.e. R(A))
> contains a number that is also 
> an index in the list of locals that are valid in the PC of that
> instruction, can I then assume that local 
> is referenced?  

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

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

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