diff options
| -rw-r--r-- | lvm.c | 35 |
1 files changed, 20 insertions, 15 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.127 2010/12/17 12:05:37 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.128 2011/02/01 18:03:10 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -467,13 +467,13 @@ void luaV_finishOp (lua_State *L) { | |||
| 467 | 467 | ||
| 468 | 468 | ||
| 469 | /* execute a jump instruction */ | 469 | /* execute a jump instruction */ |
| 470 | #define dojump(ci,i) \ | 470 | #define dojump(ci,i,e) \ |
| 471 | { int a = GETARG_A(i); \ | 471 | { int a = GETARG_A(i); \ |
| 472 | if (a > 0) luaF_close(L, ci->u.l.base + a - 1); \ | 472 | if (a > 0) luaF_close(L, ci->u.l.base + a - 1); \ |
| 473 | ci->u.l.savedpc += GETARG_sBx(i); } | 473 | ci->u.l.savedpc += GETARG_sBx(i) + e; } |
| 474 | 474 | ||
| 475 | /* for test instructions, execute the jump instruction that follows it */ | 475 | /* for test instructions, execute the jump instruction that follows it */ |
| 476 | #define donextjump(ci) dojump(ci, *ci->u.l.savedpc) | 476 | #define donextjump(ci) { i = *ci->u.l.savedpc; dojump(ci, i, 1); } |
| 477 | 477 | ||
| 478 | 478 | ||
| 479 | #define Protect(x) { {x;}; base = ci->u.l.base; } | 479 | #define Protect(x) { {x;}; base = ci->u.l.base; } |
| @@ -627,43 +627,48 @@ void luaV_execute (lua_State *L) { | |||
| 627 | L->top = ci->top; /* restore top */ | 627 | L->top = ci->top; /* restore top */ |
| 628 | ) | 628 | ) |
| 629 | vmcase(OP_JMP, | 629 | vmcase(OP_JMP, |
| 630 | dojump(ci, i); | 630 | dojump(ci, i, 0); |
| 631 | ) | 631 | ) |
| 632 | vmcase(OP_EQ, | 632 | vmcase(OP_EQ, |
| 633 | TValue *rb = RKB(i); | 633 | TValue *rb = RKB(i); |
| 634 | TValue *rc = RKC(i); | 634 | TValue *rc = RKC(i); |
| 635 | Protect( | 635 | Protect( |
| 636 | if (equalobj(L, rb, rc) == GETARG_A(i)) | 636 | if (equalobj(L, rb, rc) != GETARG_A(i)) |
| 637 | ci->u.l.savedpc++; | ||
| 638 | else | ||
| 637 | donextjump(ci); | 639 | donextjump(ci); |
| 638 | ) | 640 | ) |
| 639 | ci->u.l.savedpc++; | ||
| 640 | ) | 641 | ) |
| 641 | vmcase(OP_LT, | 642 | vmcase(OP_LT, |
| 642 | Protect( | 643 | Protect( |
| 643 | if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) | 644 | if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) |
| 645 | ci->u.l.savedpc++; | ||
| 646 | else | ||
| 644 | donextjump(ci); | 647 | donextjump(ci); |
| 645 | ) | 648 | ) |
| 646 | ci->u.l.savedpc++; | ||
| 647 | ) | 649 | ) |
| 648 | vmcase(OP_LE, | 650 | vmcase(OP_LE, |
| 649 | Protect( | 651 | Protect( |
| 650 | if (luaV_lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) | 652 | if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) |
| 653 | ci->u.l.savedpc++; | ||
| 654 | else | ||
| 651 | donextjump(ci); | 655 | donextjump(ci); |
| 652 | ) | 656 | ) |
| 653 | ci->u.l.savedpc++; | ||
| 654 | ) | 657 | ) |
| 655 | vmcase(OP_TEST, | 658 | vmcase(OP_TEST, |
| 656 | if (GETARG_C(i) ? !l_isfalse(ra) : l_isfalse(ra)) | 659 | if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) |
| 660 | ci->u.l.savedpc++; | ||
| 661 | else | ||
| 657 | donextjump(ci); | 662 | donextjump(ci); |
| 658 | ci->u.l.savedpc++; | ||
| 659 | ) | 663 | ) |
| 660 | vmcase(OP_TESTSET, | 664 | vmcase(OP_TESTSET, |
| 661 | TValue *rb = RB(i); | 665 | TValue *rb = RB(i); |
| 662 | if (GETARG_C(i) ? !l_isfalse(rb) : l_isfalse(rb)) { | 666 | if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) |
| 667 | ci->u.l.savedpc++; | ||
| 668 | else { | ||
| 663 | setobjs2s(L, ra, rb); | 669 | setobjs2s(L, ra, rb); |
| 664 | donextjump(ci); | 670 | donextjump(ci); |
| 665 | } | 671 | } |
| 666 | ci->u.l.savedpc++; | ||
| 667 | ) | 672 | ) |
| 668 | vmcase(OP_CALL, | 673 | vmcase(OP_CALL, |
| 669 | int b = GETARG_B(i); | 674 | int b = GETARG_B(i); |
