Search in sources :

Example 21 with ByteArray

use of com.taobao.android.dx.util.ByteArray 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;
}
Also used : Attribute(com.taobao.android.dx.cf.iface.Attribute) ByteArray(com.taobao.android.dx.util.ByteArray) ParseException(com.taobao.android.dx.cf.iface.ParseException)

Example 22 with ByteArray

use of com.taobao.android.dx.util.ByteArray in project atlas by alibaba.

the class BlockDumper method dump.

/**
     * Does the dumping.
     */
public void dump() {
    byte[] bytes = getBytes();
    ByteArray ba = new ByteArray(bytes);
    /*
         * First, parse the file completely, so we can safely refer to
         * attributes, etc.
         */
    classFile = new DirectClassFile(ba, getFilePath(), getStrictParse());
    classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
    // Force parsing to happen.
    classFile.getMagic();
    // Next, reparse it and observe the process.
    DirectClassFile liveCf = new DirectClassFile(ba, getFilePath(), getStrictParse());
    liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    liveCf.setObserver(this);
    // Force parsing to happen.
    liveCf.getMagic();
}
Also used : DirectClassFile(com.taobao.android.dx.cf.direct.DirectClassFile) ByteArray(com.taobao.android.dx.util.ByteArray)

Example 23 with ByteArray

use of com.taobao.android.dx.util.ByteArray in project atlas by alibaba.

the class DotDumper method run.

private void run() {
    ByteArray ba = new ByteArray(bytes);
    /*
         * First, parse the file completely, so we can safely refer to
         * attributes, etc.
         */
    classFile = new DirectClassFile(ba, filePath, strictParse);
    classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
    // Force parsing to happen.
    classFile.getMagic();
    // Next, reparse it and observe the process.
    DirectClassFile liveCf = new DirectClassFile(ba, filePath, strictParse);
    liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    liveCf.setObserver(this);
    // Force parsing to happen.
    liveCf.getMagic();
}
Also used : DirectClassFile(com.taobao.android.dx.cf.direct.DirectClassFile) ByteArray(com.taobao.android.dx.util.ByteArray)

Aggregations

ByteArray (com.taobao.android.dx.util.ByteArray)23 ConstantPool (com.taobao.android.dx.rop.cst.ConstantPool)9 Attribute (com.taobao.android.dx.cf.iface.Attribute)7 CstString (com.taobao.android.dx.rop.cst.CstString)6 DirectClassFile (com.taobao.android.dx.cf.direct.DirectClassFile)4 ParseException (com.taobao.android.dx.cf.iface.ParseException)4 CstType (com.taobao.android.dx.rop.cst.CstType)4 BytecodeArray (com.taobao.android.dx.cf.code.BytecodeArray)3 LocalVariableList (com.taobao.android.dx.cf.code.LocalVariableList)3 ByteCatchList (com.taobao.android.dx.cf.code.ByteCatchList)2 StdAttributeList (com.taobao.android.dx.cf.iface.StdAttributeList)2 CstNat (com.taobao.android.dx.rop.cst.CstNat)2 IntList (com.taobao.android.dx.util.IntList)2 AttCode (com.taobao.android.dx.cf.attrib.AttCode)1 AttConstantValue (com.taobao.android.dx.cf.attrib.AttConstantValue)1 AttEnclosingMethod (com.taobao.android.dx.cf.attrib.AttEnclosingMethod)1 AttExceptions (com.taobao.android.dx.cf.attrib.AttExceptions)1 AttInnerClasses (com.taobao.android.dx.cf.attrib.AttInnerClasses)1 AttLineNumberTable (com.taobao.android.dx.cf.attrib.AttLineNumberTable)1 AttLocalVariableTable (com.taobao.android.dx.cf.attrib.AttLocalVariableTable)1