lua-users home
lua-l archive

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


On 17 January 2015 at 11:55, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> Hi,
> I have found a way to perform in-situ type conversion so I don't need
> the MOVE after all.

The solution I thought I had isn't very good sadly. As I understand it
- because the parser generates code as it goes - it has to go back and
patch previously generated code for certain types of expressions.  So
in a call like this:

local i,j,k = f(), g()

Initially the OP_CALL instruction has operand C set to 2 for both the
calls, but later on the call to g() is patched so that C is set to 3
for the call to g(). I was trying to generate special op codes to
coerce types after each function call - but the problem is at the time
of call to the function the parser does not know how many values to
assign from the function call. As code for f() has already been
generated by the time the call to g() is patched - I cannot go back
and insert extra instructions, especially as some expressions go back
and update specific instructions so all those anchors would be
invalidated by any insertion of new instructions.

The inefficient way seems to be to apply type coercion to i,j, and k
after call to f() and then again to j,k after call to g() ;-(

So back to the drawing board.