Java Code Examples for com.android.dx.rop.cst.Constant#toHuman()

The following examples show how to use com.android.dx.rop.cst.Constant#toHuman() . 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: AnnotationParser.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #parseValue}, which parses a constant reference
 * and returns the referred-to constant value.
 *
 * @return {@code non-null;} the parsed value
 */
private Constant parseConstant() throws IOException {
    int constValueIndex = input.readUnsignedShort();
    Constant value = (Constant) pool.get(constValueIndex);

    if (observer != null) {
        String human = (value instanceof CstString)
            ? ((CstString) value).toQuoted()
            : value.toHuman();
        parsed(2, "constant_value: " + human);
    }

    return value;
}
 
Example 2
Source File: ThrowingCstInsn.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String getInlineString() {
    Constant cst = getConstant();
    String constantString = cst.toHuman();
    if (cst instanceof CstString) {
        constantString = ((CstString) cst).toQuoted();
    }
    return constantString + " " + ThrowingInsn.toCatchString(catches);
}
 
Example 3
Source File: AnnotationParser.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #parseValue}, which parses a constant reference
 * and returns the referred-to constant value.
 *
 * @return {@code non-null;} the parsed value
 */
private Constant parseConstant() throws IOException {
    int constValueIndex = input.readUnsignedShort();
    Constant value = (Constant) pool.get(constValueIndex);

    if (observer != null) {
        String human = (value instanceof CstString)
            ? ((CstString) value).toQuoted()
            : value.toHuman();
        parsed(2, "constant_value: " + human);
    }

    return value;
}
 
Example 4
Source File: ThrowingCstInsn.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String getInlineString() {
    Constant cst = getConstant();
    String constantString = cst.toHuman();
    if (cst instanceof CstString) {
        constantString = ((CstString) cst).toQuoted();
    }
    return constantString + " " + ThrowingInsn.toCatchString(catches);
}
 
Example 5
Source File: AnnotationParser.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #parseValue}, which parses a constant reference
 * and returns the referred-to constant value.
 *
 * @return {@code non-null;} the parsed value
 */
private Constant parseConstant() throws IOException {
    int constValueIndex = input.readUnsignedShort();
    Constant value = (Constant) pool.get(constValueIndex);

    if (observer != null) {
        String human = (value instanceof CstString)
            ? ((CstString) value).toQuoted()
            : value.toHuman();
        parsed(2, "constant_value: " + human);
    }

    return value;
}
 
Example 6
Source File: ThrowingCstInsn.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String getInlineString() {
    Constant cst = getConstant();
    String constantString = cst.toHuman();
    if (cst instanceof CstString) {
        constantString = ((CstString) cst).toQuoted();
    }
    return constantString + " " + ThrowingInsn.toCatchString(catches);
}
 
Example 7
Source File: AnnotationParser.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #parseValue}, which parses a constant reference
 * and returns the referred-to constant value.
 *
 * @return {@code non-null;} the parsed value
 */
private Constant parseConstant() throws IOException {
    int constValueIndex = input.readUnsignedShort();
    Constant value = (Constant) pool.get(constValueIndex);

    if (observer != null) {
        String human = (value instanceof CstString)
            ? ((CstString) value).toQuoted()
            : value.toHuman();
        parsed(2, "constant_value: " + human);
    }

    return value;
}
 
Example 8
Source File: ThrowingCstInsn.java    From buck with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String getInlineString() {
    Constant cst = getConstant();
    String constantString = cst.toHuman();
    if (cst instanceof CstString) {
        constantString = ((CstString) cst).toQuoted();
    }
    return constantString + " " + ThrowingInsn.toCatchString(catches);
}
 
Example 9
Source File: InsnFormat.java    From buck with Apache License 2.0 3 votes vote down vote up
/**
 * Helper method to return the constant string for a {@link CstInsn}
 * in human form.
 *
 * @param insn {@code non-null;} a constant-bearing instruction
 * @return {@code non-null;} the human string form of the contained
 * constant
 */
protected static String cstString(DalvInsn insn) {
    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    return cst instanceof CstString ? ((CstString) cst).toQuoted() : cst.toHuman();
}