Search in sources :

Example 1 with AttSourceFile

use of com.taobao.android.dx.cf.attrib.AttSourceFile in project atlas by alibaba.

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.taobao.android.dx.cf.iface.Attribute) ConstantPool(com.taobao.android.dx.rop.cst.ConstantPool) CstString(com.taobao.android.dx.rop.cst.CstString) AttSourceFile(com.taobao.android.dx.cf.attrib.AttSourceFile) ByteArray(com.taobao.android.dx.util.ByteArray)

Example 2 with AttSourceFile

use of com.taobao.android.dx.cf.attrib.AttSourceFile in project atlas by alibaba.

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.taobao.android.dx.cf.iface.Attribute) AttributeList(com.taobao.android.dx.cf.iface.AttributeList) StdAttributeList(com.taobao.android.dx.cf.iface.StdAttributeList) AttSourceFile(com.taobao.android.dx.cf.attrib.AttSourceFile)

Aggregations

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