lua-users home
lua-l archive

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


On 13 December 2015 at 00:20, Soni L. <fakedme@gmail.com> wrote:
>> My aim is to generate a bytecode instruction that asserts the type of
>> an expression. I am treating the operator has a unary operator. Unlike
>> the existing unary operators the difference is that in this case the
>> bytecode has only one operand A which identifies a register - and the
>> bytecode asserts the type of the value held in that register. As this
>> is a unary operator then it can be used within expressions.
>>
> Why not add opcodes that push special (internal) functions on the stack? And
> special-case them on the JIT?
>
> That way you'd probably have less work to do.
>

Hi - actually that is harder to do as Lua doesn't know that a name is
a function and by the time a function call is identified, arguments
have already been pushed on to the stack. The approach I have taken
has low overhead as all it does is a type assertion on an existing
value.

My approach so far has been to keep the existing Lua parser and code
generator - which is very fast and efficient - but because code is
generated as the parser proceeds, some things are hard to do. I may
end up creating a new parser that generates an AST first but I am
trying to avoid that.

Regards