Java Code Examples for com.android.dx.util.Bits#makeBitSet()

The following examples show how to use com.android.dx.util.Bits#makeBitSet() . 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: BasicBlocker.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance. This class is not publicly instantiable; use
 * {@link #identifyBlocks}.
 *
 * @param method {@code non-null;} method to convert
 */
private BasicBlocker(ConcreteMethod method) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    /*
     * The "+1" below is so the idx-past-end is also valid,
     * avoiding a special case, but without preventing
     * flow-of-control falling past the end of the method from
     * getting properly reported.
     */
    int sz = method.getCode().size() + 1;

    workSet = Bits.makeBitSet(sz);
    liveSet = Bits.makeBitSet(sz);
    blockSet = Bits.makeBitSet(sz);
    targetLists = new IntList[sz];
    catchLists = new ByteCatchList[sz];
    previousOffset = -1;
}
 
Example 2
Source File: BasicBlocker.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance. This class is not publicly instantiable; use
 * {@link #identifyBlocks}.
 *
 * @param method {@code non-null;} method to convert
 */
private BasicBlocker(ConcreteMethod method) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    /*
     * The "+1" below is so the idx-past-end is also valid,
     * avoiding a special case, but without preventing
     * flow-of-control falling past the end of the method from
     * getting properly reported.
     */
    int sz = method.getCode().size() + 1;

    workSet = Bits.makeBitSet(sz);
    liveSet = Bits.makeBitSet(sz);
    blockSet = Bits.makeBitSet(sz);
    targetLists = new IntList[sz];
    catchLists = new ByteCatchList[sz];
    previousOffset = -1;
}
 
Example 3
Source File: BasicBlocker.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance. This class is not publicly instantiable; use
 * {@link #identifyBlocks}.
 *
 * @param method {@code non-null;} method to convert
 */
private BasicBlocker(ConcreteMethod method) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    /*
     * The "+1" below is so the idx-past-end is also valid,
     * avoiding a special case, but without preventing
     * flow-of-control falling past the end of the method from
     * getting properly reported.
     */
    int sz = method.getCode().size() + 1;

    workSet = Bits.makeBitSet(sz);
    liveSet = Bits.makeBitSet(sz);
    blockSet = Bits.makeBitSet(sz);
    targetLists = new IntList[sz];
    catchLists = new ByteCatchList[sz];
    previousOffset = -1;
}
 
Example 4
Source File: BasicBlocker.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance. This class is not publicly instantiable; use
 * {@link #identifyBlocks}.
 *
 * @param method {@code non-null;} method to convert
 */
private BasicBlocker(ConcreteMethod method) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    /*
     * The "+1" below is so the idx-past-end is also valid,
     * avoiding a special case, but without preventing
     * flow-of-control falling past the end of the method from
     * getting properly reported.
     */
    int sz = method.getCode().size() + 1;

    workSet = Bits.makeBitSet(sz);
    liveSet = Bits.makeBitSet(sz);
    blockSet = Bits.makeBitSet(sz);
    targetLists = new IntList[sz];
    catchLists = new ByteCatchList[sz];
    previousOffset = -1;
}
 
Example 5
Source File: BytecodeArray.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the offset to each instruction in the bytecode array. The
 * result is a bit set with the offset of each opcode-per-se flipped on.
 *
 * @see Bits
 * @return {@code non-null;} appropriately constructed bit set
 */
public int[] getInstructionOffsets() {
    int sz = bytes.size();
    int[] result = Bits.makeBitSet(sz);
    int at = 0;

    while (at < sz) {
        Bits.set(result, at, true);
        int length = parseInstruction(at, null);
        at += length;
    }

    return result;
}
 
Example 6
Source File: Ropper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Does the conversion.
 */
private void doit() {
    int[] workSet = Bits.makeBitSet(maxLabel);

    Bits.set(workSet, 0);
    addSetupBlocks();
    setFirstFrame();

    for (;;) {
        int offset = Bits.findFirst(workSet, 0);
        if (offset < 0) {
            break;
        }
        Bits.clear(workSet, offset);
        ByteBlock block = blocks.labelToBlock(offset);
        Frame frame = startFrames[offset];
        try {
            processBlock(block, frame, workSet);
        } catch (SimException ex) {
            ex.addContext("...while working on block " + Hex.u2(offset));
            throw ex;
        }
    }

    addReturnBlock();
    addSynchExceptionHandlerBlock();
    addExceptionSetupBlocks();

    if (hasSubroutines) {
        // Subroutines are very rare, so skip this step if it's n/a
        inlineSubroutines();
    }
}
 
Example 7
Source File: LocalVariableExtractor.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance. This method is private. Use {@link #extract}.
 *
 * @param method {@code non-null;} the method to extract from
 */
private LocalVariableExtractor(RopMethod method) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    BasicBlockList blocks = method.getBlocks();
    int maxLabel = blocks.getMaxLabel();

    this.method = method;
    this.blocks = blocks;
    this.resultInfo = new LocalVariableInfo(method);
    this.workSet = Bits.makeBitSet(maxLabel);
}
 
Example 8
Source File: BytecodeArray.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the offset to each instruction in the bytecode array. The
 * result is a bit set with the offset of each opcode-per-se flipped on.
 *
 * @see Bits
 * @return {@code non-null;} appropriately constructed bit set
 */
