Search in sources :

Example 21 with BasicBlockList

use of com.android.dx.rop.code.BasicBlockList in project J2ME-Loader by nikita36078.

the class StdCatchBuilder method hasAnyCatches.

/**
 * {@inheritDoc}
 */
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;
}
Also used : BasicBlock(com.android.dx.rop.code.BasicBlock) BasicBlockList(com.android.dx.rop.code.BasicBlockList) TypeList(com.android.dx.rop.type.TypeList)

Example 22 with BasicBlockList

use of com.android.dx.rop.code.BasicBlockList in project J2ME-Loader by nikita36078.

the class SsaBasicBlock method newFromRop.

/**
 * Creates a new SSA basic block from a ROP form basic block.
 *
 * @param rmeth original method
 * @param basicBlockIndex index this block will have
 * @param parent method of this block predecessor set will be
 * updated
 * @return new instance
 */
public static SsaBasicBlock newFromRop(RopMethod rmeth, int basicBlockIndex, final SsaMethod parent) {
    BasicBlockList ropBlocks = rmeth.getBlocks();
    BasicBlock bb = ropBlocks.get(basicBlockIndex);
    SsaBasicBlock result = new SsaBasicBlock(basicBlockIndex, bb.getLabel(), parent);
    InsnList ropInsns = bb.getInsns();
    result.insns.ensureCapacity(ropInsns.size());
    for (int i = 0, sz = ropInsns.size(); i < sz; i++) {
        result.insns.add(new NormalSsaInsn(ropInsns.get(i), result));
    }
    result.predecessors = SsaMethod.bitSetFromLabelList(ropBlocks, rmeth.labelToPredecessors(bb.getLabel()));
    result.successors = SsaMethod.bitSetFromLabelList(ropBlocks, bb.getSuccessors());
    result.successorList = SsaMethod.indexListFromLabelList(ropBlocks, bb.getSuccessors());
    if (result.successorList.size() != 0) {
        int primarySuccessor = bb.getPrimarySuccessor();
        result.primarySuccessor = (primarySuccessor < 0) ? -1 : ropBlocks.indexOfLabel(primarySuccessor);
    }
    return result;
}
Also used : BasicBlock(com.android.dx.rop.code.BasicBlock) InsnList(com.android.dx.rop.code.InsnList) BasicBlockList(com.android.dx.rop.code.BasicBlockList)

Aggregations

BasicBlockList (com.android.dx.rop.code.BasicBlockList)22 BasicBlock (com.android.dx.rop.code.BasicBlock)14 RopMethod (com.android.dx.rop.code.RopMethod)4 TypeList (com.android.dx.rop.type.TypeList)4 IntList (com.android.dx.util.IntList)4 Insn (com.android.dx.rop.code.Insn)3 InsnList (com.android.dx.rop.code.InsnList)3 DexTranslationAdvice (com.android.dx.rop.code.DexTranslationAdvice)2 SourcePosition (com.android.dx.rop.code.SourcePosition)2 TranslationAdvice (com.android.dx.rop.code.TranslationAdvice)2 CstType (com.android.dx.rop.cst.CstType)2 Type (com.android.dx.rop.type.Type)2 SsaBasicBlock (com.android.dx.ssa.SsaBasicBlock)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 BytecodeArray (com.android.dx.cf.code.BytecodeArray)1 ConcreteMethod (com.android.dx.cf.code.ConcreteMethod)1 Method (com.android.dx.cf.iface.Method)1 ByteArray (com.android.dx.util.ByteArray)1