Java Code Examples for com.android.dx.rop.type.StdTypeList#equalContents()

The following examples show how to use com.android.dx.rop.type.StdTypeList#equalContents() . 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 File: Insn.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Compares Insn contents, since {@code Insn.equals()} is defined
 * to be an identity compare. Insn's are {@code contentEquals()}
 * if they have the same opcode, registers, source position, and other
 * metadata.
 *
 * @return true in the case described above
 */
public boolean contentEquals(Insn b) {
    return opcode == b.getOpcode()
            && position.equals(b.getPosition())
            && (getClass() == b.getClass())
            && equalsHandleNulls(result, b.getResult())
            && equalsHandleNulls(sources, b.getSources())
            && StdTypeList.equalContents(getCatches(), b.getCatches());
}
 
Example 2
Source File: Insn.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Compares Insn contents, since {@code Insn.equals()} is defined
 * to be an identity compare. Insn's are {@code contentEquals()}
 * if they have the same opcode, registers, source position, and other
 * metadata.
 *
 * @return true in the case described above
 */
public boolean contentEquals(Insn b) {
    return opcode == b.getOpcode()
            && position.equals(b.getPosition())
            && (getClass() == b.getClass())
            && equalsHandleNulls(result, b.getResult())
            && equalsHandleNulls(sources, b.getSources())
            && StdTypeList.equalContents(getCatches(), b.getCatches());
}
 
Example 3
Source File: Insn.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Compares Insn contents, since {@code Insn.equals()} is defined
 * to be an identity compare. Insn's are {@code contentEquals()}
 * if they have the same opcode, registers, source position, and other
 * metadata.
 *
 * @return true in the case described above
 */
public boolean contentEquals(Insn b) {
    return opcode == b.getOpcode()
            && position.equals(b.getPosition())
            && (getClass() == b.getClass())
            && equalsHandleNulls(result, b.getResult())
            && equalsHandleNulls(sources, b.getSources())
            && StdTypeList.equalContents(getCatches(), b.getCatches());
}
 
Example 4
Source File: Insn.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Compares Insn contents, since {@code Insn.equals()} is defined
 * to be an identity compare. Insn's are {@code contentEquals()}
 * if they have the same opcode, registers, source position, and other
 * metadata.
 *
 * @return true in the case described above
 */
public boolean contentEquals(Insn b) {
    return opcode == b.getOpcode()
            && position.equals(b.getPosition())
            && (getClass() == b.getClass())
            && equalsHandleNulls(result, b.getResult())
            && equalsHandleNulls(sources, b.getSources())
            && StdTypeList.equalContents(getCatches(), b.getCatches());
}
 
Example 5
Source File: BasicBlockList.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Compares the catches of two blocks for equality. This includes
 * both the catch types and target labels.
 *
 * @param block1 {@code non-null;} one block to compare
 * @param block2 {@code non-null;} the other block to compare
 * @return {@code true} if the two blocks' non-primary successors
 * are identical
 */
public boolean catchesEqual(BasicBlock block1, BasicBlock block2) {
    TypeList catches1 = block1.getExceptionHandlerTypes();
    TypeList catches2 = block2.getExceptionHandlerTypes();

    if (!StdTypeList.equalContents(catches1, catches2)) {
        return false;
    }

    IntList succ1 = block1.getSuccessors();
    IntList succ2 = block2.getSuccessors();
    int size = succ1.size(); // Both are guaranteed to be the same size.

    int primary1 = block1.getPrimarySuccessor();
    int primary2 = block2.getPrimarySuccessor();

    if (((primary1 == -1) || (primary2 == -1))
            && (primary1 != primary2)) {
        /*
         * For the current purpose, both blocks in question must
         * either both have a primary or both not have a primary to
         * be considered equal, and it turns out here that that's not
         * the case.
         */
        return false;
    }

    for (int i = 0; i < size; i++) {
        int label1 = succ1.get(i);
        int label2 = succ2.get(i);

        if (label1 == primary1) {
            /*
             * It should be the case that block2's primary is at the
             * same index. If not, we consider the blocks unequal for
             * the current purpose.
             */
            if (label2 != primary2) {
                return false;
            }
            continue;
        }

        if (label1 != label2) {
            return false;
        }
    }

    return true;
}
 
Example 6
Source File: BasicBlockList.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Compares the catches of two blocks for equality. This includes
 * both the catch types and target labels.
 *
 * @param block1 {@code non-null;} one block to compare
 * @param block2 {@code non-null;} the other block to compare
 * @return {@code true} if the two blocks' non-primary successors
 * are identical
 */
public boolean catchesEqual(BasicBlock block1, BasicBlock block2) {
    TypeList catches1 = block1.getExceptionHandlerTypes();
    TypeList catches2 = block2.getExceptionHandlerTypes();

    if (!StdTypeList.equalContents(catches1, catches2)) {
        return false;
    }

    IntList succ1 = block1.getSuccessors();
    IntList succ2 = block2.getSuccessors();
    int size = succ1.size(); // Both are guaranteed to be the same size.

    int primary1 = block1.getPrimarySuccessor();
    int primary2 = block2.getPrimarySuccessor();

    if (((primary1 == -1) || (primary2 == -1))
            && (primary1 != primary2)) {
        /*
         * For the current purpose, both blocks in question must
         * either both have a primary or both not have a primary to
         * be considered equal, and it turns out here that that's not
         * the case.
         */
        return false;
    }

    for (int i = 0; i < size; i++) {
        int label1 = succ1.get(i);
        int label2 = succ2.get(i);

        if (label1 == primary1) {
            /*
             * It should be the case that block2's primary is at the
             * same index. If not, we consider the blocks unequal for
             * the current purpose.
             */
            if (label2 != primary2) {
                return false;
            }
            continue;
        }

        if (label1 != label2) {
            return false;
        }
    }

    return true;
}
 
Example 7
Source File: BasicBlockList.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * Compares the catches of two blocks for equality. This includes
 * both the catch types and target labels.
 *
 * @param block1 {@code non-null;} one block to compare
 * @param block2 {@code non-null;} the other block to compare
 * @return {@code true} if the two blocks' non-primary successors
 * are identical
 */
public boolean catchesEqual(BasicBlock block1, BasicBlock block2) {
    TypeList catches1 = block1.getExceptionHandlerTypes();
    TypeList catches2 = block2.getExceptionHandlerTypes();

    if (!StdTypeList.equalContents(catches1, catches2)) {
        return false;
    }

    IntList succ1 = block1.getSuccessors();
    IntList succ2 = block2.getSuccessors();
    int size = succ1.size(); // Both are guaranteed to be the same size.

    int primary1 = block1.getPrimarySuccessor();
    int primary2 = block2.getPrimarySuccessor();

    if (((primary1 == -1) || (primary2 == -1))
            && (primary1 != primary2)) {
        /*
         * For the current purpose, both blocks in question must
         * either both have a primary or both not have a primary to
         * be considered equal, and it turns out here that that's not
         * the case.
         */
        return false;
    }

    for (int i = 0; i < size; i++) {
        int label1 = succ1.get(i);
        int label2 = succ2.get(i);

        if (label1 == primary1) {
            /*
             * It should be the case that block2's primary is at the
             * same index. If not, we consider the blocks unequal for
             * the current purpose.
             */
            if (label2 != primary2) {
                return false;
            }
            continue;
        }

        if (label1 != label2) {
            return false;
        }
    }

    return true;
}