Search in sources :

Example 21 with CstInsn

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

the class Form21h method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) && (regs.size() == 1) && unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();
    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }
    CstLiteralBits cb = (CstLiteralBits) cst;
    // Where the high bits are depends on the category of the target.
    if (regs.get(0).getCategory() == 1) {
        int bits = cb.getIntBits();
        return ((bits & 0xffff) == 0);
    } else {
        long bits = cb.getLongBits();
        return ((bits & 0xffffffffffffL) == 0);
    }
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) CstLiteralBits(com.android.dx.rop.cst.CstLiteralBits) Constant(com.android.dx.rop.cst.Constant) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 22 with CstInsn

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

the class Form22b method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) && (regs.size() == 2) && unsignedFitsInByte(regs.get(0).getReg()) && unsignedFitsInByte(regs.get(1).getReg()))) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();
    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }
    CstLiteralBits cb = (CstLiteralBits) cst;
    return cb.fitsInInt() && signedFitsInByte(cb.getIntBits());
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) CstLiteralBits(com.android.dx.rop.cst.CstLiteralBits) Constant(com.android.dx.rop.cst.Constant) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 23 with CstInsn

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

the class Form31i method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) && (regs.size() == 1) && unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();
    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }
    return ((CstLiteralBits) cst).fitsInInt();
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) CstLiteralBits(com.android.dx.rop.cst.CstLiteralBits) Constant(com.android.dx.rop.cst.Constant) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 24 with CstInsn

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

the class Form11n method isCompatible.

/**
 * {@inheritDoc}
 */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) && (regs.size() == 1) && unsignedFitsInNibble(regs.get(0).getReg()))) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();
    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }
    CstLiteralBits cb = (CstLiteralBits) cst;
    return cb.fitsInInt() && signedFitsInNibble(cb.getIntBits());
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) CstLiteralBits(com.android.dx.rop.cst.CstLiteralBits) Constant(com.android.dx.rop.cst.Constant) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 25 with CstInsn

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

the class Form21c method writeTo.

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

Aggregations

CstInsn (com.android.dx.dex.code.CstInsn)34 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)34 Constant (com.android.dx.rop.cst.Constant)24 CstLiteralBits (com.android.dx.rop.cst.CstLiteralBits)12 CstType (com.android.dx.rop.cst.CstType)10 CstFieldRef (com.android.dx.rop.cst.CstFieldRef)6 RegisterSpec (com.android.dx.rop.code.RegisterSpec)4 CstMethodRef (com.android.dx.rop.cst.CstMethodRef)4 CstString (com.android.dx.rop.cst.CstString)4 CstLiteral64 (com.android.dx.rop.cst.CstLiteral64)2