当前位置: 首页>>代码示例>>Java>>正文


Java IntList.size方法代码示例

本文整理汇总了Java中com.android.dx.util.IntList.size方法的典型用法代码示例。如果您正苦于以下问题:Java IntList.size方法的具体用法?Java IntList.size怎么用?Java IntList.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.dx.util.IntList的用法示例。


在下文中一共展示了IntList.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldPack

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Determines whether the given list of cases warrant being packed.
 *
 * @param cases {@code non-null;} sorted list of cases
 * @return {@code true} iff the table encoding the cases
 * should be packed
 */
private static boolean shouldPack(IntList cases) {
    int sz = cases.size();

    if (sz < 2) {
        return true;
    }

    long packedSize = packedCodeSize(cases);
    long sparseSize = sparseCodeSize(cases);

    /*
     * We pick the packed representation if it is possible and
     * would be as small or smaller than 5/4 of the sparse
     * representation. That is, we accept some size overhead on
     * the packed representation, since that format is faster to
     * execute at runtime.
     */
    return (packedSize >= 0) && (packedSize <= ((sparseSize * 5) / 4));
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:27,代码来源:SwitchData.java

示例2: combineBlocks

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Combines blocks proven identical into one alpha block, re-writing
 * all of the successor links that point to the beta blocks to point
 * to the alpha block instead.
 *
 * @param alphaLabel block that will replace all the beta block
 * @param betaLabels label list of blocks to combine
 */
private void combineBlocks(int alphaLabel, IntList betaLabels) {
    int szBetas = betaLabels.size();

    for (int i = 0; i < szBetas; i++) {
        int betaLabel = betaLabels.get(i);
        BasicBlock bb = blocks.labelToBlock(betaLabel);
        IntList preds = ropMethod.labelToPredecessors(bb.getLabel());
        int szPreds = preds.size();

        for (int j = 0; j < szPreds; j++) {
            BasicBlock predBlock = newBlocks.labelToBlock(preds.get(j));
            replaceSucc(predBlock, betaLabel, alphaLabel);
        }
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:24,代码来源:IdenticalBlockCombiner.java

示例3: isSubroutineCaller

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Checks to see if the basic block is a subroutine caller block.
 *
 * @param bb {@code non-null;} the basic block in question
 * @return true if this block calls a subroutine
 */
private boolean isSubroutineCaller(BasicBlock bb) {
    IntList successors = bb.getSuccessors();
    if (successors.size() < 2) return false;

    int subLabel = successors.get(1);

    return (subLabel < subroutines.length)
            && (subroutines[subLabel] != null);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:16,代码来源:Ropper.java

示例4: SwitchData

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Constructs an instance. The output address of this instance is initially
 * unknown ({@code -1}).
 *
 * @param position {@code non-null;} source position
 * @param user {@code non-null;} address representing the instruction that
 * uses this instance
 * @param cases {@code non-null;} sorted list of switch cases (keys)
 * @param targets {@code non-null;} corresponding list of code addresses; the
 * branch target for each case
 */
public SwitchData(SourcePosition position, CodeAddress user,
                  IntList cases, CodeAddress[] targets) {
    super(position, RegisterSpecList.EMPTY);

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

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

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

    int sz = cases.size();

    if (sz != targets.length) {
        throw new IllegalArgumentException("cases / targets mismatch");
    }

    if (sz > 65535) {
        throw new IllegalArgumentException("too many cases");
    }

    this.user = user;
    this.cases = cases;
    this.targets = targets;
    this.packed = shouldPack(cases);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:43,代码来源:SwitchData.java

示例5: convertBasicBlock

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Converts a single basic block to rop form.
 *
 * @param block SSA block to process
 * @return {@code non-null;} ROP block
 */
private BasicBlock convertBasicBlock(SsaBasicBlock block) {
    IntList successorList = block.getRopLabelSuccessorList();
    int primarySuccessorLabel = block.getPrimarySuccessorRopLabel();

    // Filter out any reference to the SSA form's exit block.

    // Exit block may be null.
    SsaBasicBlock exitBlock = ssaMeth.getExitBlock();
    int exitRopLabel = (exitBlock == null) ? -1 : exitBlock.getRopLabel();

    if (successorList.contains(exitRopLabel)) {
        if (successorList.size() > 1) {
            throw new RuntimeException(
                    "Exit predecessor must have no other successors"
                            + Hex.u2(block.getRopLabel()));
        } else {
            successorList = IntList.EMPTY;
            primarySuccessorLabel = -1;

            verifyValidExitPredecessor(block);
        }
    }

    successorList.setImmutable();

    BasicBlock result = new BasicBlock(
            block.getRopLabel(), convertInsns(block.getInsns()),
            successorList,
            primarySuccessorLabel);

    return result;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:39,代码来源:SsaToRop.java

示例6: adjustLocalsForSubroutines

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Adjusts a locals array to account for a merged subroutines list.
 * If a frame merge results in, effectively, a subroutine return through
 * a throw then the current locals will be a LocalsArraySet that will
 * need to be trimmed of all OneLocalsArray elements that relevent to
 * the subroutine that is returning.
 *
 * @param locals {@code non-null;} LocalsArray from before a merge
 * @param subroutines {@code non-null;} a label list of subroutine start blocks
 * representing the subroutine nesting of the block being merged into.
 * @return {@code non-null;} locals set appropriate for merge
 */
private static LocalsArray adjustLocalsForSubroutines(
        LocalsArray locals, IntList subroutines) {
    if (! (locals instanceof LocalsArraySet)) {
        // nothing to see here
        return locals;
    }

    LocalsArraySet laSet = (LocalsArraySet)locals;

    if (subroutines.size() == 0) {
        /*
         * We've merged from a subroutine context to a non-subroutine
         * context, likely via a throw. Our successor will only need
         * to consider the primary locals state, not the state of
         * all possible subroutine paths.
         */

        return laSet.getPrimary();
    }

    /*
     * It's unclear to me if the locals set needs to be trimmed here.
     * If it does, then I believe it is all of the calling blocks
     * in the subroutine at the end of "subroutines" passed into
     * this method that should be removed.
     */
    return laSet;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:41,代码来源:Frame.java

示例7: bitSetFromLabelList

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Builds a BitSet of block indices from a basic block list and a list
 * of labels taken from Rop form.
 *
 * @param blocks Rop blocks
 * @param labelList list of rop block labels
 * @return BitSet of block indices
 */
static BitSet bitSetFromLabelList(BasicBlockList blocks,
        IntList labelList) {
    BitSet result = new BitSet(blocks.size());

    for (int i = 0, sz = labelList.size(); i < sz; i++) {
        result.set(blocks.indexOfLabel(labelList.get(i)));
    }

    return result;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:19,代码来源:SsaMethod.java

示例8: packedCodeSize

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Gets the size of a packed table for the given cases, in 16-bit code
 * units.
 *
 * @param cases {@code non-null;} sorted list of cases
 * @return {@code >= -1;} the packed table size or {@code -1} if the
 * cases couldn't possibly be represented as a packed table
 */
private static long packedCodeSize(IntList cases) {
    int sz = cases.size();
    long low = cases.get(0);
    long high = cases.get(sz - 1);
    long result = ((high - low + 1)) * 2 + 4;

    return (result <= 0x7fffffff) ? result : -1;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:17,代码来源:SwitchData.java

示例9: catchesEqual

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:59,代码来源:BasicBlockList.java

示例10: mergeWithSubroutineCaller

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Merges this frame with the frame of a subroutine caller at
 * {@code predLabel}. Only called on the frame at the first
 * block of a subroutine.
 *
 * @param other {@code non-null;} another frame
 * @param subLabel label of subroutine start block
 * @param predLabel label of calling block
 * @return {@code non-null;} the result of merging the two frames
 */
public Frame mergeWithSubroutineCaller(Frame other, int subLabel,
        int predLabel) {
    LocalsArray resultLocals;
    ExecutionStack resultStack;

    resultLocals = getLocals().mergeWithSubroutineCaller(
            other.getLocals(), predLabel);
    resultStack = getStack().merge(other.getStack());

    IntList newOtherSubroutines = other.subroutines.mutableCopy();
    newOtherSubroutines.add(subLabel);
    newOtherSubroutines.setImmutable();

    if ((resultLocals == getLocals())
            && (resultStack == getStack())
            && subroutines.equals(newOtherSubroutines)) {
        return this;
    }

    IntList resultSubroutines;

    if (subroutines.equals(newOtherSubroutines)) {
        resultSubroutines = subroutines;
    } else {
        /*
         * The new subroutines list should be the deepest of the two
         * lists being merged, but the postfix of the resultant list
         * must be equal to the shorter list.
         */
        IntList nonResultSubroutines;

        if (subroutines.size() > newOtherSubroutines.size()) {
            resultSubroutines = subroutines;
            nonResultSubroutines = newOtherSubroutines;
        } else {
            resultSubroutines = newOtherSubroutines;
            nonResultSubroutines = subroutines;
        }

        int szResult = resultSubroutines.size();
        int szNonResult = nonResultSubroutines.size();

        for (int i = szNonResult - 1; i >=0; i-- ) {
            if (nonResultSubroutines.get(i)
                    != resultSubroutines.get(
                    i + (szResult - szNonResult))) {
                throw new
                        RuntimeException("Incompatible merged subroutines");
            }
        }

    }

    return new Frame(resultLocals, resultStack, resultSubroutines);
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:66,代码来源:Frame.java

示例11: visitSwitchInsn

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void visitSwitchInsn(SwitchInsn insn) {
    SourcePosition pos = insn.getPosition();
    IntList cases = insn.getCases();
    IntList successors = block.getSuccessors();
    int casesSz = cases.size();
    int succSz = successors.size();
    int primarySuccessor = block.getPrimarySuccessor();

    /*
     * Check the assumptions that the number of cases is one
     * less than the number of successors and that the last
     * successor in the list is the primary (in this case, the
     * default). This test is here to guard against forgetting
     * to change this code if the way switch instructions are
     * constructed also gets changed.
     */
    if ((casesSz != (succSz - 1)) ||
        (primarySuccessor != successors.get(casesSz))) {
        throw new RuntimeException("shouldn't happen");
    }

    CodeAddress[] switchTargets = new CodeAddress[casesSz];

    for (int i = 0; i < casesSz; i++) {
        int label = successors.get(i);
        switchTargets[i] = addresses.getStart(label);
    }

    CodeAddress dataAddress = new CodeAddress(pos);
    // make a new address that binds closely to the switch instruction
    CodeAddress switchAddress =
        new CodeAddress(lastAddress.getPosition(), true);
    SwitchData dataInsn =
        new SwitchData(pos, switchAddress, cases, switchTargets);
    Dop opcode = dataInsn.isPacked() ?
        Dops.PACKED_SWITCH : Dops.SPARSE_SWITCH;
    TargetInsn switchInsn =
        new TargetInsn(opcode, pos, getRegs(insn), dataAddress);

    addOutput(switchAddress);
    addOutput(switchInsn);

    addOutputSuffix(new OddSpacer(pos));
    addOutputSuffix(dataAddress);
    addOutputSuffix(dataInsn);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:48,代码来源:RopTranslator.java

示例12: handlersFor

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Makes the {@link CatchHandlerList} for the given basic block.
 *
 * @param block {@code non-null;} block to get entries for
 * @param addresses {@code non-null;} address objects for each block
 * @return {@code non-null;} array of entries
 */
private static CatchHandlerList handlersFor(BasicBlock block,
        BlockAddresses addresses) {
    IntList successors = block.getSuccessors();
    int succSize = successors.size();
    int primary = block.getPrimarySuccessor();
    TypeList catches = block.getLastInsn().getCatches();
    int catchSize = catches.size();

    if (catchSize == 0) {
        return CatchHandlerList.EMPTY;
    }

    if (((primary == -1) && (succSize != catchSize))
            || ((primary != -1) &&
                    ((succSize != (catchSize + 1))
                            || (primary != successors.get(catchSize))))) {
        /*
         * Blocks that throw are supposed to list their primary
         * successor -- if any -- last in the successors list, but
         * that constraint appears to be violated here.
         */
        throw new RuntimeException(
                "shouldn't happen: weird successors list");
    }

    /*
     * Reduce the effective catchSize if we spot a catch-all that
     * isn't at the end.
     */
    for (int i = 0; i < catchSize; i++) {
        Type type = catches.getType(i);
        if (type.equals(Type.OBJECT)) {
            catchSize = i + 1;
            break;
        }
    }

    CatchHandlerList result = new CatchHandlerList(catchSize);

    for (int i = 0; i < catchSize; i++) {
        CstType oneType = new CstType(catches.getType(i));
        CodeAddress oneHandler = addresses.getStart(successors.get(i));
        result.set(i, oneType, oneHandler.getAddress());
    }

    result.setImmutable();
    return result;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:56,代码来源:StdCatchBuilder.java

示例13: endParsingMember

import com.android.dx.util.IntList; //导入方法依赖的package包/类
public void endParsingMember(ByteArray bytes, int offset, String name,
                             String descriptor, Member member) {
    if (!(member instanceof Method)) {
        return;
    }

    if (!shouldDumpMethod(name)) {
        return;
    }

    ConcreteMethod meth = new ConcreteMethod((Method) member, classFile,
                                             true, true);

    TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
    RopMethod rmeth =
        Ropper.convert(meth, advice, classFile.getMethods());

    if (optimize) {
        boolean isStatic = AccessFlags.isStatic(meth.getAccessFlags());
        rmeth = Optimizer.optimize(rmeth,
                BaseDumper.computeParamWidth(meth, isStatic), isStatic,
                true, advice);
    }

    System.out.println("digraph "  + name + "{");

    System.out.println("\tfirst -> n"
            + Hex.u2(rmeth.getFirstLabel()) + ";");

    BasicBlockList blocks = rmeth.getBlocks();

    int sz = blocks.size();
    for (int i = 0; i < sz; i++) {
        BasicBlock bb = blocks.get(i);
        int label = bb.getLabel();
        IntList successors = bb.getSuccessors();

        if (successors.size() == 0) {
            System.out.println("\tn" + Hex.u2(label) + " -> returns;");
        } else if (successors.size() == 1) {
            System.out.println("\tn" + Hex.u2(label) + " -> n"
                    + Hex.u2(successors.get(0)) + ";");
        } else {
            System.out.print("\tn" + Hex.u2(label) + " -> {");
            for (int j = 0; j < successors.size(); j++ ) {
                int successor = successors.get(j);

                if (successor != bb.getPrimarySuccessor()) {
                    System.out.print(" n" + Hex.u2(successor) + " ");
                }

            }
            System.out.println("};");

            System.out.println("\tn" + Hex.u2(label) + " -> n"
                    + Hex.u2(bb.getPrimarySuccessor())
                    + " [label=\"primary\"];");


        }
    }

    System.out.println("}");
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:65,代码来源:DotDumper.java

示例14: involvedInSubroutine

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Checks to see if a specified label is involved in a specified
 * subroutine.
 *
 * @param label {@code >= 0;} a basic block label
 * @param subroutineStart {@code >= 0;} a subroutine as identified
 * by the label of its start block
 * @return true if the block is dominated by the subroutine call
 */
private boolean involvedInSubroutine(int label, int subroutineStart) {
    IntList subroutinesList = labelToSubroutines.get(label);
    return (subroutinesList != null && subroutinesList.size() > 0
            && subroutinesList.top() == subroutineStart);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:15,代码来源:Ropper.java

示例15: sparseCodeSize

import com.android.dx.util.IntList; //导入方法依赖的package包/类
/**
 * Gets the size of a sparse table for the given cases, in 16-bit code
 * units.
 *
 * @param cases {@code non-null;} sorted list of cases
 * @return {@code > 0;} the sparse table size
 */
private static long sparseCodeSize(IntList cases) {
    int sz = cases.size();

    return (sz * 4L) + 2;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:13,代码来源:SwitchData.java


注:本文中的com.android.dx.util.IntList.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。