MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / patchtestreg

Function patchtestreg

extlibs/lua/src/lcode.c:258–270  ·  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

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

Callers 2

removevaluesFunction · 0.85
patchlistauxFunction · 0.85

Calls 1

getjumpcontrolFunction · 0.85

Tested by

no test coverage detected