| 426 | |
| 427 | |
| 428 | void luaV_execute (lua_State *L, int nexeccalls) { |
| 429 | LClosure *cl; |
| 430 | StkId base; |
| 431 | TValue *k; |
| 432 | const Instruction *pc; |
| 433 | reentry: /* entry point */ |
| 434 | lua_assert(isLua(L->ci)); |
| 435 | pc = L->savedpc; |
| 436 | cl = &clvalue(L->ci->func)->l; |
| 437 | base = L->base; |
| 438 | k = cl->p->k; |
| 439 | /* main loop of interpreter */ |
| 440 | for (;;) { |
| 441 | const Instruction i = *pc++; |
| 442 | StkId ra; |
| 443 | if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && |
| 444 | (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { |
| 445 | traceexec(L, pc); |
| 446 | if (L->status == LUA_YIELD) { /* did hook yield? */ |
| 447 | L->savedpc = pc - 1; |
| 448 | return; |
| 449 | } |
| 450 | base = L->base; |
| 451 | } |
| 452 | /* warning!! several calls may realloc the stack and invalidate `ra' */ |
| 453 | ra = RA(i); |
| 454 | lua_assert(base == L->base && L->base == L->ci->base); |
| 455 | lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); |
| 456 | lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); |
| 457 | switch (GET_OPCODE(i)) { |
| 458 | case OP_MOVE: { |
| 459 | assign_op(GET_OPCODE(i)); |
| 460 | continue; |
| 461 | } |
| 462 | case OP_LOADK: { |
| 463 | TValue *rb = RKB(i); |
| 464 | const TValue *tm = luaT_gettmbyobj(L, rb, TM_TYPE); |
| 465 | if (ttisuserdata(rb) && !ttisnil(tm)) { |
| 466 | Protect(Arith(L, ra, rb, KBx(i), TM_TYPE)); |
| 467 | } else { |
| 468 | setobj2s(L, ra, KBx(i)); |
| 469 | } |
| 470 | continue; |
| 471 | } |
| 472 | case OP_LOADBOOL: { |
| 473 | setbvalue(ra, GETARG_B(i)); |
| 474 | if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ |
| 475 | continue; |
| 476 | } |
| 477 | case OP_LOADNIL: { |
| 478 | TValue *rb = RB(i); |
| 479 | do { |
| 480 | setnilvalue(rb--); |
| 481 | } while (rb >= ra); |
| 482 | continue; |
| 483 | } |
| 484 | case OP_GETUPVAL: { |
| 485 | int b = GETARG_B(i); |
no test coverage detected