MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / patchtestreg

Function patchtestreg

src/lcode.cpp:261–273  ·  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

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

Callers 2

removevaluesFunction · 0.85
patchlistauxFunction · 0.85

Calls 1

getjumpcontrolFunction · 0.85

Tested by

no test coverage detected