lua-users home
lua-l archive

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


Hello,

I'm trying to figure out parser register allocation.

So we have OP_SELF A B C R(A+1) := R(B); R(A) := R(B)[RK(C)], it allocates 2 registers. If I want to change R(A), I need a way to deallocate it so the next expression(s) can change it.

My question is, how can I deallocate R(A) without deallocating R(A+1)? So I can get things like:

GETUPVAL    0  0    ; R(0) = _ENV
OP_SELF     1  0 -1 ; R(2) = _ENV; R(1) = _ENV["table"]
OP_GETTABLE 1  1 -2 ; R(1) = R(1) = R(1)["insert"]
LOADK       3 -2    ; R(3) = "test"
OP_CALL     1  3  1 ; R(1)(R(2), R(3))

Using a syntax like:

-- (I actually want this code to output bytecode _exactly_ as above)
local _ENV = _ENV
_ENV:table.insert"test"

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.