[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: OP_MMBIN, OP_MMBINI, OP_MMBINK questions
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 27 Apr 2020 10:43:33 -0300
> OP_MMBIN - invokes metamethod denoted by the index in C (enum TMS) with
> R[A] and R[B] as parameters. If there is a metamethod, is the result
> placed in the result register of the previous arithmetic instruction?
> The same goes for OP_MMBINI and OP_MMBINK I assume, is that correct?
> OP_MMBINI and OP_MMBINK - similar to OP_MMBIN, but on an integer (SB) or
> constant (K[B]), am I correct about that?
> What is the significance of K in OP_MMBINI and OP_MMBINK? Is it to just
> flip the two parameters to the metamethod?
Yes. It means the parameters were flipped when generating the opcodes,
assuming the operation was commutative (plus, mul, band, etc.). As we
cannot assume metamethods are commutative, 'k' flips them back to the
> In summary, I assume these instructions (judging by the source code) try
> to invoke a metamethod indicated by C and put the result in the R(A of
> previous instruction) if the call could happen, where K indicates
> whether the parameters to the methamethod should be flipped or not.
lua-l mailing list -- firstname.lastname@example.org
To unsubscribe send an email to email@example.com