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);
}
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));
}
Aggregations