FileDocCategorySizeDatePackage
BlockAddresses.javaAPI DocAndroid 5.1 API4671Thu Mar 12 22:18:30 GMT 2015com.android.dx.dex.code

BlockAddresses

public final class BlockAddresses extends Object
Container for the set of {@link CodeAddress} instances associated with the blocks of a particular method. Each block has a corresponding start address, end address, and last instruction address.

Fields Summary
private final CodeAddress[]
starts
{@code non-null;} array containing addresses for the start of each basic block (indexed by basic block label)
private final CodeAddress[]
lasts
{@code non-null;} array containing addresses for the final instruction of each basic block (indexed by basic block label)
private final CodeAddress[]
ends
{@code non-null;} array containing addresses for the end (just past the final instruction) of each basic block (indexed by basic block label)
Constructors Summary
public BlockAddresses(com.android.dx.rop.code.RopMethod method)
Constructs an instance.

param
method {@code non-null;} the method to have block addresses for

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

        this.starts = new CodeAddress[maxLabel];
        this.lasts = new CodeAddress[maxLabel];
        this.ends = new CodeAddress[maxLabel];

        setupArrays(method);
    
Methods Summary
public CodeAddressgetEnd(com.android.dx.rop.code.BasicBlock block)
Gets the instance for the end (address after the final instruction) of the given block.

param
block {@code non-null;} the block in question
return
{@code non-null;} the appropriate instance

        return ends[block.getLabel()];
    
public CodeAddressgetEnd(int label)
Gets the instance for the end (address after the final instruction) of the block with the given label.

param
label {@code non-null;} the label of the block in question
return
{@code non-null;} the appropriate instance

        return ends[label];
    
public CodeAddressgetLast(com.android.dx.rop.code.BasicBlock block)
Gets the instance for the final instruction of the given block.

param
block {@code non-null;} the block in question
return
{@code non-null;} the appropriate instance

        return lasts[block.getLabel()];
    
public CodeAddressgetLast(int label)
Gets the instance for the final instruction of the block with the given label.

param
label {@code non-null;} the label of the block in question
return
{@code non-null;} the appropriate instance

        return lasts[label];
    
public CodeAddressgetStart(com.android.dx.rop.code.BasicBlock block)
Gets the instance for the start of the given block.

param
block {@code non-null;} the block in question
return
{@code non-null;} the appropriate instance

        return starts[block.getLabel()];
    
public CodeAddressgetStart(int label)
Gets the instance for the start of the block with the given label.

param
label {@code non-null;} the label of the block in question
return
{@code non-null;} the appropriate instance

        return starts[label];
    
private voidsetupArrays(com.android.dx.rop.code.RopMethod method)
Sets up the address arrays.

        BasicBlockList blocks = method.getBlocks();
        int sz = blocks.size();

        for (int i = 0; i < sz; i++) {
            BasicBlock one = blocks.get(i);
            int label = one.getLabel();
            Insn insn = one.getInsns().get(0);

            starts[label] = new CodeAddress(insn.getPosition());

            SourcePosition pos = one.getLastInsn().getPosition();

            lasts[label] = new CodeAddress(pos);
            ends[label] = new CodeAddress(pos);
        }