lua-users home
lua-l archive

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


On 17 January 2015 at 06:15, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> There is no difference between temporary registers and locals.
> A local variable is simply a stack slot for which the compiler has
> a name. Not all the names are visible at the Lua level.
>
> All the "local" instruction does ia give names to slots and
> increment the count of how many locals there are.
>
> The reason for the difference between the two sets of code
> is that in the first case when you give names for the two stack
> slots, the compiler knows they already have the values in them,
> so no need to move anything. I.e. the '=' in a local instruction
> generates code only when the most recent temporary slots
> do not already contain the required values.
>

Hi Dirk,

I already know all this - I have my reasons for wanting to do as I
describe. I am building a version of Lua with optional types so I need
the ability to coerce types after a function call. Hence my question.
I will share my changes if / when I have something worth showing.

I am finding that the Lua parser/code generator is the most complex
part of the system, as it is designed for efficiency and does parsing
/ code generation all at the same time - so a lot of clever stuff is
going on, which makes it harder to understand as it is not very well
documented.

Thanks and Regards

Dibyendu