Ejemplo n.º 1
0
        private bool patchtestreg(int node, int reg)
        {
            int i = getjumpcontrol(node);

            int[] code  = f.code_Renamed;
            int   instr = code[i];

            if (Lua.OPCODE(instr) != Lua.OP_TESTSET)
            {
                return(false);  // cannot patch other instructions
            }
            if (reg != Lua.NO_REG && reg != Lua.ARGB(instr))
            {
                code[i] = Lua.SETARG_A(instr, reg);
            }
            else     // no register to put value or register already has the value
            {
                code[i] = Lua.CREATE_ABC(Lua.OP_TEST, Lua.ARGB(instr), 0, Lua.ARGC(instr));
            }

            return(true);
        }