diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-05-12 17:31:33 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-05-12 17:31:33 -0300 |
commit | 8554baeacf8e2af3e87d5f1c0e033fc9d1f9dc8e (patch) | |
tree | 7c186ec539e7ec53ff6a980e0fc85752081f1c95 /lvm.c | |
parent | f5b7f077eca034e03683363d15f28765568372e4 (diff) | |
download | lua-8554baeacf8e2af3e87d5f1c0e033fc9d1f9dc8e.tar.gz lua-8554baeacf8e2af3e87d5f1c0e033fc9d1f9dc8e.tar.bz2 lua-8554baeacf8e2af3e87d5f1c0e033fc9d1f9dc8e.zip |
small changes in 'luaV_execute' to make cases more regularly formatted
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.116 2010/05/04 17:25:19 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.117 2010/05/05 18:49:56 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 | */ |
@@ -459,8 +459,7 @@ void luaV_execute (lua_State *L) { | |||
459 | StkId ra; | 459 | StkId ra; |
460 | if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && | 460 | if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && |
461 | (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { | 461 | (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { |
462 | traceexec(L); | 462 | Protect(traceexec(L)); |
463 | base = ci->u.l.base; | ||
464 | } | 463 | } |
465 | /* warning!! several calls may realloc the stack and invalidate `ra' */ | 464 | /* warning!! several calls may realloc the stack and invalidate `ra' */ |
466 | ra = RA(i); | 465 | ra = RA(i); |
@@ -638,22 +637,20 @@ void luaV_execute (lua_State *L) { | |||
638 | if (luaD_precall(L, ra, nresults)) { /* C function? */ | 637 | if (luaD_precall(L, ra, nresults)) { /* C function? */ |
639 | if (nresults >= 0) L->top = ci->top; /* adjust results */ | 638 | if (nresults >= 0) L->top = ci->top; /* adjust results */ |
640 | base = ci->u.l.base; | 639 | base = ci->u.l.base; |
641 | break; | ||
642 | } | 640 | } |
643 | else { /* Lua function */ | 641 | else { /* Lua function */ |
644 | ci = L->ci; | 642 | ci = L->ci; |
645 | ci->callstatus |= CIST_REENTRY; | 643 | ci->callstatus |= CIST_REENTRY; |
646 | goto newframe; /* restart luaV_execute over new Lua function */ | 644 | goto newframe; /* restart luaV_execute over new Lua function */ |
647 | } | 645 | } |
646 | break; | ||
648 | } | 647 | } |
649 | case OP_TAILCALL: { | 648 | case OP_TAILCALL: { |
650 | int b = GETARG_B(i); | 649 | int b = GETARG_B(i); |
651 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ | 650 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ |
652 | lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); | 651 | lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); |
653 | if (luaD_precall(L, ra, LUA_MULTRET)) { /* C function? */ | 652 | if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */ |
654 | base = ci->u.l.base; | 653 | base = ci->u.l.base; |
655 | break; | ||
656 | } | ||
657 | else { | 654 | else { |
658 | /* tail call: put called frame (n) in place of caller one (o) */ | 655 | /* tail call: put called frame (n) in place of caller one (o) */ |
659 | CallInfo *nci = L->ci; /* called frame */ | 656 | CallInfo *nci = L->ci; /* called frame */ |
@@ -676,6 +673,7 @@ void luaV_execute (lua_State *L) { | |||
676 | lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); | 673 | lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); |
677 | goto newframe; /* restart luaV_execute over new Lua function */ | 674 | goto newframe; /* restart luaV_execute over new Lua function */ |
678 | } | 675 | } |
676 | break; | ||
679 | } | 677 | } |
680 | case OP_RETURN: { | 678 | case OP_RETURN: { |
681 | int b = GETARG_B(i); | 679 | int b = GETARG_B(i); |
@@ -729,9 +727,10 @@ void luaV_execute (lua_State *L) { | |||
729 | i = *(ci->u.l.savedpc++); /* go to next instruction */ | 727 | i = *(ci->u.l.savedpc++); /* go to next instruction */ |
730 | ra = RA(i); | 728 | ra = RA(i); |
731 | lua_assert(GET_OPCODE(i) == OP_TFORLOOP); | 729 | lua_assert(GET_OPCODE(i) == OP_TFORLOOP); |
732 | /* go through */ | 730 | goto l_tforloop; |
733 | } | 731 | } |
734 | case OP_TFORLOOP: { | 732 | case OP_TFORLOOP: { |
733 | l_tforloop: | ||
735 | if (!ttisnil(ra + 1)) { /* continue loop? */ | 734 | if (!ttisnil(ra + 1)) { /* continue loop? */ |
736 | setobjs2s(L, ra, ra + 1); /* save control variable */ | 735 | setobjs2s(L, ra, ra + 1); /* save control variable */ |
737 | dojump(GETARG_sBx(i)); /* jump back */ | 736 | dojump(GETARG_sBx(i)); /* jump back */ |