MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / luaK_storevar

Function luaK_storevar

libraries/AP_Scripting/lua/src/lcode.c:789–810  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

787** Generate code to store result of expression 'ex' into variable 'var'.
788*/
789void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
790 switch (var->k) {
791 case VLOCAL: {
792 freeexp(fs, ex);
793 exp2reg(fs, ex, var->u.info); /* compute 'ex' into proper place */
794 return;
795 }
796 case VUPVAL: {
797 int e = luaK_exp2anyreg(fs, ex);
798 luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0);
799 break;
800 }
801 case VINDEXED: {
802 OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP;
803 int e = luaK_exp2RK(fs, ex);
804 luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
805 break;
806 }
807 default: lua_assert(0); /* invalid var kind to store */
808 }
809 freeexp(fs, ex);
810}
811
812
813/*

Callers 2

assignmentFunction · 0.85
funcstatFunction · 0.85

Calls 5

freeexpFunction · 0.85
exp2regFunction · 0.85
luaK_exp2anyregFunction · 0.85
luaK_codeABCFunction · 0.85
luaK_exp2RKFunction · 0.85

Tested by

no test coverage detected