lua-users home
lua-l archive

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


On 24 April 2012 17:16, Rodrigo Dias Arruda Senra
<rodrigo.senra@hitecnologia.com.br> wrote:
> My question is: How to change local variables (from C code) ?
> I read several threads about merging upvalues, and did some experiments
> but  my current understanding is that it will not work because
> local variables are registers and are not stored in _ENV.
>
> Is this possible ? How ?

Take a look at my attempt here: http://snippets.luacode.org/snippets/title_88

What I've done is create an ENV table, which actually looks up
variables first in the locals, then in global table. It also supports
writes. There are some hacks regarding the function layout during
indexing ("{where = l + 2…"), but at least you can get the idea how to
implement this.