MCPcopy Create free account
hub / github.com/DFHack/dfhack / patchtestreg

Function patchtestreg

depends/lua/src/lcode.c:195–207  ·  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

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

Callers 2

removevaluesFunction · 0.85
patchlistauxFunction · 0.85

Calls 1

getjumpcontrolFunction · 0.85

Tested by

no test coverage detected