com.android.dx.rop.type.TypeList Java Examples

The following examples show how to use com.android.dx.rop.type.TypeList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: Box   Author: lulululbj   File: StdCatchBuilder.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public HashSet<Type> getCatchTypes() {
    HashSet<Type> result = new HashSet<Type>(20);
    BasicBlockList blocks = method.getBlocks();
    int size = blocks.size();

    for (int i = 0; i < size; i++) {
        BasicBlock block = blocks.get(i);
        TypeList catches = block.getLastInsn().getCatches();
        int catchSize = catches.size();

        for (int j = 0; j < catchSize; j++) {
            result.add(catches.getType(j));
        }
    }

    return result;
}
 
Example #2
Source Project: J2ME-Loader   Author: nikita36078   File: StdAttributeFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Parses an {@code Exceptions} attribute.
 */
private Attribute exceptions(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset); // number_of_exceptions

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                        "number_of_exceptions: " + Hex.u2(count));
    }

    offset += 2;
    length -= 2;

    if (length != (count * 2)) {
        throwBadLength((count * 2) + 2);
    }

    TypeList list = cf.makeTypeList(offset, count);
    return new AttExceptions(list);
}
 
Example #3
Source Project: Box   Author: lulululbj   File: ClassDefItem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance. Its sets of members and annotations are
 * initially empty.
 *
 * @param thisClass {@code non-null;} type constant for this class
 * @param accessFlags access flags
 * @param superclass {@code null-ok;} superclass or {@code null} if
 * this class is a/the root class
 * @param interfaces {@code non-null;} list of implemented interfaces
 * @param sourceFile {@code null-ok;} source file name or
 * {@code null} if unknown
 */
public ClassDefItem(CstType thisClass, int accessFlags,
        CstType superclass, TypeList interfaces, CstString sourceFile) {
    if (thisClass == null) {
        throw new NullPointerException("thisClass == null");
    }

    /*
     * TODO: Maybe check accessFlags and superclass, at
     * least for easily-checked stuff?
     */

    if (interfaces == null) {
        throw new NullPointerException("interfaces == null");
    }

    this.thisClass = thisClass;
    this.accessFlags = accessFlags;
    this.superclass = superclass;
    this.interfaces =
        (interfaces.size() == 0) ? null :  new TypeListItem(interfaces);
    this.sourceFile = sourceFile;
    this.classData = new ClassDataItem(thisClass);
    this.staticValuesItem = null;
    this.annotationsDirectory = new AnnotationsDirectoryItem();
}
 
Example #4
Source Project: buck   Author: facebook   File: ThrowingInsn.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param opcode {@code non-null;} the opcode
 * @param position {@code non-null;} source position
 * @param sources {@code non-null;} specs for all the sources
 * @param catches {@code non-null;} list of exceptions caught
 */
public ThrowingInsn(Rop opcode, SourcePosition position,
                    RegisterSpecList sources,
                    TypeList catches) {
    super(opcode, position, null, sources);

    if (opcode.getBranchingness() != Rop.BRANCH_THROW) {
        throw new IllegalArgumentException("bogus branchingness");
    }

    if (catches == null) {
        throw new NullPointerException("catches == null");
    }

    this.catches = catches;
}
 
Example #5
Source Project: J2ME-Loader   Author: nikita36078   File: EncodedMethod.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} constant for the method
 * @param accessFlags access flags
 * @param code {@code null-ok;} code for the method, if it is neither
 * {@code abstract} nor {@code native}
 * @param throwsList {@code non-null;} list of possibly-thrown exceptions,
 * just used in generating debugging output (listings)
 */
public EncodedMethod(CstMethodRef method, int accessFlags,
        DalvCode code, TypeList throwsList) {
    super(accessFlags);

    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    if (code == null) {
        this.code = null;
    } else {
        boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0;
        this.code = new CodeItem(method, code, isStatic, throwsList);
    }
}
 
Example #6
Source Project: Box   Author: lulululbj   File: StdAttributeFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Parses an {@code Exceptions} attribute.
 */
private Attribute exceptions(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset); // number_of_exceptions

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                        "number_of_exceptions: " + Hex.u2(count));
    }

    offset += 2;
    length -= 2;

    if (length != (count * 2)) {
        throwBadLength((count * 2) + 2);
    }

    TypeList list = cf.makeTypeList(offset, count);
    return new AttExceptions(list);
}
 
