Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (36 sloc) 1.58 KB

Lua VM instructions

MOVE A B R(A) := R(B) LOADK A Bx R(A) := K(Bx) LOADBOOL A B C R(A) := (Bool)B; if (C) PC++ LOADNIL A B R(A) := ... := R(B) := nil GETUPVAL A B R(A) := U[B] GETGLOBAL A Bx R(A) := G[K(Bx)] GETTABLE A B C R(A) := R(B)[RK(C)] SETGLOBAL A Bx G[K(Bx)] := R(A) SETUPVAL A B U[B] := R(A) SETTABLE A B C R(A)[RK(B)] := RK(C) NEWTABLE A B C R(A) := {} (size = B,C) SELF A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] ADD A B C R(A) := RK(B) + RK(C) SUB A B C R(A) := RK(B) - RK(C) MUL A B C R(A) := RK(B) * RK(C) DIV A B C R(A) := RK(B) / RK(C) POW A B C R(A) := RK(B) ^ RK(C) UNM A B R(A) := -R(B) NOT A B R(A) := not R(B) CONCAT A B C R(A) := R(B) .. ... .. R(C) JMP sBx PC += sBx EQ A B C if ((RK(B) == RK(C)) ~= A) then PC++ LT A B C if ((RK(B) < RK(C)) ~= A) then PC++ LE A B C if ((RK(B) <= RK(C)) ~= A) then PC++ TEST A B C if (R(B) <=> C) then R(A) := R(B) else PC++ CALL A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) TAILCALL A B C return R(A)(R(A+1), ... ,R(A+B-1)) RETURN A B return R(A), ... ,R(A+B-2) (see note) FORLOOP A sBx R(A)+=R(A+2); if R(A) <?= R(A+1) then PC+= sBx TFORLOOP A C R(A+2), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); TFORPREP A sBx if type(R(A)) == table then R(A+1):=R(A), R(A):=next; SETLIST A Bx R(A)[Bx-Bx%FPF+i] := R(A+i), 1 <= i <= Bx%FPF+1 SETLISTO A Bx CLOSE A close stack variables up to R(A) CLOSURE A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n))