use of com.taobao.android.dx.cf.iface.Attribute in project atlas by alibaba.
the class AttributeFactory method parse0.
/**
* Parses attribute content. The base class implements this by constructing
* an instance of {@link RawAttribute}. Subclasses are expected to
* override this to do something better in most cases.
*
* @param cf {@code non-null;} class file to parse from
* @param context context to parse in; one of the {@code CTX_*}
* constants
* @param name {@code non-null;} the attribute name
* @param offset offset into {@code bytes} to start parsing at; this
* is the offset to the start of attribute data, not to the header
* @param length the length of the attribute data
* @param observer {@code null-ok;} parse observer to report to, if any
* @return {@code non-null;} an appropriately-constructed {@link Attribute}
*/
protected Attribute parse0(DirectClassFile cf, int context, String name, int offset, int length, ParseObserver observer) {
ByteArray bytes = cf.getBytes();
ConstantPool pool = cf.getConstantPool();
Attribute result = new RawAttribute(name, bytes, offset, length, pool);
if (observer != null) {
observer.parsed(bytes, offset, length, "attribute data");
}
return result;
}
use of com.taobao.android.dx.cf.iface.Attribute in project atlas by alibaba.
the class AttributeListParser method parse.
/**
* Does the actual parsing.
*/
private void parse() {
int sz = list.size();
// Skip the count.
int at = offset + 2;
ByteArray bytes = cf.getBytes();
if (observer != null) {
observer.parsed(bytes, offset, 2, "attributes_count: " + Hex.u2(sz));
}
for (int i = 0; i < sz; i++) {
try {
if (observer != null) {
observer.parsed(bytes, at, 0, "\nattributes[" + i + "]:\n");
observer.changeIndent(1);
}
Attribute attrib = attributeFactory.parse(cf, context, at, observer);
at += attrib.byteLength();
list.set(i, attrib);
if (observer != null) {
observer.changeIndent(-1);
observer.parsed(bytes, at, 0, "end attributes[" + i + "]\n");
}
} catch (ParseException ex) {
ex.addContext("...while parsing attributes[" + i + "]");
throw ex;
} catch (RuntimeException ex) {
ParseException pe = new ParseException(ex);
pe.addContext("...while parsing attributes[" + i + "]");
throw pe;
}
}
endOffset = at;
}
use of com.taobao.android.dx.cf.iface.Attribute 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;
}
Aggregations