lua-users home
lua-l archive

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

> I'm planning to translate the code like that:
> m[i, j]         => __index(m, i, j)
> m[i, j] = v    => __newindex(m, i, j, v)
> [...]
> So, for the parser modification I should be able to do it. I'm more
> worried about the code generation. May be is not that difficult but I
> will need some hints.

Currently Lua does not have opcodes to do that. The calls to metamethods
are done automatically by the virtual machine, there is no instruction
to explicitly call a metamethod or even to get the metatable of an
object. So either you modify the virtual machine, adding an extra
instruction, or you will have to generate a long (and inefficient)
sequence of instructions equivalent to getmetatable(m).__index(m, i, j).

-- Roberto