MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / exp2reg

Function exp2reg

xrepo/packages/l/lua/port/lua/src/lcode.c:914–936  ·  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

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

Callers 3

luaK_exp2nextregFunction · 0.85
luaK_exp2anyregFunction · 0.85
luaK_storevarFunction · 0.85

Calls 8

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

Tested by

no test coverage detected