Search in sources :

Example 76 with RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList in project J2ME-Loader by nikita36078.

the class Form11x method writeTo.

/**
 * {@inheritDoc}
 */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    write(out, opcodeUnit(insn, regs.get(0).getReg()));
}
Also used : RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 77 with RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList in project J2ME-Loader by nikita36078.

the class Form12x method insnArgString.

/**
 * {@inheritDoc}
 */
@Override
public String insnArgString(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int sz = regs.size();
    return regs.get(sz - 2).regString() + ", " + regs.get(sz - 1).regString();
}
Also used : RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 78 with RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList 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 79 with RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList in project J2ME-Loader by nikita36078.

the class Form12x method writeTo.

/**
 * {@inheritDoc}
 */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int sz = regs.size();
    /*
         * The (sz - 2) and (sz - 1) below makes this code work for
         * both the two- and three-register ops. (See "case 3" in
         * isCompatible(), above.)
         */
    write(out, opcodeUnit(insn, makeByte(regs.get(sz - 2).getReg(), regs.get(sz - 1).getReg())));
}
Also used : RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 80 with RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList in project J2ME-Loader by nikita36078.

the class Form12x method compatibleRegs.

/**
 * {@inheritDoc}
 */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    BitSet bits = new BitSet(2);
    int r0 = regs.get(0).getReg();
    int r1 = regs.get(1).getReg();
    switch(regs.size()) {
        case 2:
            {
                bits.set(0, unsignedFitsInNibble(r0));
                bits.set(1, unsignedFitsInNibble(r1));
                break;
            }
        case 3:
            {
                if (r0 != r1) {
                    bits.set(0, false);
                    bits.set(1, false);
                } else {
                    boolean dstRegComp = unsignedFitsInNibble(r1);
                    bits.set(0, dstRegComp);
                    bits.set(1, dstRegComp);
                }
                bits.set(2, unsignedFitsInNibble(regs.get(2).getReg()));
                break;
            }
        default:
            {
                throw new AssertionError();
            }
    }
    return bits;
}
Also used : BitSet(java.util.BitSet) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Aggregations

RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)202 RegisterSpec (com.android.dx.rop.code.RegisterSpec)50 BitSet (java.util.BitSet)45 CstLiteralBits (com.android.dx.rop.cst.CstLiteralBits)42 Constant (com.android.dx.rop.cst.Constant)36 CstInsn (com.android.dx.dex.code.CstInsn)34 PlainInsn (com.android.dx.rop.code.PlainInsn)18 CstType (com.android.dx.rop.cst.CstType)12 TargetInsn (com.android.dx.dex.code.TargetInsn)10 Insn (com.android.dx.rop.code.Insn)10 TypedConstant (com.android.dx.rop.cst.TypedConstant)10 PlainCstInsn (com.android.dx.rop.code.PlainCstInsn)8 Rop (com.android.dx.rop.code.Rop)8 CstFieldRef (com.android.dx.rop.cst.CstFieldRef)8 CstMethodRef (com.android.dx.rop.cst.CstMethodRef)8 TypeBearer (com.android.dx.rop.type.TypeBearer)8 ThrowingCstInsn (com.android.dx.rop.code.ThrowingCstInsn)6 ThrowingInsn (com.android.dx.rop.code.ThrowingInsn)6 CstInteger (com.android.dx.rop.cst.CstInteger)6 MultiCstInsn (com.android.dx.dex.code.MultiCstInsn)4