Search in sources :

Example 1 with SimpleInsn

use of com.android.dx.dex.code.SimpleInsn in project J2ME-Loader by nikita36078.

the class Form12x method isCompatible.

/**
 * {@inheritDoc}
 */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof SimpleInsn)) {
        return false;
    }
    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec rs1;
    RegisterSpec rs2;
    switch(regs.size()) {
        case 2:
            {
                rs1 = regs.get(0);
                rs2 = regs.get(1);
                break;
            }
        case 3:
            {
                /*
                 * This format is allowed for ops that are effectively
                 * 3-arg but where the first two args are identical.
                 */
                rs1 = regs.get(1);
                rs2 = regs.get(2);
                if (rs1.getReg() != regs.get(0).getReg()) {
                    return false;
                }
                break;
            }
        default:
            {
                return false;
            }
    }
    return unsignedFitsInNibble(rs1.getReg()) && unsignedFitsInNibble(rs2.getReg());
}
Also used : SimpleInsn(com.android.dx.dex.code.SimpleInsn) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Example 2 with SimpleInsn

use of com.android.dx.dex.code.SimpleInsn in project buck by facebook.

the class Form12x method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof SimpleInsn)) {
        return false;
    }
    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec rs1;
    RegisterSpec rs2;
    switch(regs.size()) {
        case 2:
            {
                rs1 = regs.get(0);
                rs2 = regs.get(1);
                break;
            }
        case 3:
            {
                /*
                 * This format is allowed for ops that are effectively
                 * 3-arg but where the first two args are identical.
                 */
                rs1 = regs.get(1);
                rs2 = regs.get(2);
                if (rs1.getReg() != regs.get(0).getReg()) {
                    return false;
                }
                break;
            }
        default:
            {
                return false;
            }
    }
    return unsignedFitsInNibble(rs1.getReg()) && unsignedFitsInNibble(rs2.getReg());
}
Also used : SimpleInsn(com.android.dx.dex.code.SimpleInsn) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Aggregations

SimpleInsn (com.android.dx.dex.code.SimpleInsn)2 RegisterSpec (com.android.dx.rop.code.RegisterSpec)2 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)2