new opcodes 'FORLOOP1'/'FORPREP1' for "basic for" (integer variable

with increment of 1)
This commit is contained in:
Roberto Ierusalimschy
2017-12-18 15:53:50 -02:00
parent ab07005568
commit d388c165ef
4 changed files with 73 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lopcodes.h,v 1.178 2017/12/15 18:35:22 roberto Exp roberto $
** $Id: lopcodes.h,v 1.179 2017/12/15 18:53:48 roberto Exp roberto $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -267,6 +267,10 @@ OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
OP_RETURN0,/* return */
OP_RETURN1,/* A return R(A) */
OP_FORLOOP1,/* A Bx R(A)++;
if R(A) <= R(A+1) then { pc-=Bx; R(A+3)=R(A) } */
OP_FORPREP1,/* A Bx R(A)--; pc+=Bx */
OP_FORLOOP,/* A Bx R(A)+=R(A+2);
if R(A) <?= R(A+1) then { pc-=Bx; R(A+3)=R(A) } */
OP_FORPREP,/* A Bx R(A)-=R(A+2); pc+=Bx */