MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaK_setoneret

Function luaK_setoneret

3rd/lua-5.4.3/src/lcode.c:736–747  ·  view source on GitHub ↗

** Fix an expression to return one result. ** If expression is not a multi-ret expression (function call or ** vararg), it already returns one result, so nothing needs to be done. ** Function calls become VNONRELOC expressions (as its result comes ** fixed in the base register of the call), while vararg expressions ** become VRELOC (as OP_VARARG puts its results where it wants). ** (Calls are crea

Source from the content-addressed store, hash-verified

734** to be fixed.)
735*/
736void luaK_setoneret (FuncState *fs, expdesc *e) {
737 if (e->k == VCALL) { /* expression is an open function call? */
738 /* already returns 1 value */
739 lua_assert(GETARG_C(getinstruction(fs, e)) == 2);
740 e->k = VNONRELOC; /* result has fixed position */
741 e->u.info = GETARG_A(getinstruction(fs, e));
742 }
743 else if (e->k == VVARARG) {
744 SETARG_C(getinstruction(fs, e), 2);
745 e->k = VRELOC; /* can relocate its simple result */
746 }
747}
748
749
750/*

Callers 2

restassignFunction · 0.85
luaK_dischargevarsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected