Search in sources :

Example 31 with CstType

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

the class DebugInfoEncoder method entryAnnotationString.

/**
     * Returns a string representation of this LocalList entry that is
     * appropriate for emitting as an annotation.
     *
     * @param e {@code non-null;} entry
     * @return {@code non-null;} annotation string
     */
private String entryAnnotationString(LocalList.Entry e) {
    StringBuilder sb = new StringBuilder();
    sb.append(RegisterSpec.PREFIX);
    sb.append(e.getRegister());
    sb.append(' ');
    CstString name = e.getName();
    if (name == null) {
        sb.append("null");
    } else {
        sb.append(name.toHuman());
    }
    sb.append(' ');
    CstType type = e.getType();
    if (type == null) {
        sb.append("null");
    } else {
        sb.append(type.toHuman());
    }
    CstString signature = e.getSignature();
    if (signature != null) {
        sb.append(' ');
        sb.append(signature.toHuman());
    }
    return sb.toString();
}
Also used : CstType(com.taobao.android.dx.rop.cst.CstType) CstString(com.taobao.android.dx.rop.cst.CstString)

Example 32 with CstType

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

the class ClassDefsSection method orderItems0.

/**
     * Helper for {@link #orderItems}, which recursively assigns indices
     * to classes.
     *
     * @param type {@code null-ok;} type ref to assign, if any
     * @param idx {@code >= 0;} the next index to assign
     * @param maxDepth maximum recursion depth; if negative, this will
     * throw an exception indicating class definition circularity
     * @return {@code >= 0;} the next index to assign
     */
private int orderItems0(Type type, int idx, int maxDepth) {
    ClassDefItem c = classDefs.get(type);
    if ((c == null) || (c.hasIndex())) {
        return idx;
    }
    if (maxDepth < 0) {
        throw new RuntimeException("class circularity with " + type);
    }
    maxDepth--;
    CstType superclassCst = c.getSuperclass();
    if (superclassCst != null) {
        Type superclass = superclassCst.getClassType();
        idx = orderItems0(superclass, idx, maxDepth);
    }
    TypeList interfaces = c.getInterfaces();
    int sz = interfaces.size();
    for (int i = 0; i < sz; i++) {
        idx = orderItems0(interfaces.getType(i), idx, maxDepth);
    }
    c.setIndex(idx);
    orderedDefs.add(c);
    return idx + 1;
}
Also used : CstType(com.taobao.android.dx.rop.cst.CstType) Type(com.taobao.android.dx.rop.type.Type) CstType(com.taobao.android.dx.rop.cst.CstType) TypeList(com.taobao.android.dx.rop.type.TypeList)

Example 33 with CstType

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

the class ClassDefsSection method get.

/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }
    throwIfNotPrepared();
    Type type = ((CstType) cst).getClassType();
    IndexedItem result = classDefs.get(type);
    if (result == null) {
        throw new IllegalArgumentException("not found");
    }
    return result;
}
Also used : CstType(com.taobao.android.dx.rop.cst.CstType) Type(com.taobao.android.dx.rop.type.Type) CstType(com.taobao.android.dx.rop.cst.CstType)

Example 34 with CstType

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

the class Annotations method add.

/**
     * Adds an element to this instance. There must not already be an
     * element of the same type.
     *
     * @param annotation {@code non-null;} the element to add
     * @throws IllegalArgumentException thrown if there is a duplicate type
     */
public void add(Annotation annotation) {
    throwIfImmutable();
    if (annotation == null) {
        throw new NullPointerException("annotation == null");
    }
    CstType type = annotation.getType();
    if (annotations.containsKey(type)) {
        throw new IllegalArgumentException("duplicate type: " + type.toHuman());
    }
    annotations.put(type, annotation);
}
Also used : CstType(com.taobao.android.dx.rop.cst.CstType)

Example 35 with CstType

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

the class TypeIdItem method writeTo.

/** {@inheritDoc} */
@Override
public void writeTo(DexFile file, AnnotatedOutput out) {
    CstType type = getDefiningClass();
    CstString descriptor = type.getDescriptor();
    int idx = file.getStringIds().indexOf(descriptor);
    if (out.annotates()) {
        out.annotate(0, indexString() + ' ' + descriptor.toHuman());
        out.annotate(4, "  descriptor_idx: " + Hex.u4(idx));
    }
    out.writeInt(idx);
}
Also used : CstType(com.taobao.android.dx.rop.cst.CstType) CstString(com.taobao.android.dx.rop.cst.CstString)

Aggregations

CstType (com.taobao.android.dx.rop.cst.CstType)36 CstString (com.taobao.android.dx.rop.cst.CstString)14 Constant (com.taobao.android.dx.rop.cst.Constant)12 Type (com.taobao.android.dx.rop.type.Type)9 CstFieldRef (com.taobao.android.dx.rop.cst.CstFieldRef)7 CstMethodRef (com.taobao.android.dx.rop.cst.CstMethodRef)6 CstInsn (com.taobao.android.dx.dex.code.CstInsn)5 Annotations (com.taobao.android.dx.rop.annotation.Annotations)5 RegisterSpec (com.taobao.android.dx.rop.code.RegisterSpec)5 RegisterSpecList (com.taobao.android.dx.rop.code.RegisterSpecList)5 Annotation (com.taobao.android.dx.rop.annotation.Annotation)4 CstNat (com.taobao.android.dx.rop.cst.CstNat)4 IntList (com.taobao.android.dx.util.IntList)4 AttEnclosingMethod (com.taobao.android.dx.cf.attrib.AttEnclosingMethod)3 NameValuePair (com.taobao.android.dx.rop.annotation.NameValuePair)3 ConstantPool (com.taobao.android.dx.rop.cst.ConstantPool)3 TypeList (com.taobao.android.dx.rop.type.TypeList)3 ByteArray (com.taobao.android.dx.util.ByteArray)3 AttInnerClasses (com.taobao.android.dx.cf.attrib.AttInnerClasses)2 AttRuntimeInvisibleAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeInvisibleAnnotations)2