MCPcopy Create free account
hub / github.com/TASEmulators/fceux / luaV_execute

Function luaV_execute

src/lua/src/lvm.c:373–762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371
372
373void luaV_execute (lua_State *L, int nexeccalls) {
374 LClosure *cl;
375 StkId base;
376 TValue *k;
377 const Instruction *pc;
378 reentry: /* entry point */
379 lua_assert(isLua(L->ci));
380 pc = L->savedpc;
381 cl = &clvalue(L->ci->func)->l;
382 base = L->base;
383 k = cl->p->k;
384 /* main loop of interpreter */
385 for (;;) {
386 const Instruction i = *pc++;
387 StkId ra;
388 if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
389 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
390 traceexec(L, pc);
391 if (L->status == LUA_YIELD) { /* did hook yield? */
392 L->savedpc = pc - 1;
393 return;
394 }
395 base = L->base;
396 }
397 /* warning!! several calls may realloc the stack and invalidate `ra' */
398 ra = RA(i);
399 lua_assert(base == L->base && L->base == L->ci->base);
400 lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
401 lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
402 switch (GET_OPCODE(i)) {
403 case OP_MOVE: {
404 setobjs2s(L, ra, RB(i));
405 continue;
406 }
407 case OP_LOADK: {
408 setobj2s(L, ra, KBx(i));
409 continue;
410 }
411 case OP_LOADBOOL: {
412 setbvalue(ra, GETARG_B(i));
413 if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
414 continue;
415 }
416 case OP_LOADNIL: {
417 TValue *rb = RB(i);
418 do {
419 setnilvalue(rb--);
420 } while (rb >= ra);
421 continue;
422 }
423 case OP_GETUPVAL: {
424 int b = GETARG_B(i);
425 setobj2s(L, ra, cl->upvals[b]->v);
426 continue;
427 }
428 case OP_GETGLOBAL: {
429 TValue g;
430 TValue *rb = KBx(i);

Callers 2

luaD_callFunction · 0.85
resumeFunction · 0.85

Calls 15

traceexecFunction · 0.85
luaG_checkopenopFunction · 0.85
luaV_gettableFunction · 0.85
luaV_settableFunction · 0.85
luaH_newFunction · 0.85
luaO_fb2intFunction · 0.85
ArithFunction · 0.85
luaH_getnFunction · 0.85
call_binTMFunction · 0.85
luaG_typeerrorFunction · 0.85
luaV_concatFunction · 0.85
luaV_lessthanFunction · 0.85

Tested by

no test coverage detected