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

Function luaK_storevar

third-party/lua-5.5.0/src/lcode.c:1105–1140  ·  view source on GitHub ↗

** Generate code to store result of expression 'ex' into variable 'var'. */

Source from the content-addressed store, hash-verified

1103** Generate code to store result of expression 'ex' into variable 'var'.
1104*/
1105void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
1106 switch (var->k) {
1107 case VLOCAL: {
1108 freeexp(fs, ex);
1109 exp2reg(fs, ex, var->u.var.ridx); /* compute 'ex' into proper place */
1110 return;
1111 }
1112 case VUPVAL: {
1113 int e = luaK_exp2anyreg(fs, ex);
1114 luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0);
1115 break;
1116 }
1117 case VINDEXUP: {
1118 codeABRK(fs, OP_SETTABUP, var->u.ind.t, var->u.ind.idx, ex);
1119 break;
1120 }
1121 case VINDEXI: {
1122 codeABRK(fs, OP_SETI, var->u.ind.t, var->u.ind.idx, ex);
1123 break;
1124 }
1125 case VINDEXSTR: {
1126 codeABRK(fs, OP_SETFIELD, var->u.ind.t, var->u.ind.idx, ex);
1127 break;
1128 }
1129 case VVARGIND: {
1130 needvatab(fs->f); /* function will need a vararg table */
1131 /* now, assignment is to a regular table */
1132 } /* FALLTHROUGH */
1133 case VINDEXED: {
1134 codeABRK(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, ex);
1135 break;
1136 }
1137 default: lua_assert(0); /* invalid var kind to store */
1138 }
1139 freeexp(fs, ex);
1140}
1141
1142
1143/*

Callers 5

recfieldFunction · 0.70
storevartopFunction · 0.70
restassignFunction · 0.70
globalfuncFunction · 0.70
funcstatFunction · 0.70

Calls 5

freeexpFunction · 0.70
exp2regFunction · 0.70
luaK_exp2anyregFunction · 0.70
codeABRKFunction · 0.70
luaK_codeABCFunction · 0.50

Tested by

no test coverage detected