Search in sources :

Example 1 with AttLineNumberTable

use of com.android.dx.cf.attrib.AttLineNumberTable in project buck by facebook.

the class StdAttributeFactory method lineNumberTable.

/**
     * Parses a {@code LineNumberTable} attribute.
     */
private Attribute lineNumberTable(DirectClassFile cf, int offset, int length, ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }
    ByteArray bytes = cf.getBytes();
    // line_number_table_length
    int count = bytes.getUnsignedShort(offset);
    if (observer != null) {
        observer.parsed(bytes, offset, 2, "line_number_table_length: " + Hex.u2(count));
    }
    offset += 2;
    length -= 2;
    if (length != (count * 4)) {
        throwBadLength((count * 4) + 2);
    }
    LineNumberList list = new LineNumberList(count);
    for (int i = 0; i < count; i++) {
        int startPc = bytes.getUnsignedShort(offset);
        int lineNumber = bytes.getUnsignedShort(offset + 2);
        list.set(i, startPc, lineNumber);
        if (observer != null) {
            observer.parsed(bytes, offset, 4, Hex.u2(startPc) + " " + lineNumber);
        }
        offset += 4;
    }
    list.setImmutable();
    return new AttLineNumberTable(list);
}
Also used : LineNumberList(com.android.dx.cf.code.LineNumberList) ByteArray(com.android.dx.util.ByteArray) AttLineNumberTable(com.android.dx.cf.attrib.AttLineNumberTable)

Example 2 with AttLineNumberTable

use of com.android.dx.cf.attrib.AttLineNumberTable in project J2ME-Loader by nikita36078.

the class StdAttributeFactory method lineNumberTable.

/**
 * Parses a {@code LineNumberTable} attribute.
 */
private Attribute lineNumberTable(DirectClassFile cf, int offset, int length, ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }
    ByteArray bytes = cf.getBytes();
    // line_number_table_length
    int count = bytes.getUnsignedShort(offset);
    if (observer != null) {
        observer.parsed(bytes, offset, 2, "line_number_table_length: " + Hex.u2(count));
    }
    offset += 2;
    length -= 2;
    if (length != (count * 4)) {
        throwBadLength((count * 4) + 2);
    }
    LineNumberList list = new LineNumberList(count);
    for (int i = 0; i < count; i++) {
        int startPc = bytes.getUnsignedShort(offset);
        int lineNumber = bytes.getUnsignedShort(offset + 2);
        list.set(i, startPc, lineNumber);
        if (observer != null) {
            observer.parsed(bytes, offset, 4, Hex.u2(startPc) + " " + lineNumber);
        }
        offset += 4;
    }
    list.setImmutable();
    return new AttLineNumberTable(list);
}
Also used : LineNumberList(com.android.dx.cf.code.LineNumberList) ByteArray(com.android.dx.util.ByteArray) AttLineNumberTable(com.android.dx.cf.attrib.AttLineNumberTable)

Aggregations

AttLineNumberTable (com.android.dx.cf.attrib.AttLineNumberTable)2 LineNumberList (com.android.dx.cf.code.LineNumberList)2 ByteArray (com.android.dx.util.ByteArray)2