Java Code Examples for org.jf.util.IndentingWriter#write()

The following examples show how to use org.jf.util.IndentingWriter#write() . 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: ArrayEncodedValueAdaptor.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
public static void writeTo(IndentingWriter writer, ArrayEncodedValue arrayEncodedValue) throws IOException {
    writer.write('{');
    Collection<? extends EncodedValue> values = arrayEncodedValue.getValue();
    if (values.size() == 0) {
        writer.write('}');
        return;
    }

    writer.write('\n');
    writer.indent(4);
    boolean first = true;
    for (EncodedValue encodedValue: values) {
        if (!first) {
            writer.write(",\n");
        }
        first = false;

        EncodedValueAdaptor.writeTo(writer, encodedValue);
    }
    writer.deindent(4);
    writer.write("\n}");
}
 
Example 2
Source File: InstructionMethodItem.java    From atlas with Apache License 2.0 6 votes vote down vote up
protected void writeCommentIfLikelyDouble(IndentingWriter writer, long val) throws IOException {
    if (NumberUtils.isLikelyDouble(val)) {
        writer.write("    # ");
        double dval = Double.longBitsToDouble(val);
        if (dval == Double.POSITIVE_INFINITY)
            writer.write("Double.POSITIVE_INFINITY");
        else if (dval == Double.NEGATIVE_INFINITY)
            writer.write("Double.NEGATIVE_INFINITY");
        else if (dval == Double.NaN)
            writer.write("Double.NaN");
        else if (dval == Double.MAX_VALUE)
            writer.write("Double.MAX_VALUE");
        else if (dval == Math.PI)
            writer.write("Math.PI");
        else if (dval == Math.E)
            writer.write("Math.E");
        else
            writer.write(Double.toString(dval));
    }
}
 
Example 3
Source File: LongRenderer.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, long val) throws IOException {
    if (val<0) {
        writer.write("-0x");
        writer.printUnsignedLongAsHex(-val);
        writer.write('L');
    } else {
        writer.write("0x");
        writer.printUnsignedLongAsHex(val);
        writer.write('L');
    }
}
 
Example 4
Source File: ArrayDataMethodItem.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public boolean writeTo(IndentingWriter writer) throws IOException {
    int elementWidth = instruction.getElementWidth();

    writer.write(".array-data ");
    writer.printSignedIntAsDec(instruction.getElementWidth());
    writer.write('\n');

    writer.indent(4);

    List<Number> elements = instruction.getArrayElements();

    String suffix = "";
    switch (elementWidth) {
        case 1:
            suffix = "t";
            break;
        case 2:
            suffix = "s";
            break;
    }

    for (Number number: elements) {
        LongRenderer.writeSignedIntOrLongTo(writer, number.longValue());
        writer.write(suffix);
        if (elementWidth == 4)
            writeResourceId(writer, number.intValue());
        writer.write("\n");
    }
    writer.deindent(4);
    writer.write(".end array-data");
    return true;
}
 
Example 5
Source File: SparseSwitchMethodItem.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Override
public boolean writeTo(IndentingWriter writer) throws IOException {
    writer.write(".sparse-switch\n");
    writer.indent(4);
    for (SparseSwitchTarget target: targets) {
        IntegerRenderer.writeTo(writer, target.getKey());
        writer.write(" -> ");
        target.writeTargetTo(writer);
        writeResourceId(writer, target.getKey());
        writer.write('\n');
    }
    writer.deindent(4);
    writer.write(".end sparse-switch");
    return true;
}
 
Example 6
Source File: InstructionMethodItem.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
protected void writeResourceId(IndentingWriter writer, int val) throws IOException {
    Map<Integer,String> resourceIds = methodDef.classDef.options.resourceIds;
    String resource = resourceIds.get(Integer.valueOf(val));
    if (resource != null) {
        writer.write("    # ");
        writer.write(resource);
    }
}
 
Example 7
Source File: BooleanRenderer.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, boolean val) throws IOException {
    if (val) {
        writer.write("true");
    } else {
        writer.write("false");
    }
}
 
Example 8
Source File: ClassDefinition.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
private void writeSuper(IndentingWriter writer) throws IOException {
    String superClass = classDef.getSuperclass();
    if (superClass != null) {
        writer.write(".super ");
        writer.write(superClass);
        writer.write('\n');
    }
}
 
Example 9
Source File: InstructionMethodItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
protected void writeResourceId(IndentingWriter writer, int val) throws IOException {
    Map<Integer,String> resourceIds = methodDef.classDef.options.resourceIds;
    String resource = resourceIds.get(Integer.valueOf(val));
    if (resource != null) {
        writer.write("    # ");
        writer.write(resource);
    }
}
 
Example 10
Source File: CommentMethodItem.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
public boolean writeTo(IndentingWriter writer) throws IOException {
    writer.write('#');
    writer.write(comment);
    return true;
}
 
Example 11
Source File: InstructionMethodItem.java    From atlas with Apache License 2.0 4 votes vote down vote up
protected void writeOpcode(IndentingWriter writer) throws IOException {
    writer.write(instruction.getOpcode().name);
}
 
Example 12
Source File: FieldDefinition.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
private static void writeAccessFlags(IndentingWriter writer, int accessFlags) throws IOException {
    for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForField(accessFlags)) {
        writer.write(accessFlag.toString());
        writer.write(' ');
    }
}
 
Example 13
Source File: CommentedOutMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public boolean writeTo(IndentingWriter writer) throws IOException {
    writer.write('#');
    commentedOutMethodItem.writeTo(writer);
    return true;
}
 
Example 14
Source File: FloatRenderer.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public static void writeTo(IndentingWriter writer, float val) throws IOException {
    writer.write(Float.toString(val));
    writer.write('f');
}
 
Example 15
Source File: InstructionMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
protected void writeInlineIndex(IndentingWriter writer) throws IOException {
    writer.write("inline@");
    writer.printSignedIntAsDec(((InlineIndexInstruction)instruction).getInlineIndex());
}
 
Example 16
Source File: DoubleRenderer.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public static void writeTo(IndentingWriter writer, double val) throws IOException {
    writer.write(Double.toString(val));
}
 
Example 17
Source File: DoubleRenderer.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public static void writeTo(IndentingWriter writer, double val) throws IOException {
    writer.write(Double.toString(val));
}
 
Example 18
Source File: SparseSwitchMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public void writeTargetTo(IndentingWriter writer) throws IOException {
    if (target >= 0) {
        writer.write('+');
    }
    writer.printSignedIntAsDec(target);
}
 
Example 19
Source File: ClassDefinition.java    From atlas with Apache License 2.0 4 votes vote down vote up
private void writeClass(IndentingWriter writer) throws IOException {
    writer.write(".class ");
    writeAccessFlags(writer);
    writer.write(TypeGenUtil.newType(classDef.getType()));
    writer.write('\n');
}
 
Example 20
Source File: CharRenderer.java    From atlas with Apache License 2.0 4 votes vote down vote up
public static void writeTo(IndentingWriter writer, char val) throws IOException {
    writer.write('\'');
    StringUtils.writeEscapedChar(writer, val);
    writer.write('\'');
}