aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-04-12 15:57:19 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-04-12 15:57:19 -0300
commitf9cf402fbd1ba2ab00f5aa5f7d0ff5c9c0580dd5 (patch)
tree7bed49a7ff5c730cdfdef7c3a43b71e039d4442b /lcode.c
parent0c3fe2c44be155b11b52230e36f45e688bae5ce2 (diff)
downloadlua-f9cf402fbd1ba2ab00f5aa5f7d0ff5c9c0580dd5.tar.gz
lua-f9cf402fbd1ba2ab00f5aa5f7d0ff5c9c0580dd5.tar.bz2
lua-f9cf402fbd1ba2ab00f5aa5f7d0ff5c9c0580dd5.zip
first implementation of FOR
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lcode.c b/lcode.c
index c1bcc980..f75ac359 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.22 2000/04/07 13:13:11 roberto Exp roberto $ 2** $Id: lcode.c,v 1.23 2000/04/07 19:35:20 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -53,7 +53,6 @@ static void luaK_fixjump (FuncState *fs, int pc, int dest) {
53 SETARG_S(*jmp, NO_JUMP); /* point to itself to represent end of list */ 53 SETARG_S(*jmp, NO_JUMP); /* point to itself to represent end of list */
54 else { /* jump is relative to position following jump instruction */ 54 else { /* jump is relative to position following jump instruction */
55 int offset = dest-(pc+1); 55 int offset = dest-(pc+1);
56 LUA_ASSERT(L, offset != NO_JUMP, "cannot link to itself");
57 if (abs(offset) > MAXARG_S) 56 if (abs(offset) > MAXARG_S)
58 luaK_error(fs->ls, "control structure too long"); 57 luaK_error(fs->ls, "control structure too long");
59 SETARG_S(*jmp, offset); 58 SETARG_S(*jmp, offset);
@@ -434,7 +433,6 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
434 mode = iP; 433 mode = iP;
435 switch (o) { 434 switch (o) {
436 435
437 case OP_JMP: delta = 0; mode = iS; break;
438 case OP_CLOSURE: delta = -arg2+1; mode = iAB; break; 436 case OP_CLOSURE: delta = -arg2+1; mode = iAB; break;
439 case OP_SETLINE: mode = iU; break; 437 case OP_SETLINE: mode = iU; break;
440 case OP_CALL: mode = iAB; break; 438 case OP_CALL: mode = iAB; break;
@@ -443,6 +441,10 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
443 case OP_SETTABLE: delta = -arg2; mode = iAB; break; 441 case OP_SETTABLE: delta = -arg2; mode = iAB; break;
444 case OP_SETLIST: delta = -(arg2+1); mode = iAB; break; 442 case OP_SETLIST: delta = -(arg2+1); mode = iAB; break;
445 case OP_SETMAP: delta = -2*(arg1+1); mode = iU; break; 443 case OP_SETMAP: delta = -2*(arg1+1); mode = iU; break;
444 case OP_FORLOOP: delta = -3; arg1 = NO_JUMP; mode = iS; break;
445
446 case OP_FORPREP: arg1 = NO_JUMP; /* go through */
447 case OP_JMP: mode = iS; break;
446 448
447 case OP_END: case OP_PUSHNILJMP: case OP_NOT: 449 case OP_END: case OP_PUSHNILJMP: case OP_NOT:
448 mode = iO; break; 450 mode = iO; break;