Search in sources :

Example 1 with AttSourceFile

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

the class StdAttributeFactory method sourceFile.

/**
     * Parses a {@code SourceFile} attribute.
     */
private Attribute sourceFile(DirectClassFile cf, int offset, int length, ParseObserver observer) {
    if (length != 2) {
        throwBadLength(2);
    }
    ByteArray bytes = cf.getBytes();
    ConstantPool pool = cf.getConstantPool();
    int idx = bytes.getUnsignedShort(offset);
    CstString cst = (CstString) pool.get(idx);
    Attribute result = new AttSourceFile(cst);
    if (observer != null) {
        observer.parsed(bytes, offset, 2, "source: " + cst);
    }
    return result;
}
Also used : Attribute(com.android.dx.cf.iface.Attribute) ConstantPool(com.android.dx.rop.cst.ConstantPool) CstString(com.android.dx.rop.cst.CstString) AttSourceFile(com.android.dx.cf.attrib.AttSourceFile) ByteArray(com.android.dx.util.ByteArray)

Example 2 with AttSourceFile

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

the class DirectClassFile method getSourceFile.

/** {@inheritDoc} */
public CstString getSourceFile() {
    AttributeList attribs = getAttributes();
    Attribute attSf = attribs.findFirst(AttSourceFile.ATTRIBUTE_NAME);
    if (attSf instanceof AttSourceFile) {
        return ((AttSourceFile) attSf).getSourceFile();
    }
    return null;
}
Also used : Attribute(com.android.dx.cf.iface.Attribute) StdAttributeList(com.android.dx.cf.iface.StdAttributeList) AttributeList(com.android.dx.cf.iface.AttributeList) AttSourceFile(com.android.dx.cf.attrib.AttSourceFile)

Aggregations

AttSourceFile (com.android.dx.cf.attrib.AttSourceFile)2 Attribute (com.android.dx.cf.iface.Attribute)2 AttributeList (com.android.dx.cf.iface.AttributeList)1 StdAttributeList (com.android.dx.cf.iface.StdAttributeList)1 ConstantPool (com.android.dx.rop.cst.ConstantPool)1 CstString (com.android.dx.rop.cst.CstString)1 ByteArray (com.android.dx.util.ByteArray)1