FileDocCategorySizeDatePackage
LineNumberList.javaAPI DocAndroid 5.1 API5161Thu Mar 12 22:18:30 GMT 2015com.android.dexgen.rop

LineNumberList

public final class LineNumberList extends com.android.dexgen.util.FixedSizeList
List of "line number" entries, which are the contents of {@code LineNumberTable} attributes.

Fields Summary
public static final LineNumberList
EMPTY
{@code non-null;} zero-size instance
Constructors Summary
public LineNumberList(int count)
Constructs an instance.

param
count the number of elements to be in the list

        super(count);
    
Methods Summary
public static com.android.dexgen.rop.LineNumberListconcat(com.android.dexgen.rop.LineNumberList list1, com.android.dexgen.rop.LineNumberList list2)
Returns an instance which is the concatenation of the two given instances.

param
list1 {@code non-null;} first instance
param
list2 {@code non-null;} second instance
return
{@code non-null;} combined instance


                                      
        
                                          
        if (list1 == EMPTY) {
            // easy case
            return list2;
        }

        int sz1 = list1.size();
        int sz2 = list2.size();
        LineNumberList result = new LineNumberList(sz1 + sz2);

        for (int i = 0; i < sz1; i++) {
            result.set(i, list1.get(i));
        }

        for (int i = 0; i < sz2; i++) {
            result.set(sz1 + i, list2.get(i));
        }

        return result;
    
public com.android.dexgen.rop.LineNumberList$Itemget(int n)
Gets the indicated item.

param
n {@code >= 0;} which item
return
{@code null-ok;} the indicated item

        return (Item) get0(n);
    
public intpcToLine(int pc)
Gets the line number associated with the given address.

param
pc {@code >= 0;} the address to look up
return
{@code >= -1;} the associated line number, or {@code -1} if none is known

        /*
         * Line number entries don't have to appear in any particular
         * order, so we have to do a linear search. TODO: If
         * this turns out to be a bottleneck, consider sorting the
         * list prior to use.
         */
        int sz = size();
        int bestPc = -1;
        int bestLine = -1;

        for (int i = 0; i < sz; i++) {
            Item one = get(i);
            int onePc = one.getStartPc();
            if ((onePc <= pc) && (onePc > bestPc)) {
                bestPc = onePc;
                bestLine = one.getLineNumber();
                if (bestPc == pc) {
                    // We can't do better than this
                    break;
                }
            }
        }

        return bestLine;
    
public voidset(int n, com.android.dexgen.rop.LineNumberList$Item item)
Sets the item at the given index.

param
n {@code >= 0, < size();} which element
param
item {@code non-null;} the item

        if (item == null) {
            throw new NullPointerException("item == null");
        }

        set0(n, item);
    
public voidset(int n, int startPc, int lineNumber)
Sets the item at the given index.

param
n {@code >= 0, < size();} which element
param
startPc {@code >= 0;} start pc of this item
param
lineNumber {@code >= 0;} corresponding line number

        set0(n, new Item(startPc, lineNumber));