Example #7
Source Project: J2ME-Loader   Author: nikita36078   File: StdCatchBuilder.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
   @Override
public boolean hasAnyCatches() {
       BasicBlockList blocks = method.getBlocks();
       int size = blocks.size();

       for (int i = 0; i < size; i++) {
           BasicBlock block = blocks.get(i);
           TypeList catches = block.getLastInsn().getCatches();
           if (catches.size() != 0) {
               return true;
           }
       }

       return false;
   }
 
Example #8
Source Project: Box   Author: lulululbj   File: StdCatchBuilder.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean hasAnyCatches() {
    BasicBlockList blocks = method.getBlocks();
    int size = blocks.size();

    for (int i = 0; i < size; i++) {
        BasicBlock block = blocks.get(i);
        TypeList catches = block.getLastInsn().getCatches();
        if (catches.size() != 0) {
            return true;
        }
    }

    return false;
}
 
Example #9
Source Project: buck   Author: facebook   File: ThrowingCstInsn.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param opcode {@code non-null;} the opcode
 * @param position {@code non-null;} source position
 * @param sources {@code non-null;} specs for all the sources
 * @param catches {@code non-null;} list of exceptions caught
 * @param cst {@code non-null;} the constant
 */
public ThrowingCstInsn(Rop opcode, SourcePosition position,
                       RegisterSpecList sources,
                       TypeList catches, Constant cst) {
    super(opcode, position, null, sources, cst);

    if (opcode.getBranchingness() != Rop.BRANCH_THROW) {
        throw new IllegalArgumentException("bogus branchingness");
    }

    if (catches == null) {
        throw new NullPointerException("catches == null");
    }

    this.catches = catches;
}
 
Example #10
Source Project: J2ME-Loader   Author: nikita36078   File: Rops.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate binary arithmetic rop for the given type
 * and arguments. The result is a shared instance.
 *
 * @param types {@code non-null;} sources of the operation
 * @param int1 {@code non-null;} the int-to-constant rop
 * @param long1 {@code non-null;} the long-to-constant rop
 * @param float1 {@code null-ok;} the float-to-constant rop, if any
 * @param double1 {@code null-ok;} the double-to-constant rop, if any
 * @param int2 {@code non-null;} the int-to-int rop
 * @param long2 {@code non-null;} the long-to-long or long-to-int rop
 * @param float2 {@code null-ok;} the float-to-float rop, if any
 * @param double2 {@code null-ok;} the double-to-double rop, if any
 * @return {@code non-null;} an appropriate instance
 */
private static Rop pickBinaryOp(TypeList types, Rop int1, Rop long1,
                                Rop float1, Rop double1, Rop int2,
                                Rop long2, Rop float2, Rop double2) {
    int bt1 = types.getType(0).getBasicFrameType();
    Rop result = null;

    switch (types.size()) {
        case 1: {
            switch(bt1) {
                case Type.BT_INT:    return int1;
                case Type.BT_LONG:   return long1;
                case Type.BT_FLOAT:  result = float1; break;
                case Type.BT_DOUBLE: result = double1; break;
            }
            break;
        }
        case 2: {
            switch(bt1) {
                case Type.BT_INT:    return int2;
                case Type.BT_LONG:   return long2;
                case Type.BT_FLOAT:  result = float2; break;
                case Type.BT_DOUBLE: result = double2; break;
            }
            break;
        }
    }

    if (result == null) {
        return throwBadTypes(types);
    }

    return result;
}
 
