FileDocCategorySizeDatePackage
InsnList.javaAPI DocAndroid 5.1 API3627Thu Mar 12 22:18:30 GMT 2015com.android.dx.rop.code

InsnList

public final class InsnList extends com.android.dx.util.FixedSizeList
List of {@link Insn} instances.

Fields Summary
Constructors Summary
public InsnList(int size)
Constructs an instance. All indices initially contain {@code null}.

param
size the size of the list

        super(size);
    
Methods Summary
public booleancontentEquals(com.android.dx.rop.code.InsnList b)
Compares the contents of this {@code InsnList} with another. The blocks must have the same number of insns, and each Insn must also return true to {@code Insn.contentEquals()}.

param
b to compare
return
true in the case described above.

        if (b == null) return false;

        int sz = size();

        if (sz != b.size()) return false;

        for (int i = 0; i < sz; i++) {
            if (!get(i).contentEquals(b.get(i))) {
                return false;
            }
        }

        return true;
    
public voidforEach(Insn.Visitor visitor)
Visits each instruction in the list, in order.

param
visitor {@code non-null;} visitor to use

        int sz = size();

        for (int i = 0; i < sz; i++) {
            get(i).accept(visitor);
        }
    
public Insnget(int n)
Gets the element at the given index. It is an error to call this with the index for an element which was never set; if you do that, this will throw {@code NullPointerException}.

param
n {@code >= 0, < size();} which index
return
{@code non-null;} element at that index

        return (Insn) get0(n);
    
public InsngetLast()
Gets the last instruction. This is just a convenient shorthand for {@code get(size() - 1)}.

return
{@code non-null;} the last instruction

        return get(size() - 1);
    
public voidset(int n, Insn insn)
Sets the instruction at the given index.

param
n {@code >= 0, < size();} which index
param
insn {@code non-null;} the instruction to set at {@code n}

        set0(n, insn);
    
public com.android.dx.rop.code.InsnListwithRegisterOffset(int delta)
Returns an instance that is identical to this one, except that the registers in each instruction are offset by the given amount. Mutability of the result is inherited from the original.

param
delta the amount to offset register numbers by
return
{@code non-null;} an appropriately-constructed instance

        int sz = size();
        InsnList result = new InsnList(sz);

        for (int i = 0; i < sz; i++) {
            Insn one = (Insn) get0(i);
            if (one != null) {
                result.set0(i, one.withRegisterOffset(delta));
            }
        }

        if (isImmutable()) {
            result.setImmutable();
        }

        return result;