lua-users home
lua-l archive

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


On 16 December 2015 at 14:11, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> Thanks for the explanation Roberto. I did wonder if there was a bit of
>> optimization going on in some cases. I have tried to step through the
>> code in the debugger but the problem is that Lua itself executes Lua
>> code before one can get to the code of interest. So there is just too
>> much noise to be able to see what is going on.
>
> Can't you just see the code that was generated?
>

Do you mean the resulting bytecode? Yes I do look at that all the time.

Now I have a more involved question.

Using type assertion I want to be able to do following:

@number[] { 1,2,3 }

I would like to change the OP_NEWTABLE instruction generated above to
a specialized opcode that creates number[] instead. The problem is
that when the parser sees the expression @number[] exp - the exp is
already VNONRELOC, so the information regarding the OP_NEWTABLE
instruction is no longer present. To solve this I would like to add a
new field in the exp structure to hold the last u.info value when
exp.k was VRELOCABLE. Because then I can get back to the OP_NEWTABLE
instruction and change it.

I have implemented this and it appears to work but I am wondering if
there is a gotcha somewhere in this approach?

Thanks and Regards
Dibyendu