lua-users home
lua-l archive

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

> 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 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?

It seems more complicated than necessary. Can't the @number[] handler
just grab the next 'pc' before calling 'constructor'? (There is where
the OP_NEWTABLE will be.) Or couldn't 'constructor' return that

-- Roberto