MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaK_dischargevars

Function luaK_dischargevars

depends/lua/src/lcode.c:556–588  ·  view source on GitHub ↗

** Ensure that expression 'e' is not a variable. */

Source from the content-addressed store, hash-verified

554** Ensure that expression 'e' is not a variable.
555*/
556void luaK_dischargevars (FuncState *fs, expdesc *e) {
557 switch (e->k) {
558 case VLOCAL: { /* already in a register */
559 e->k = VNONRELOC; /* becomes a non-relocatable value */
560 break;
561 }
562 case VUPVAL: { /* move value to some (pending) register */
563 e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0);
564 e->k = VRELOCABLE;
565 break;
566 }
567 case VINDEXED: {
568 OpCode op;
569 freereg(fs, e->u.ind.idx);
570 if (e->u.ind.vt == VLOCAL) { /* is 't' in a register? */
571 freereg(fs, e->u.ind.t);
572 op = OP_GETTABLE;
573 }
574 else {
575 lua_assert(e->u.ind.vt == VUPVAL);
576 op = OP_GETTABUP; /* 't' is in an upvalue */
577 }
578 e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx);
579 e->k = VRELOCABLE;
580 break;
581 }
582 case VVARARG: case VCALL: {
583 luaK_setoneret(fs, e);
584 break;
585 }
586 default: break; /* there is one value available (somewhere) */
587 }
588}
589
590
591/*

Callers 9

primaryexpFunction · 0.85
discharge2regFunction · 0.85
luaK_exp2nextregFunction · 0.85
luaK_exp2anyregFunction · 0.85
luaK_exp2valFunction · 0.85
luaK_goiftrueFunction · 0.85
luaK_goiffalseFunction · 0.85
codenotFunction · 0.85
luaK_posfixFunction · 0.85

Calls 3

luaK_codeABCFunction · 0.85
freeregFunction · 0.85
luaK_setoneretFunction · 0.85

Tested by

no test coverage detected