FileDocCategorySizeDatePackage
InsnList.javaAPI DocAndroid 1.5 API3623Wed May 06 22:41:02 BST 2009com.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 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 InsnList with another. The blocks must have the same number of insns, and each Insn must also return true to 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 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 NullPointerException.

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

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

return
non-null; the last instruction

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

param
n >= 0, < size(); which index
param
insn non-null; the instruction to set at 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
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;