Search in sources :

Example 21 with CstFieldRef

use of com.android.dx.rop.cst.CstFieldRef in project J2ME-Loader by nikita36078.

the class Form21c method isCompatible.

/**
 * {@inheritDoc}
 */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }
    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec reg;
    switch(regs.size()) {
        case 1:
            {
                reg = regs.get(0);
                break;
            }
        case 2:
            {
                /*
                 * This format is allowed for ops that are effectively
                 * 2-arg but where the two args are identical.
                 */
                reg = regs.get(0);
                if (reg.getReg() != regs.get(1).getReg()) {
                    return false;
                }
                break;
            }
        default:
            {
                return false;
            }
    }
    if (!unsignedFitsInByte(reg.getReg())) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();
    Constant cst = ci.getConstant();
    if (!unsignedFitsInShort(cpi)) {
        return false;
    }
    return (cst instanceof CstType) || (cst instanceof CstFieldRef) || (cst instanceof CstString);
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) Constant(com.android.dx.rop.cst.Constant) CstType(com.android.dx.rop.cst.CstType) CstFieldRef(com.android.dx.rop.cst.CstFieldRef) CstString(com.android.dx.rop.cst.CstString) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Aggregations

CstFieldRef (com.android.dx.rop.cst.CstFieldRef)21 CstType (com.android.dx.rop.cst.CstType)21 Constant (com.android.dx.rop.cst.Constant)19 CstString (com.android.dx.rop.cst.CstString)12 CstMethodRef (com.android.dx.rop.cst.CstMethodRef)9 RegisterSpec (com.android.dx.rop.code.RegisterSpec)8 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)8 CstInsn (com.android.dx.dex.code.CstInsn)6 FieldList (com.android.dx.cf.iface.FieldList)4 Annotations (com.android.dx.rop.annotation.Annotations)4 Rop (com.android.dx.rop.code.Rop)4 ThrowingCstInsn (com.android.dx.rop.code.ThrowingCstInsn)4 CstInterfaceMethodRef (com.android.dx.rop.cst.CstInterfaceMethodRef)4 TypedConstant (com.android.dx.rop.cst.TypedConstant)4 Prototype (com.android.dx.rop.type.Prototype)3 StdTypeList (com.android.dx.rop.type.StdTypeList)3 Field (com.android.dx.cf.iface.Field)2 MethodList (com.android.dx.cf.iface.MethodList)2 ParseException (com.android.dx.cf.iface.ParseException)2 ClassDefItem (com.android.dx.dex.file.ClassDefItem)2