FileDocCategorySizeDatePackage
LineNumberList.javaAPI DocAndroid 1.5 API5079Wed May 06 22:41:02 BST 2009com.android.dx.cf.code

LineNumberList

public final class LineNumberList extends com.android.dx.util.FixedSizeList
List of "line number" entries, which are the contents of LineNumberTable attributes.

Fields Summary
public static final LineNumberList
EMPTY
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.dx.cf.code.LineNumberListconcat(com.android.dx.cf.code.LineNumberList list1, com.android.dx.cf.code.LineNumberList list2)
Returns an instance which is the concatenation of the two given instances.

param
list1 non-null; first instance
param
list2 non-null; second instance
return
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.dx.cf.code.LineNumberList$Itemget(int n)
Gets the indicated item.

param
n >= 0; which item
return
null-ok; the indicated item

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

param
pc >= 0; the address to look up
return
>= -1; the associated line number, or -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.dx.cf.code.LineNumberList$Item item)
Sets the item at the given index.

param
n >= 0, < size(); which element
param
item 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 >= 0, < size(); which element
param
startPc >= 0; start pc of this item
param
lineNumber >= 0; corresponding line number

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