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

Function patchtestreg

third-party/lua-5.4.6/src/lcode.c:260–272  ·  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

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

Callers 2

removevaluesFunction · 0.70
patchlistauxFunction · 0.70

Calls 1

getjumpcontrolFunction · 0.70

Tested by

no test coverage detected