Example #11
Source Project: Box   Author: lulululbj   File: AttributeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the annotations out of a given method, similar to {@link
 * #getAnnotations}, also including an annotation for the translation
 * of the method-specific attribute {@code Exceptions}.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the set of annotations, which may be empty
 */
public static Annotations getMethodAnnotations(Method method) {
    Annotations result = getAnnotations(method.getAttributes());
    TypeList exceptions = getExceptions(method);

    if (exceptions.size() != 0) {
        Annotation throwsAnnotation =
            AnnotationUtils.makeThrows(exceptions);
        result = Annotations.combine(result, throwsAnnotation);
    }

    return result;
}
 
Example #12
Source Project: Box   Author: lulululbj   File: AnnotationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source Project: Box   Author: lulululbj   File: TypeListItem.java    License: Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected int compareTo0(OffsettedItem other) {
    TypeList thisList = this.list;
    TypeList otherList = ((TypeListItem) other).list;

    return StdTypeList.compareContents(thisList, otherList);
}
 
Example #14
Source Project: Box   Author: lulululbj   File: TypeListItem.java    License: Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected int compareTo0(OffsettedItem other) {
    TypeList thisList = this.list;
    TypeList otherList = ((TypeListItem) other).list;

    return StdTypeList.compareContents(thisList, otherList);
}
 
Example #15
Source Project: Box   Author: lulululbj   File: ClassDefItem.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the list of interfaces implemented.
 *
 * @return {@code non-null;} the interfaces list
 */
public TypeList getInterfaces() {
    if (interfaces == null) {
        return StdTypeList.EMPTY;
    }

    return interfaces.getList();
}
 
Example #16
Source Project: J2ME-Loader   Author: nikita36078   File: ThrowingInsn.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the string form of a register spec list to be used as a catches
 * list.
 *
 * @param catches {@code non-null;} the catches list
 * @return {@code non-null;} the string form
 */
public static String toCatchString(TypeList catches) {
    StringBuffer sb = new StringBuffer(100);

    sb.append("catch");

    int sz = catches.size();
    for (int i = 0; i < sz; i++) {
        sb.append(" ");
        sb.append(catches.getType(i).toHuman());
    }

    return sb.toString();
}
 
Example #17
Source Project: J2ME-Loader   Author: nikita36078   File: AttExceptions.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param exceptions {@code non-null;} list of classes, presumed but not
 * verified to be subclasses of {@code Throwable}
 */
public AttExceptions(TypeList exceptions) {
    super(ATTRIBUTE_NAME);

    try {
        if (exceptions.isMutable()) {
            throw new MutabilityException("exceptions.isMutable()");
        }
    } catch (NullPointerException ex) {
        // Translate the exception.
        throw new NullPointerException("exceptions == null");
    }

    this.exceptions = exceptions;
}
 
Example #18
Source Project: buck   Author: facebook   File: Rops.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Helper for all the {@code if*}-related methods, which
 * checks types and picks one of the four variants, throwing if
 * there's a problem.
 *
 * @param types {@code non-null;} the types
 * @param intZ {@code non-null;} the int-to-0 comparison
 * @param objZ {@code null-ok;} the object-to-null comparison
 * @param intInt {@code non-null;} the int-to-int comparison
 * @param objObj {@code non-null;} the object-to-object comparison
 * @return {@code non-null;} the appropriate instance
 */
private static Rop pickIf(TypeList types, Rop intZ, Rop objZ, Rop intInt,
                          Rop objObj) {
    switch(types.size()) {
        case 1: {
            switch (types.getType(0).getBasicFrameType()) {
                case Type.BT_INT: {
                    return intZ;
                }
                case Type.BT_OBJECT: {
                    if (objZ != null) {
                        return objZ;
                    }
                }
            }
            break;
        }
        case 2: {
            int bt = types.getType(0).getBasicFrameType();
            if (bt == types.getType(1).getBasicFrameType()) {
                switch (bt) {
                    case Type.BT_INT: {
                        return intInt;
                    }
                    case Type.BT_OBJECT: {
                        if (objObj != null) {
                            return objObj;
                        }
                    }
                }
            }
            break;
        }
    }

    return throwBadTypes(types);
}
 
Example #19
Source Project: J2ME-Loader   Author: nikita36078   File: AttributeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the list of thrown exceptions for a given method.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of thrown exceptions
 */
public static TypeList getExceptions(Method method) {
    AttributeList attribs = method.getAttributes();
    AttExceptions exceptions = (AttExceptions)
        attribs.findFirst(AttExceptions.ATTRIBUTE_NAME);

    if (exceptions == null) {
        return StdTypeList.EMPTY;
    }

    return exceptions.getExceptions();
}
 
Example #20
Source Project: Box   Author: lulululbj   File: Rops.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate binary arithmetic rop for the given type
 * and arguments. The result is a shared instance.
 *
 * @param types {@code non-null;} sources of the operation
 * @param int1 {@code non-null;} the int-to-constant rop
 * @param long1 {@code non-null;} the long-to-constant rop
 * @param float1 {@code null-ok;} the float-to-constant rop, if any
 * @param double1 {@code null-ok;} the double-to-constant rop, if any
 * @param int2 {@code non-null;} the int-to-int rop
 * @param long2 {@code non-null;} the long-to-long or long-to-int rop
 * @param float2 {@code null-ok;} the float-to-float rop, if any
 * @param double2 {@code null-ok;} the double-to-double rop, if any
 * @return {@code non-null;} an appropriate instance
 */
private static Rop pickBinaryOp(TypeList types, Rop int1, Rop long1,
                                Rop float1, Rop double1, Rop int2,
                                Rop long2, Rop float2, Rop double2) {
    int bt1 = types.getType(0).getBasicFrameType();
    Rop result = null;

    switch (types.size()) {
        case 1: {
            switch(bt1) {
                case Type.BT_INT:    return int1;
                case Type.BT_LONG:   return long1;
                case Type.BT_FLOAT:  result = float1; break;
                case Type.BT_DOUBLE: result = double1; break;
            }
            break;
        }
        case 2: {
            switch(bt1) {
                case Type.BT_INT:    return int2;
                case Type.BT_LONG:   return long2;
                case Type.BT_FLOAT:  result = float2; break;
                case Type.BT_DOUBLE: result = double2; break;
            }
            break;
        }
    }

    if (result == null) {
        return throwBadTypes(types);
    }

    return result;
}
 
Example #21
Source Project: buck   Author: facebook   File: AttributeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the annotations out of a given method, similar to {@link
 * #getAnnotations}, also including an annotation for the translation
 * of the method-specific attribute {@code Exceptions}.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the set of annotations, which may be empty
 */
public static Annotations getMethodAnnotations(Method method) {
    Annotations result = getAnnotations(method.getAttributes());
    TypeList exceptions = getExceptions(method);

    if (exceptions.size() != 0) {
        Annotation throwsAnnotation =
            AnnotationUtils.makeThrows(exceptions);
        result = Annotations.combine(result, throwsAnnotation);
    }

    return result;
}
 
Example #22
Source Project: buck   Author: facebook   File: ThrowingInsn.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the string form of a register spec list to be used as a catches
 * list.
 *
 * @param catches {@code non-null;} the catches list
 * @return {@code non-null;} the string form
 */
public static String toCatchString(TypeList catches) {
    StringBuffer sb = new StringBuffer(100);

    sb.append("catch");

    int sz = catches.size();
    for (int i = 0; i < sz; i++) {
        sb.append(" ");
        sb.append(catches.getType(i).toHuman());
    }

    return sb.toString();
}
 
Example #23
Source Project: Box   Author: lulululbj   File: Rops.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the appropriate binary arithmetic rop for the given type
 * and arguments. The result is a shared instance.
 *
 * @param types {@code non-null;} sources of the operation
 * @param int1 {@code non-null;} the int-to-constant rop
 * @param long1 {@code non-null;} the long-to-constant rop
 * @param float1 {@code null-ok;} the float-to-constant rop, if any
 * @param double1 {@code null-ok;} the double-to-constant rop, if any
 * @param int2 {@code non-null;} the int-to-int rop
 * @param long2 {@code non-null;} the long-to-long or long-to-int rop
 * @param float2 {@code null-ok;} the float-to-float rop, if any
 * @param double2 {@code null-ok;} the double-to-double rop, if any
 * @return {@code non-null;} an appropriate instance
 */
private static Rop pickBinaryOp(TypeList types, Rop int1, Rop long1,
                                Rop float1, Rop double1, Rop int2,
                                Rop long2, Rop float2, Rop double2) {
    int bt1 = types.getType(0).getBasicFrameType();
    Rop result = null;

    switch (types.size()) {
        case 1: {
            switch(bt1) {
                case Type.BT_INT:    return int1;
                case Type.BT_LONG:   return long1;
                case Type.BT_FLOAT:  result = float1; break;
                case Type.BT_DOUBLE: result = double1; break;
            }
            break;
        }
        case 2: {
            switch(bt1) {
                case Type.BT_INT:    return int2;
                case Type.BT_LONG:   return long2;
                case Type.BT_FLOAT:  result = float2; break;
                case Type.BT_DOUBLE: result = double2; break;
            }
            break;
        }
    }

    if (result == null) {
        return throwBadTypes(types);
    }

    return result;
}
 
Example #24
Source Project: buck   Author: facebook   File: TypeListItem.java    License: Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected int compareTo0(OffsettedItem other) {
    TypeList thisList = this.list;
    TypeList otherList = ((TypeListItem) other).list;

    return StdTypeList.compareContents(thisList, otherList);
}
 
Example #25
Source Project: J2ME-Loader   Author: nikita36078   File: AttributeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the annotations out of a given method, similar to {@link
 * #getAnnotations}, also including an annotation for the translation
 * of the method-specific attribute {@code Exceptions}.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the set of annotations, which may be empty
 */
public static Annotations getMethodAnnotations(Method method) {
    Annotations result = getAnnotations(method.getAttributes());
    TypeList exceptions = getExceptions(method);

    if (exceptions.size() != 0) {
        Annotation throwsAnnotation =
            AnnotationUtils.makeThrows(exceptions);
        result = Annotations.combine(result, throwsAnnotation);
    }

    return result;
}
 
Example #26
Source Project: buck   Author: facebook   File: AttExceptions.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param exceptions {@code non-null;} list of classes, presumed but not
 * verified to be subclasses of {@code Throwable}
 */
public AttExceptions(TypeList exceptions) {
    super(ATTRIBUTE_NAME);

    try {
        if (exceptions.isMutable()) {
            throw new MutabilityException("exceptions.isMutable()");
        }
    } catch (NullPointerException ex) {
        // Translate the exception.
        throw new NullPointerException("exceptions == null");
    }

    this.exceptions = exceptions;
}
 
Example #27
Source Project: Box   Author: lulululbj   File: Rop.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance. This method is private. Use one of the
 * public constructors.
 *
 * @param opcode the opcode; one of the constants in {@link RegOps}
 * @param result {@code non-null;} result type of this operation; {@link
 * Type#VOID} for no-result operations
 * @param sources {@code non-null;} types of all the sources of this operation
 * @param exceptions {@code non-null;} list of possible types thrown by this
 * operation
 * @param branchingness the branchingness of this op; one of the
 * {@code BRANCH_*} constants
 * @param isCallLike whether the op is a function/method call or similar
 * @param nickname {@code null-ok;} optional nickname (used for debugging)
 */
public Rop(int opcode, Type result, TypeList sources,
           TypeList exceptions, int branchingness, boolean isCallLike,
           String nickname) {
    if (result == null) {
        throw new NullPointerException("result == null");
    }

    if (sources == null) {
        throw new NullPointerException("sources == null");
    }

    if (exceptions == null) {
        throw new NullPointerException("exceptions == null");
    }

    if ((branchingness < BRANCH_MIN) || (branchingness > BRANCH_MAX)) {
        throw new IllegalArgumentException("invalid branchingness: " + branchingness);
    }

    if ((exceptions.size() != 0) && (branchingness != BRANCH_THROW)) {
        throw new IllegalArgumentException("exceptions / branchingness " +
                                           "mismatch");
    }

    this.opcode = opcode;
    this.result = result;
    this.sources = sources;
    this.exceptions = exceptions;
    this.branchingness = branchingness;
    this.isCallLike = isCallLike;
    this.nickname = nickname;
}
 
Example #28
Source Project: J2ME-Loader   Author: nikita36078   File: ClassDefsSection.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #29
Source Project: buck   Author: facebook   File: AnnotationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts a {@link TypeList} to a {@link CstArray}.
 *
 * @param types {@code non-null;} the type list
 * @return {@code non-null;} the corresponding array constant
 */
private static CstArray makeCstArray(TypeList types) {
    int size = types.size();
    CstArray.List list = new CstArray.List(size);

    for (int i = 0; i < size; i++) {
        list.set(i, CstType.intern(types.getType(i)));
    }

    list.setImmutable();
    return new CstArray(list);
}
 
Example #30
Source Project: Box   Author: lulululbj   File: ThrowingInsn.java    License: Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public TypeList getCatches() {
    return catches;
}