simpler implementation of for loops

This commit is contained in:
Roberto Ierusalimschy
2001-01-29 13:26:40 -02:00
parent caf01b5bfa
commit 3b6f8bfbe6
4 changed files with 29 additions and 29 deletions

13
lcode.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lcode.c,v 1.57 2001/01/19 13:20:30 roberto Exp roberto $
** $Id: lcode.c,v 1.58 2001/01/29 13:14:49 roberto Exp roberto $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -59,6 +59,17 @@ static void luaK_fixjump (FuncState *fs, int pc, int dest) {
}
/*
** prep-for instructions (OP_FORPREP & OP_LFORPREP) have a negated jump,
** as they simulate the real jump...
*/
void luaK_fixfor (FuncState *fs, int pc, int dest) {
Instruction *jmp = &fs->f->code[pc];
int offset = dest-(pc+1);
SETARG_S(*jmp, -offset);
}
static int luaK_getjump (FuncState *fs, int pc) {
int offset = GETARG_S(fs->f->code[pc]);
if (offset == NO_JUMP) /* point to itself represents end of list */