[prev in list] [next in list] [prev in thread] [next in thread]
List: lua-l
Subject: Re: A question about TFORCALL and locals
From: Bas Groothedde <lua () xoru ! net>
Date: 2019-12-18 20:59:59
Message-ID: b06206a8ccf60041e6289b25538b5c71 () xoru ! net
[Download RAW message or body]
On 18-12-2019 20:46, Roberto Ierusalimschy wrote:
> 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
Ah, thank you. That confirms how I currently try to get the local name
for an index. I will have a look at luaF_getlocalname.
Bas
[Attachment #3 (unknown)]
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" \
/></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'> <p>On \
18-12-2019 20:46, Roberto Ierusalimschy wrote:</p> <blockquote type="cite" \
style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"> <div class="pre" \
style="margin: 0; padding: 0; font-family: monospace">The indices of locals in the \
list of locals are not equal to their<br /> indices. Consider the next example:<br /> \
<br /> do<br /> local a, b, c<br /> \
end<br /> do<br /> local x, y, z<br \
/> end<br /> <br /> Because registers are reused, local 'x' has index 0, \
but it is not<br /> in position 0 in the list of locals: it is in position 3 (after \
'a',<br /> 'b', and 'c'). To find a local at a given index and given PC, you<br /> \
must do what luaF_getlocalname does, counting the variables that<br /> are active at \
the given PC until you find the one with the index you<br /> are looking for. (Have a \
look at luaF_getlocalname in file 'lfunc.c'.)<br /> <br /> -- Roberto<br /> </div> \
</blockquote> <p>Ah, thank you. That confirms how I currently try to get the local \
name for an index. I will have a look at <span>luaF_getlocalname.</span></p> \
<p><span>Bas</span></p>
</body></html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic