Search in sources :

Example 6 with CstArray

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

the class AnnotationUtils method makeSignature.

/**
     * Constructs a standard {@code Signature} annotation.
     *
     * @param signature {@code non-null;} the signature string
     * @return {@code non-null;} the annotation
     */
public static Annotation makeSignature(CstString signature) {
    Annotation result = new Annotation(SIGNATURE_TYPE, SYSTEM);
    /*
         * Split the string into pieces that are likely to be common
         * across many signatures and the rest of the file.
         */
    String raw = signature.getString();
    int rawLength = raw.length();
    ArrayList<String> pieces = new ArrayList<String>(20);
    for (int at = 0; at < rawLength; ) /*at*/
    {
        char c = raw.charAt(at);
        int endAt = at + 1;
        if (c == 'L') {
            // Scan to ';' or '<'. Consume ';' but not '<'.
            while (endAt < rawLength) {
                c = raw.charAt(endAt);
                if (c == ';') {
                    endAt++;
                    break;
                } else if (c == '<') {
                    break;
                }
                endAt++;
            }
        } else {
            // Scan to 'L' without consuming it.
            while (endAt < rawLength) {
                c = raw.charAt(endAt);
                if (c == 'L') {
                    break;
                }
                endAt++;
            }
        }
        pieces.add(raw.substring(at, endAt));
        at = endAt;
    }
    int size = pieces.size();
    CstArray.List list = new CstArray.List(size);
    for (int i = 0; i < size; i++) {
        list.set(i, new CstString(pieces.get(i)));
    }
    list.setImmutable();
    result.put(new NameValuePair(VALUE_STRING, new CstArray(list)));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) CstArray(com.taobao.android.dx.rop.cst.CstArray) ArrayList(java.util.ArrayList) CstString(com.taobao.android.dx.rop.cst.CstString) ArrayList(java.util.ArrayList) TypeList(com.taobao.android.dx.rop.type.TypeList) CstString(com.taobao.android.dx.rop.cst.CstString) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Example 7 with CstArray

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

the class AnnotationUtils method makeThrows.

/**
     * Constructs a standard {@code Throws} annotation.
     *
     * @param types {@code non-null;} the list of thrown types
     * @return {@code non-null;} the annotation
     */
public static Annotation makeThrows(TypeList types) {
    CstArray array = makeCstArray(types);
    Annotation result = new Annotation(THROWS_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, array));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) CstArray(com.taobao.android.dx.rop.cst.CstArray) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Aggregations

CstArray (com.taobao.android.dx.rop.cst.CstArray)7 Annotation (com.taobao.android.dx.rop.annotation.Annotation)4 CstAnnotation (com.taobao.android.dx.rop.cst.CstAnnotation)4 NameValuePair (com.taobao.android.dx.rop.annotation.NameValuePair)3 Constant (com.taobao.android.dx.rop.cst.Constant)2 CstString (com.taobao.android.dx.rop.cst.CstString)2 ArrayList (java.util.ArrayList)2 ParseException (com.taobao.android.dx.cf.iface.ParseException)1 AnnotationsList (com.taobao.android.dx.rop.annotation.AnnotationsList)1 CstDouble (com.taobao.android.dx.rop.cst.CstDouble)1 CstEnumRef (com.taobao.android.dx.rop.cst.CstEnumRef)1 CstFloat (com.taobao.android.dx.rop.cst.CstFloat)1 CstInteger (com.taobao.android.dx.rop.cst.CstInteger)1 CstLiteralBits (com.taobao.android.dx.rop.cst.CstLiteralBits)1 CstLong (com.taobao.android.dx.rop.cst.CstLong)1 CstNat (com.taobao.android.dx.rop.cst.CstNat)1 CstType (com.taobao.android.dx.rop.cst.CstType)1 Type (com.taobao.android.dx.rop.type.Type)1 TypeList (com.taobao.android.dx.rop.type.TypeList)1