lua-users home
lua-l archive

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


On 18-12-2019 18:53, Roberto Ierusalimschy wrote:

For the case of Lua 5.4, in TFORCALL R(A) holds the generator, R(A + 1)
the state, R(A + 2) the control variable and R(A + 3) the to be closed
variable.
R(A + 4) through R(A + 3 + C) will hold the local values specified in
the for loop, returned by the generator. Am I correct about this?

Yes.

Thank you.



If so, usually when a register is referring to a local then the local
can easily be resolved by looking up the value of A in the locals list
for that function. Am
I correct that in the case of TFORCALL, A is relative to the first local
that the PC of TFORCALL falls within? (TFORCALL PC >= local startpc &&
TFORCALL PC <= local endpc)

I did not understand your question here.

-- Roberto

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? 

i.e.

pc    line    opcode  operands   comment
28    [52]    SELF    2 1 1k     ; "push"

and 

# name   pc start  pc end
0 stack   3        106
1 stack1 25        106
2 t1     51        106

In this case, R(B) of the SELF instruction is `stack1`, however R(A) of the SELF instruction is not `t1` as that instruction's PC is not in the pc start to pc end range of that local. This seems logical to me, however I would like to be sure about this. 

Thank you.