MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / exp2reg

Function exp2reg

third-party/lua-5.4.6/src/lcode.c:916–938  ·  view source on GitHub ↗

** Ensures final expression result (which includes results from its ** jump lists) is in register 'reg'. ** If expression has jumps, need to patch these jumps either to ** its final position or to "load" instructions (for those tests ** that do not produce values). */

Source from the content-addressed store, hash-verified

914** that do not produce values).
915*/
916static void exp2reg (FuncState *fs, expdesc *e, int reg) {
917 discharge2reg(fs, e, reg);
918 if (e->k == VJMP) /* expression itself is a test? */
919 luaK_concat(fs, &e->t, e->u.info); /* put this jump in 't' list */
920 if (hasjumps(e)) {
921 int final; /* position after whole expression */
922 int p_f = NO_JUMP; /* position of an eventual LOAD false */
923 int p_t = NO_JUMP; /* position of an eventual LOAD true */
924 if (need_value(fs, e->t) || need_value(fs, e->f)) {
925 int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
926 p_f = code_loadbool(fs, reg, OP_LFALSESKIP); /* skip next inst. */
927 p_t = code_loadbool(fs, reg, OP_LOADTRUE);
928 /* jump around these booleans if 'e' is not a test */
929 luaK_patchtohere(fs, fj);
930 }
931 final = luaK_getlabel(fs);
932 patchlistaux(fs, e->f, final, reg, p_f);
933 patchlistaux(fs, e->t, final, reg, p_t);
934 }
935 e->f = e->t = NO_JUMP;
936 e->u.info = reg;
937 e->k = VNONRELOC;
938}
939
940
941/*

Callers 3

luaK_exp2nextregFunction · 0.70
luaK_exp2anyregFunction · 0.70
luaK_storevarFunction · 0.70

Calls 8

discharge2regFunction · 0.70
luaK_concatFunction · 0.70
need_valueFunction · 0.70
luaK_jumpFunction · 0.70
code_loadboolFunction · 0.70
luaK_patchtohereFunction · 0.70
luaK_getlabelFunction · 0.70
patchlistauxFunction · 0.70

Tested by

no test coverage detected