MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / patchtestreg

Function patchtestreg

lib/lua/src/lcode.c:259–271  ·  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

257** no register value)
258*/
259static int patchtestreg (FuncState *fs, int node, int reg) {
260 Instruction *i = getjumpcontrol(fs, node);
261 if (GET_OPCODE(*i) != OP_TESTSET)
262 return 0; /* cannot patch other instructions */
263 if (reg != NO_REG && reg != GETARG_B(*i))
264 SETARG_A(*i, reg);
265 else {
266 /* no register to put value or register already has the value;
267 change instruction to simple test */
268 *i = CREATE_ABCk(OP_TEST, GETARG_B(*i), 0, 0, GETARG_k(*i));
269 }
270 return 1;
271}
272
273
274/*

Callers 2

removevaluesFunction · 0.85
patchlistauxFunction · 0.85

Calls 1

getjumpcontrolFunction · 0.85

Tested by

no test coverage detected