public int[] getInstructionOffsets() {
    int sz = bytes.size();
    int[] result = Bits.makeBitSet(sz);
    int at = 0;

    while (at < sz) {
        Bits.set(result, at, true);
        int length = parseInstruction(at, null);
        at += length;
    }

    return result;
}
 
Example 9
Source File: Ropper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Does the conversion.
 */
private void doit() {
    int[] workSet = Bits.makeBitSet(maxLabel);

    Bits.set(workSet, 0);
    addSetupBlocks();
    setFirstFrame();

    for (;;) {
        int offset = Bits.findFirst(workSet, 0);
        if (offset < 0) {
            break;
        }
        Bits.clear(workSet, offset);
        ByteBlock block = blocks.labelToBlock(offset);
        Frame frame = startFrames[offset];
        try {
            processBlock(block, frame, workSet);
        } catch (SimException ex) {
            ex.addContext("...while working on block " + Hex.u2(offset));
            throw ex;
        }
    }

    addReturnBlock();
    addSynchExceptionHandlerBlock();
    addExceptionSetupBlocks();

    if (hasSubroutines) {
        // Subroutines are very rare, so skip this step if it's n/a
        inlineSubroutines();
    }
}
 
Example 10
Source File: LocalVariableExtractor.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance. This method is private. Use {@link #extract}.
 *
 * @param method {@code non-null;} the method to extract from
 */
private LocalVariableExtractor(RopMethod method) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    BasicBlockList blocks = method.getBlocks();
    int maxLabel = blocks.getMaxLabel();

    this.method = method;
    this.blocks = blocks;
    this.resultInfo = new LocalVariableInfo(method);
    this.workSet = Bits.makeBitSet(maxLabel);
}
 
Example 11
Source File: Ropper.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Does the conversion.
 */
private void doit() {
    int[] workSet = Bits.makeBitSet(maxLabel);

    Bits.set(workSet, 0);
    addSetupBlocks();
    setFirstFrame();

    for (;;) {
        int offset = Bits.findFirst(workSet, 0);
        if (offset < 0) {
            break;
        }
        Bits.clear(workSet, offset);
        ByteBlock block = blocks.labelToBlock(offset);
        Frame frame = startFrames[offset];
        try {
            processBlock(block, frame, workSet);
        } catch (SimException ex) {
            ex.addContext("...while working on block " + Hex.u2(offset));
            throw ex;
        }
    }

    addReturnBlock();
    addSynchExceptionHandlerBlock();
    addExceptionSetupBlocks();

    if (hasSubroutines) {
        // Subroutines are very rare, so skip this step if it's n/a
        inlineSubroutines();
    }
}
 
Example 12
Source File: LocalVariableExtractor.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance. This method is private. Use {@link #extract}.
 *
 * @param method {@code non-null;} the method to extract from
 */
private LocalVariableExtractor(RopMethod method) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    BasicBlockList blocks = method.getBlocks();
    int maxLabel = blocks.getMaxLabel();

    this.method = method;
    this.blocks = blocks;
    this.resultInfo = new LocalVariableInfo(method);
    this.workSet = Bits.makeBitSet(maxLabel);
}
 
Example 13
Source File: BytecodeArray.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the offset to each instruction in the bytecode array. The
 * result is a bit set with the offset of each opcode-per-se flipped on.
 *
 * @see Bits
 * @return {@code non-null;} appropriately constructed bit set
 */
public int[] getInstructionOffsets() {
    int sz = bytes.size();
    int[] result = Bits.makeBitSet(sz);
    int at = 0;

    while (at < sz) {
        Bits.set(result, at, true);
        int length = parseInstruction(at, null);
        at += length;
    }

    return result;
}
 
Example 14
Source File: Ropper.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Does the conversion.
 */
private void doit() {
    int[] workSet = Bits.makeBitSet(maxLabel);

    Bits.set(workSet, 0);
    addSetupBlocks();
    setFirstFrame();

    for (;;) {
        int offset = Bits.findFirst(workSet, 0);
        if (offset < 0) {
            break;
        }
        Bits.clear(workSet, offset);
        ByteBlock block = blocks.labelToBlock(offset);
        Frame frame = startFrames[offset];
        try {
            processBlock(block, frame, workSet);
        } catch (SimException ex) {
            ex.addContext("...while working on block " + Hex.u2(offset));
            throw ex;
        }
    }

    addReturnBlock();
    addSynchExceptionHandlerBlock();
    addExceptionSetupBlocks();

    if (hasSubroutines) {
        // Subroutines are very rare, so skip this step if it's n/a
        inlineSubroutines();
    }
}
 
Example 15
Source File: LocalVariableExtractor.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance. This method is private. Use {@link #extract}.
 *
 * @param method {@code non-null;} the method to extract from
 */
private LocalVariableExtractor(RopMethod method) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    BasicBlockList blocks = method.getBlocks();
    int maxLabel = blocks.getMaxLabel();

    this.method = method;
    this.blocks = blocks;
    this.resultInfo = new LocalVariableInfo(method);
    this.workSet = Bits.makeBitSet(maxLabel);
}