MCPcopy Create free account
hub / github.com/Tencent/sluaunreal / patchtestreg

Function patchtestreg

Plugins/slua_unreal/External/lua/lcode.cpp:193–205  ·  view source on GitHub ↗

** Patch destination register for a TESTSET instruction. ** If instruction in position 'node' is not a TESTSET, return 0 ("fails"). ** Otherwise, if 'reg' is not 'NO_REG', set it as the destination ** register. Otherwise, change instruction to a simple 'TEST' (produces ** no register value) */

Source from the content-addressed store, hash-verified

191** no register value)
192*/
193static int patchtestreg (FuncState *fs, int node, int reg) {
194 Instruction *i = getjumpcontrol(fs, node);
195 if (GET_OPCODE(*i) != OP_TESTSET)
196 return 0; /* cannot patch other instructions */
197 if (reg != NO_REG && reg != GETARG_B(*i))
198 SETARG_A(*i, reg);
199 else {
200 /* no register to put value or register already has the value;
201 change instruction to simple test */
202 *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
203 }
204 return 1;
205}
206
207
208/*

Callers 2

removevaluesFunction · 0.85
patchlistauxFunction · 0.85

Calls 1

getjumpcontrolFunction · 0.85

Tested by

no test coverage detected