Java Code Examples for com.android.dx.util.Hex#s2()

The following examples show how to use com.android.dx.util.Hex#s2() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeObserver.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitLocal(int opcode, int offset, int length,
        int idx, Type type, int value) {
    String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx);
    boolean argComment = (length == 1);
    String valueStr = "";

    if (opcode == ByteOps.IINC) {
        valueStr = ", #" +
            ((length <= 3) ? Hex.s1(value) : Hex.s2(value));
    }

    String catStr = "";
    if (type.isCategory2()) {
        catStr = (argComment ? "," : " //") + " category-2";
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + (argComment ? " // " : " ") +
                    idxStr + valueStr + catStr);
}
 
Example 2
Source File: CodeObserver.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Helper for {@link #visitConstant} where the constant is an
 * {@code int}.
 *
 * @param opcode the opcode
 * @param offset offset to the instruction
 * @param length instruction length
 * @param value constant value
 */
private void visitLiteralInt(int opcode, int offset, int length,
        int value) {
    String commentOrSpace = (length == 1) ? " // " : " ";
    String valueStr;

    opcode = bytes.getUnsignedByte(offset); // Compare with orig op below.
    if ((length == 1) || (opcode == ByteOps.BIPUSH)) {
        valueStr = "#" + Hex.s1(value);
    } else if (opcode == ByteOps.SIPUSH) {
        valueStr = "#" + Hex.s2(value);
    } else {
        valueStr = "#" + Hex.s4(value);
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + commentOrSpace + valueStr);
}
 
Example 3
Source File: CodeObserver.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitLocal(int opcode, int offset, int length,
        int idx, Type type, int value) {
    String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx);
    boolean argComment = (length == 1);
    String valueStr = "";

    if (opcode == ByteOps.IINC) {
        valueStr = ", #" +
            ((length <= 3) ? Hex.s1(value) : Hex.s2(value));
    }

    String catStr = "";
    if (type.isCategory2()) {
        catStr = (argComment ? "," : " //") + " category-2";
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + (argComment ? " // " : " ") +
                    idxStr + valueStr + catStr);
}
 
Example 4
Source File: CodeObserver.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Helper for {@link #visitConstant} where the constant is an
 * {@code int}.
 *
 * @param opcode the opcode
 * @param offset offset to the instruction
 * @param length instruction length
 * @param value constant value
 */
private void visitLiteralInt(int opcode, int offset, int length,
        int value) {
    String commentOrSpace = (length == 1) ? " // " : " ";
    String valueStr;

    opcode = bytes.getUnsignedByte(offset); // Compare with orig op below.
    if ((length == 1) || (opcode == ByteOps.BIPUSH)) {
        valueStr = "#" + Hex.s1(value);
    } else if (opcode == ByteOps.SIPUSH) {
        valueStr = "#" + Hex.s2(value);
    } else {
        valueStr = "#" + Hex.s4(value);
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + commentOrSpace + valueStr);
}
 
Example 5
Source File: CodeObserver.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
   @Override
public void visitLocal(int opcode, int offset, int length,
					   int idx, Type type, int value) {
       String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx);
       boolean argComment = (length == 1);
       String valueStr = "";

       if (opcode == ByteOps.IINC) {
           valueStr = ", #" +
               ((length <= 3) ? Hex.s1(value) : Hex.s2(value));
       }

       String catStr = "";
       if (type.isCategory2()) {
           catStr = (argComment ? "," : " //") + " category-2";
       }

       observer.parsed(bytes, offset, length,
                       header(offset) + (argComment ? " // " : " ") +
                       idxStr + valueStr + catStr);
   }
 
Example 6
Source File: CodeObserver.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Helper for {@link #visitConstant} where the constant is an
 * {@code int}.
 *
 * @param opcode the opcode
 * @param offset offset to the instruction
 * @param length instruction length
 * @param value constant value
 */
private void visitLiteralInt(int opcode, int offset, int length,
        int value) {
    String commentOrSpace = (length == 1) ? " // " : " ";
    String valueStr;

    opcode = bytes.getUnsignedByte(offset); // Compare with orig op below.
    if ((length == 1) || (opcode == ByteOps.BIPUSH)) {
        valueStr = "#" + Hex.s1(value);
    } else if (opcode == ByteOps.SIPUSH) {
        valueStr = "#" + Hex.s2(value);
    } else {
        valueStr = "#" + Hex.s4(value);
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + commentOrSpace + valueStr);
}
 
Example 7
Source File: CodeObserver.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
public void visitLocal(int opcode, int offset, int length,
        int idx, Type type, int value) {
    String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx);
    boolean argComment = (length == 1);
    String valueStr = "";

    if (opcode == ByteOps.IINC) {
        valueStr = ", #" +
            ((length <= 3) ? Hex.s1(value) : Hex.s2(value));
    }

    String catStr = "";
    if (type.isCategory2()) {
        catStr = (argComment ? "," : " //") + " category-2";
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + (argComment ? " // " : " ") +
                    idxStr + valueStr + catStr);
}
 
Example 8
Source File: CodeObserver.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Helper for {@link #visitConstant} where the constant is an
 * {@code int}.
 *
 * @param opcode the opcode
 * @param offset offset to the instruction
 * @param length instruction length
 * @param value constant value
 */
private void visitLiteralInt(int opcode, int offset, int length,
        int value) {
    String commentOrSpace = (length == 1) ? " // " : " ";
    String valueStr;

    opcode = bytes.getUnsignedByte(offset); // Compare with orig op below.
    if ((length == 1) || (opcode == ByteOps.BIPUSH)) {
        valueStr = "#" + Hex.s1(value);
    } else if (opcode == ByteOps.SIPUSH) {
        valueStr = "#" + Hex.s2(value);
    } else {
        valueStr = "#" + Hex.s4(value);
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + commentOrSpace + valueStr);
}
 
Example 9
Source File: InsnFormat.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to return the comment for a branch.
 *
 * @param insn {@code non-null;} the instruction in question
 * @return {@code non-null;} the comment
 */
protected static String branchComment(DalvInsn insn) {
    TargetInsn ti = (TargetInsn) insn;
    int offset = ti.getTargetOffset();

    return (offset == (short) offset) ? Hex.s2(offset) : Hex.s4(offset);
}
 
Example 10
Source File: InsnFormat.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to return the comment for a branch.
 *
 * @param insn {@code non-null;} the instruction in question
 * @return {@code non-null;} the comment
 */
protected static String branchComment(DalvInsn insn) {
    TargetInsn ti = (TargetInsn) insn;
    int offset = ti.getTargetOffset();

    return (offset == (short) offset) ? Hex.s2(offset) : Hex.s4(offset);
}
 
Example 11
Source File: InsnFormat.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to return the comment for a branch.
 *
 * @param insn {@code non-null;} the instruction in question
 * @return {@code non-null;} the comment
 */
protected static String branchComment(DalvInsn insn) {
    TargetInsn ti = (TargetInsn) insn;
    int offset = ti.getTargetOffset();

    return (offset == (short) offset) ? Hex.s2(offset) : Hex.s4(offset);
}
 
Example 12
Source File: InsnFormat.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to return the comment for a branch.
 *
 * @param insn {@code non-null;} the instruction in question
 * @return {@code non-null;} the comment
 */
protected static String branchComment(DalvInsn insn) {
    TargetInsn ti = (TargetInsn) insn;
    int offset = ti.getTargetOffset();

    return (offset == (short) offset) ? Hex.s2(offset) : Hex.s4(offset);
}