Search in sources :

Example 1 with CONSTANT_String

use of com.android.dx.cf.cst.ConstantTags.CONSTANT_String in project J2ME-Loader by nikita36078.

the class ConstantPoolParser method parse.

/**
 * Does the actual parsing.
 */
private void parse() {
    determineOffsets();
    if (observer != null) {
        observer.parsed(bytes, 8, 2, "constant_pool_count: " + Hex.u2(offsets.length));
        observer.parsed(bytes, 10, 0, "\nconstant_pool:");
        observer.changeIndent(1);
    }
    /*
         * Track the constant value's original string type. True if constants[i] was
         * a CONSTANT_Utf8, false for any other type including CONSTANT_string.
         */
    BitSet wasUtf8 = new BitSet(offsets.length);
    for (int i = 1; i < offsets.length; i++) {
        int offset = offsets[i];
        if ((offset != 0) && (pool.getOrNull(i) == null)) {
            parse0(i, wasUtf8);
        }
    }
    if (observer != null) {
        for (int i = 1; i < offsets.length; i++) {
            Constant cst = pool.getOrNull(i);
            if (cst == null) {
                continue;
            }
            int offset = offsets[i];
            int nextOffset = endOffset;
            for (int j = i + 1; j < offsets.length; j++) {
                int off = offsets[j];
                if (off != 0) {
                    nextOffset = off;
                    break;
                }
            }
            String human = wasUtf8.get(i) ? Hex.u2(i) + ": utf8{\"" + cst.toHuman() + "\"}" : Hex.u2(i) + ": " + cst.toString();
            observer.parsed(bytes, offset, nextOffset - offset, human);
        }
        observer.changeIndent(-1);
        observer.parsed(bytes, endOffset, 0, "end constant_pool");
    }
}
Also used : Constant(com.android.dx.rop.cst.Constant) BitSet(java.util.BitSet) CONSTANT_String(com.android.dx.cf.cst.ConstantTags.CONSTANT_String) CstString(com.android.dx.rop.cst.CstString)

Example 2 with CONSTANT_String

use of com.android.dx.cf.cst.ConstantTags.CONSTANT_String in project buck by facebook.

the class ConstantPoolParser method parse.

/**
     * Does the actual parsing.
     */
private void parse() {
    determineOffsets();
    if (observer != null) {
        observer.parsed(bytes, 8, 2, "constant_pool_count: " + Hex.u2(offsets.length));
        observer.parsed(bytes, 10, 0, "\nconstant_pool:");
        observer.changeIndent(1);
    }
    /*
         * Track the constant value's original string type. True if constants[i] was
         * a CONSTANT_Utf8, false for any other type including CONSTANT_string.
         */
    BitSet wasUtf8 = new BitSet(offsets.length);
    for (int i = 1; i < offsets.length; i++) {
        int offset = offsets[i];
        if ((offset != 0) && (pool.getOrNull(i) == null)) {
            parse0(i, wasUtf8);
        }
    }
    if (observer != null) {
        for (int i = 1; i < offsets.length; i++) {
            Constant cst = pool.getOrNull(i);
            if (cst == null) {
                continue;
            }
            int offset = offsets[i];
            int nextOffset = endOffset;
            for (int j = i + 1; j < offsets.length; j++) {
                int off = offsets[j];
                if (off != 0) {
                    nextOffset = off;
                    break;
                }
            }
            String human = wasUtf8.get(i) ? Hex.u2(i) + ": utf8{\"" + cst.toHuman() + "\"}" : Hex.u2(i) + ": " + cst.toString();
            observer.parsed(bytes, offset, nextOffset - offset, human);
        }
        observer.changeIndent(-1);
        observer.parsed(bytes, endOffset, 0, "end constant_pool");
    }
}
Also used : Constant(com.android.dx.rop.cst.Constant) BitSet(java.util.BitSet) CONSTANT_String(com.android.dx.cf.cst.ConstantTags.CONSTANT_String) CstString(com.android.dx.rop.cst.CstString)

Aggregations

CONSTANT_String (com.android.dx.cf.cst.ConstantTags.CONSTANT_String)2 Constant (com.android.dx.rop.cst.Constant)2 CstString (com.android.dx.rop.cst.CstString)2 BitSet (java.util.BitSet)2