Search in sources :

Example 6 with CstMethodRef

use of com.taobao.android.dx.rop.cst.CstMethodRef in project atlas by alibaba.

the class Form35c method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();
    if (!unsignedFitsInShort(cpi)) {
        return false;
    }
    Constant cst = ci.getConstant();
    if (!((cst instanceof CstMethodRef) || (cst instanceof CstType))) {
        return false;
    }
    RegisterSpecList regs = ci.getRegisters();
    return (wordCount(regs) >= 0);
}
Also used : CstInsn(com.taobao.android.dx.dex.code.CstInsn) Constant(com.taobao.android.dx.rop.cst.Constant) CstType(com.taobao.android.dx.rop.cst.CstType) CstMethodRef(com.taobao.android.dx.rop.cst.CstMethodRef) RegisterSpecList(com.taobao.android.dx.rop.code.RegisterSpecList)

Example 7 with CstMethodRef

use of com.taobao.android.dx.rop.cst.CstMethodRef in project atlas by alibaba.

the class AttributeTranslator method translateEnclosingMethod.

/**
     * Gets the {@code EnclosingMethod} attribute out of a given
     * {@link AttributeList}, if any, translating it to an annotation.
     * If the class really has an enclosing method, this returns an
     * {@code EnclosingMethod} annotation; if not, this returns
     * an {@code EnclosingClass} annotation.
     *
     * @param attribs {@code non-null;} the attributes list to search in
     * @return {@code null-ok;} the converted {@code EnclosingMethod} or
     * {@code EnclosingClass} annotation, if there was an
     * attribute to translate
     */
private static Annotation translateEnclosingMethod(AttributeList attribs) {
    AttEnclosingMethod enclosingMethod = (AttEnclosingMethod) attribs.findFirst(AttEnclosingMethod.ATTRIBUTE_NAME);
    if (enclosingMethod == null) {
        return null;
    }
    CstType enclosingClass = enclosingMethod.getEnclosingClass();
    CstNat nat = enclosingMethod.getMethod();
    if (nat == null) {
        /*
             * Dalvik doesn't use EnclosingMethod annotations unless
             * there really is an enclosing method. Anonymous classes
             * are unambiguously identified by having an InnerClass
             * annotation with an empty name along with an appropriate
             * EnclosingClass.
             */
        return AnnotationUtils.makeEnclosingClass(enclosingClass);
    }
    return AnnotationUtils.makeEnclosingMethod(new CstMethodRef(enclosingClass, nat));
}
Also used : CstNat(com.taobao.android.dx.rop.cst.CstNat) AttEnclosingMethod(com.taobao.android.dx.cf.attrib.AttEnclosingMethod) CstType(com.taobao.android.dx.rop.cst.CstType) CstMethodRef(com.taobao.android.dx.rop.cst.CstMethodRef)

Aggregations

CstMethodRef (com.taobao.android.dx.rop.cst.CstMethodRef)7 CstType (com.taobao.android.dx.rop.cst.CstType)7 Constant (com.taobao.android.dx.rop.cst.Constant)4 RegisterSpecList (com.taobao.android.dx.rop.code.RegisterSpecList)3 CstString (com.taobao.android.dx.rop.cst.CstString)3 CstInsn (com.taobao.android.dx.dex.code.CstInsn)2 Annotations (com.taobao.android.dx.rop.annotation.Annotations)2 RegisterSpec (com.taobao.android.dx.rop.code.RegisterSpec)2 CstFieldRef (com.taobao.android.dx.rop.cst.CstFieldRef)2 CstNat (com.taobao.android.dx.rop.cst.CstNat)2 AttEnclosingMethod (com.taobao.android.dx.cf.attrib.AttEnclosingMethod)1 ConcreteMethod (com.taobao.android.dx.cf.code.ConcreteMethod)1 Method (com.taobao.android.dx.cf.iface.Method)1 MethodList (com.taobao.android.dx.cf.iface.MethodList)1 DalvCode (com.taobao.android.dx.dex.code.DalvCode)1 ClassDefItem (com.taobao.android.dx.dex.file.ClassDefItem)1 EncodedMethod (com.taobao.android.dx.dex.file.EncodedMethod)1 FieldIdsSection (com.taobao.android.dx.dex.file.FieldIdsSection)1 MethodIdsSection (com.taobao.android.dx.dex.file.MethodIdsSection)1 AnnotationsList (com.taobao.android.dx.rop.annotation.AnnotationsList)1