lua-users home
lua-l archive

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


On 24 January 2015 at 06:55, Dong Feng <middle.fengdong@gmail.com> wrote:
> Lua document section 3.3.2: Lua handles a chunk as the body of an anonymous
> function with a variable number of arguments (see §3.4.11).
>

Thanks - I had missed that.

>>
>> Another question I have is to do with lexical scopes of variables
>> within the parse run.  Can I assume that LocVar.startpc and
>> LocVar.endpc define the boundary within where a particular variable is
>> available - and that if LexState.dyd contains a reference to a
>> variable register then the corresponding variable scope is as defined
>> in LocVar?
>
>
> Maybe I'm wrong. I think "startpc" and "endpc" are mainly, if not
> completely, for debugging information. They reflect the effective scope of a
> local variable. But you could hardly say they "define" one. The scope of
> local variable is defined by FuncState::nactvar, BlockCnt:: nactvar, and the
> generated code that maintaining Lua stack.
>

Yes, I am now using 'nactvar' - so I don't need to use 'startpc'. The
scenario I have is that when I see a register I need to know what type
is associated with the register, so that I can generate type specific
instructions. I had some trouble getting this right as I did not fully
understand how the 'nactvar' variable interacts with other variables.
Thanks to Sven Olsen's write-up and further debugging I have a better
understanding now.

I have updated the following link with my latest understanding:

https://github.com/dibyendumajumdar/ravi/wiki/Lua-Internals

Thanks and Regards
Dibyendu