lua-users home
lua-l archive

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


On 18 December 2015 at 18:32, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> @number[] does two things:
>> If applied to a table constructor it converts the table to number[] which
>> is a specialisation of the table. This is done by changing the op code from
>> OP_NEWTABLE to OP_RAVI_NEWARRAYF.
>> If applied to an expression that is not a constructor it generates a
>> OP_RAVI_TOARRAYF instruction which will assert at runtime that the
>> expression is of type number[].
>
> In my view, the cleanest solution (but that needs more changes) would
> be to introduce a new kind of expression, VCONSTRUCTOR.
>

Ok thank you for that suggestion - I will investigate that option.

I have found a better solution based on your previous suggestion - the
constructor() function knows the 'pc' of the instruction containing
OP_NEWTABLE, so I can make it store this in the exp structure directly
instead of trying to infer this by tracking when VRELOCABLE becomes
VNONRELOC.

Regards
Dibyendu