lua-users home
lua-l archive

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


> SELF takes 2 inputs and produces 2 outputs, so why's it 1 1 3 and not 1 1 2?

See its description in lopcodes.h:

OP_SELF,/*      A B C   R(A+1) := R(B); R(A) := R(B)[RK(C):string]      */

The outputs go to A,(A+1). It produces output (A+1) before consuming
input C, so "1 1 2" would erase the input before using it. (The other
option would be a slower implementation, using an extra temporary and an
extra move. Changing the order of the assignments would destroy A before
using B, so A and B would need to be different and the instruction would
need three registers anyway.)

-- Roberto