aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/lcode.c b/lcode.c
index 26a606ef..42899758 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.13 2000/03/16 18:03:09 roberto Exp roberto $ 2** $Id: lcode.c,v 1.14 2000/03/17 13:09:46 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*/
@@ -337,8 +337,23 @@ static OpCode invertjump (OpCode op) {
337 337
338static void luaK_jump (FuncState *fs, OpCode jump) { 338static void luaK_jump (FuncState *fs, OpCode jump) {
339 Instruction previous = prepare(fs, CREATE_S(jump, 0), -1); 339 Instruction previous = prepare(fs, CREATE_S(jump, 0), -1);
340 if (previous == CREATE_0(OP_NOT)) 340 switch (GET_OPCODE(previous)) {
341 setprevious(fs, CREATE_S(invertjump(jump), 0)); 341 case OP_NOT: previous = CREATE_S(invertjump(jump), 0); break;
342 case OP_PUSHINT:
343 if (jump == OP_IFTJMP) {
344 previous = CREATE_S(OP_JMP, 0);
345 break;
346 }
347 else return; /* do not set previous */
348 case OP_PUSHNIL:
349 if (jump == OP_IFFJMP) {
350 previous = CREATE_S(OP_JMP, 0);
351 break;
352 }
353 else return; /* do not set previous */
354 default: return;
355 }
356 setprevious(fs, previous);
342} 357}
343 358
344 359