mirror of
https://github.com/revanced/smali.git
synced 2025-05-05 09:04:25 +02:00
delete IndentingPrintWriter and refactor everything to use IndentingWriter directly
git-svn-id: https://smali.googlecode.com/svn/trunk@688 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
bf483ac86d
commit
0b2f7d6a57
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.AnnotationItem;
|
import org.jf.dexlib.AnnotationItem;
|
||||||
import org.jf.baksmali.Adaptors.EncodedValue.AnnotationEncodedValueAdaptor;
|
import org.jf.baksmali.Adaptors.EncodedValue.AnnotationEncodedValueAdaptor;
|
||||||
import org.jf.dexlib.AnnotationSetItem;
|
import org.jf.dexlib.AnnotationSetItem;
|
||||||
@ -38,11 +38,11 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class AnnotationFormatter {
|
public class AnnotationFormatter {
|
||||||
|
|
||||||
public static void writeTo(IndentingPrintWriter writer, AnnotationSetItem annotationSet) throws IOException {
|
public static void writeTo(IndentingWriter writer, AnnotationSetItem annotationSet) throws IOException {
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (AnnotationItem annotationItem: annotationSet.getAnnotations()) {
|
for (AnnotationItem annotationItem: annotationSet.getAnnotations()) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
@ -50,15 +50,15 @@ public class AnnotationFormatter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeTo(IndentingPrintWriter writer, AnnotationItem annotationItem) throws IOException {
|
public static void writeTo(IndentingWriter writer, AnnotationItem annotationItem) throws IOException {
|
||||||
writer.write(".annotation ");
|
writer.write(".annotation ");
|
||||||
writer.write(annotationItem.getVisibility().visibility);
|
writer.write(annotationItem.getVisibility().visibility);
|
||||||
writer.write(' ');
|
writer.write(' ');
|
||||||
ReferenceFormatter.writeTypeReference(writer, annotationItem.getEncodedAnnotation().annotationType);
|
ReferenceFormatter.writeTypeReference(writer, annotationItem.getEncodedAnnotation().annotationType);
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
|
|
||||||
AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotationItem.getEncodedAnnotation());
|
AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotationItem.getEncodedAnnotation());
|
||||||
|
|
||||||
writer.println(".end annotation");
|
writer.write(".end annotation\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
//a "spacer" between instructions
|
//a "spacer" between instructions
|
||||||
public class BlankMethodItem extends MethodItem {
|
public class BlankMethodItem extends MethodItem {
|
||||||
@ -40,7 +40,7 @@ public class BlankMethodItem extends MethodItem {
|
|||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean writeTo(IndentingPrintWriter writer) {
|
public boolean writeTo(IndentingWriter writer) {
|
||||||
//we didn't technically print something, but returning true indicates that a newline should be printed
|
//we didn't technically print something, but returning true indicates that a newline should be printed
|
||||||
//after this method item, which is the intended functionality
|
//after this method item, which is the intended functionality
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,9 +28,11 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.TypeIdItem;
|
import org.jf.dexlib.TypeIdItem;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CatchMethodItem extends MethodItem {
|
public class CatchMethodItem extends MethodItem {
|
||||||
private final TypeIdItem exceptionType;
|
private final TypeIdItem exceptionType;
|
||||||
|
|
||||||
@ -76,7 +78,7 @@ public class CatchMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
if (exceptionType == null) {
|
if (exceptionType == null) {
|
||||||
writer.write(".catchall");
|
writer.write(".catchall");
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.Code.Analysis.ValidationException;
|
import org.jf.dexlib.Code.Analysis.ValidationException;
|
||||||
import org.jf.dexlib.EncodedValue.EncodedValue;
|
import org.jf.dexlib.EncodedValue.EncodedValue;
|
||||||
import org.jf.dexlib.*;
|
import org.jf.dexlib.*;
|
||||||
@ -124,7 +124,7 @@ public class ClassDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(IndentingPrintWriter writer) throws IOException {
|
public void writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeClass(writer);
|
writeClass(writer);
|
||||||
writeSuper(writer);
|
writeSuper(writer);
|
||||||
writeSourceFile(writer);
|
writeSourceFile(writer);
|
||||||
@ -137,37 +137,39 @@ public class ClassDefinition {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeClass(IndentingPrintWriter writer) {
|
private void writeClass(IndentingWriter writer) throws IOException {
|
||||||
writer.write(".class ");
|
writer.write(".class ");
|
||||||
writeAccessFlags(writer);
|
writeAccessFlags(writer);
|
||||||
writer.println(classDefItem.getClassType().getTypeDescriptor());
|
writer.write(classDefItem.getClassType().getTypeDescriptor());
|
||||||
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeAccessFlags(IndentingPrintWriter writer) {
|
private void writeAccessFlags(IndentingWriter writer) throws IOException {
|
||||||
for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForClass(classDefItem.getAccessFlags())) {
|
for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForClass(classDefItem.getAccessFlags())) {
|
||||||
writer.write(accessFlag.toString());
|
writer.write(accessFlag.toString());
|
||||||
writer.write(' ');
|
writer.write(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeSuper(IndentingPrintWriter writer) {
|
private void writeSuper(IndentingWriter writer) throws IOException {
|
||||||
TypeIdItem superClass = classDefItem.getSuperclass();
|
TypeIdItem superClass = classDefItem.getSuperclass();
|
||||||
if (superClass != null) {
|
if (superClass != null) {
|
||||||
writer.write(".super ");
|
writer.write(".super ");
|
||||||
writer.println(superClass.getTypeDescriptor());
|
writer.write(superClass.getTypeDescriptor());
|
||||||
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeSourceFile(IndentingPrintWriter writer) {
|
private void writeSourceFile(IndentingWriter writer) throws IOException {
|
||||||
StringIdItem sourceFile = classDefItem.getSourceFile();
|
StringIdItem sourceFile = classDefItem.getSourceFile();
|
||||||
if (sourceFile != null) {
|
if (sourceFile != null) {
|
||||||
writer.write(".source \"");
|
writer.write(".source \"");
|
||||||
writer.print(sourceFile.getStringValue());
|
writer.write(sourceFile.getStringValue());
|
||||||
writer.println('"');
|
writer.write("\"\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeInterfaces(IndentingPrintWriter writer) {
|
private void writeInterfaces(IndentingWriter writer) throws IOException {
|
||||||
TypeListItem interfaceList = classDefItem.getInterfaces();
|
TypeListItem interfaceList = classDefItem.getInterfaces();
|
||||||
if (interfaceList == null) {
|
if (interfaceList == null) {
|
||||||
return;
|
return;
|
||||||
@ -178,15 +180,16 @@ public class ClassDefinition {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
writer.println("# interfaces");
|
writer.write("# interfaces\n");
|
||||||
for (TypeIdItem typeIdItem: interfaceList.getTypes()) {
|
for (TypeIdItem typeIdItem: interfaceList.getTypes()) {
|
||||||
writer.write(".implements ");
|
writer.write(".implements ");
|
||||||
writer.println(typeIdItem.getTypeDescriptor());
|
writer.write(typeIdItem.getTypeDescriptor());
|
||||||
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeAnnotations(IndentingPrintWriter writer) throws IOException {
|
private void writeAnnotations(IndentingWriter writer) throws IOException {
|
||||||
AnnotationDirectoryItem annotationDirectory = classDefItem.getAnnotations();
|
AnnotationDirectoryItem annotationDirectory = classDefItem.getAnnotations();
|
||||||
if (annotationDirectory == null) {
|
if (annotationDirectory == null) {
|
||||||
return;
|
return;
|
||||||
@ -197,13 +200,12 @@ public class ClassDefinition {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write("\n\n");
|
||||||
writer.println();
|
writer.write("# annotations\n");
|
||||||
writer.println("# annotations");
|
|
||||||
AnnotationFormatter.writeTo(writer, annotationSet);
|
AnnotationFormatter.writeTo(writer, annotationSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeStaticFields(IndentingPrintWriter writer) throws IOException {
|
private void writeStaticFields(IndentingWriter writer) throws IOException {
|
||||||
if (classDataItem == null) {
|
if (classDataItem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -224,14 +226,13 @@ public class ClassDefinition {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write("\n\n");
|
||||||
writer.println();
|
writer.write("# static fields\n");
|
||||||
writer.println("# static fields");
|
|
||||||
|
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (int i=0; i<encodedFields.length; i++) {
|
for (int i=0; i<encodedFields.length; i++) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
@ -249,7 +250,7 @@ public class ClassDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeInstanceFields(IndentingPrintWriter writer) throws IOException {
|
private void writeInstanceFields(IndentingWriter writer) throws IOException {
|
||||||
if (classDataItem == null) {
|
if (classDataItem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -259,13 +260,12 @@ public class ClassDefinition {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write("\n\n");
|
||||||
writer.println();
|
writer.write("# instance fields\n");
|
||||||
writer.println("# instance fields");
|
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (ClassDataItem.EncodedField field: classDataItem.getInstanceFields()) {
|
for (ClassDataItem.EncodedField field: classDataItem.getInstanceFields()) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ public class ClassDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDirectMethods(IndentingPrintWriter writer) throws IOException {
|
private void writeDirectMethods(IndentingWriter writer) throws IOException {
|
||||||
if (classDataItem == null) {
|
if (classDataItem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -286,13 +286,12 @@ public class ClassDefinition {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write("\n\n");
|
||||||
writer.println();
|
writer.write("# direct methods\n");
|
||||||
writer.println("# direct methods");
|
|
||||||
writeMethods(writer, directMethods);
|
writeMethods(writer, directMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeVirtualMethods(IndentingPrintWriter writer) throws IOException {
|
private void writeVirtualMethods(IndentingWriter writer) throws IOException {
|
||||||
if (classDataItem == null) {
|
if (classDataItem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -303,17 +302,16 @@ public class ClassDefinition {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write("\n\n");
|
||||||
writer.println();
|
writer.write("# virtual methods\n");
|
||||||
writer.println("# virtual methods");
|
|
||||||
writeMethods(writer, virtualMethods);
|
writeMethods(writer, virtualMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeMethods(IndentingPrintWriter writer, ClassDataItem.EncodedMethod[] methods) throws IOException {
|
private void writeMethods(IndentingWriter writer, ClassDataItem.EncodedMethod[] methods) throws IOException {
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (ClassDataItem.EncodedMethod method: methods) {
|
for (ClassDataItem.EncodedMethod method: methods) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CommentMethodItem extends MethodItem {
|
public class CommentMethodItem extends MethodItem {
|
||||||
//private final StringTemplate template;
|
//private final StringTemplate template;
|
||||||
@ -45,7 +47,7 @@ public class CommentMethodItem extends MethodItem {
|
|||||||
return sortOrder;
|
return sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean writeTo(IndentingPrintWriter writer) {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writer.write('#');
|
writer.write('#');
|
||||||
writer.write(comment);
|
writer.write(comment);
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public class CommentedOutMethodItem extends MethodItem {
|
|||||||
return commentedOutMethodItem.getSortOrder() + .001;
|
return commentedOutMethodItem.getSortOrder() + .001;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writer.write('#');
|
writer.write('#');
|
||||||
commentedOutMethodItem.writeTo(writer);
|
commentedOutMethodItem.writeTo(writer);
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,11 +28,13 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.CodeItem;
|
import org.jf.dexlib.CodeItem;
|
||||||
import org.jf.dexlib.StringIdItem;
|
import org.jf.dexlib.StringIdItem;
|
||||||
import org.jf.dexlib.TypeIdItem;
|
import org.jf.dexlib.TypeIdItem;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class DebugMethodItem extends MethodItem {
|
public abstract class DebugMethodItem extends MethodItem {
|
||||||
private final double sortOrder;
|
private final double sortOrder;
|
||||||
|
|
||||||
@ -45,21 +47,22 @@ public abstract class DebugMethodItem extends MethodItem {
|
|||||||
return sortOrder;
|
return sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void writeLine(IndentingPrintWriter writer, int line) {
|
protected static void writeLine(IndentingWriter writer, int line) throws IOException {
|
||||||
writer.write(".line ");
|
writer.write(".line ");
|
||||||
writer.print(line);
|
writer.printIntAsDec(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void writeEndPrologue(IndentingPrintWriter writer) {
|
protected static void writeEndPrologue(IndentingWriter writer) throws IOException {
|
||||||
writer.write(".prologue");
|
writer.write(".prologue");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void writeBeginEpilogue(IndentingPrintWriter writer) {
|
protected static void writeBeginEpilogue(IndentingWriter writer) throws IOException {
|
||||||
writer.write(".epilogue");
|
writer.write(".epilogue");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void writeStartLocal(IndentingPrintWriter writer, CodeItem codeItem, int register,
|
protected static void writeStartLocal(IndentingWriter writer, CodeItem codeItem, int register,
|
||||||
StringIdItem name, TypeIdItem type, StringIdItem signature) {
|
StringIdItem name, TypeIdItem type, StringIdItem signature)
|
||||||
|
throws IOException {
|
||||||
writer.write(".local ");
|
writer.write(".local ");
|
||||||
RegisterFormatter.writeTo(writer, codeItem, register);
|
RegisterFormatter.writeTo(writer, codeItem, register);
|
||||||
writer.write(", ");
|
writer.write(", ");
|
||||||
@ -73,8 +76,8 @@ public abstract class DebugMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void writeEndLocal(IndentingPrintWriter writer, CodeItem codeItem, int register, StringIdItem name,
|
protected static void writeEndLocal(IndentingWriter writer, CodeItem codeItem, int register, StringIdItem name,
|
||||||
TypeIdItem type, StringIdItem signature) {
|
TypeIdItem type, StringIdItem signature) throws IOException {
|
||||||
writer.write(".end local ");
|
writer.write(".end local ");
|
||||||
RegisterFormatter.writeTo(writer, codeItem, register);
|
RegisterFormatter.writeTo(writer, codeItem, register);
|
||||||
|
|
||||||
@ -92,8 +95,9 @@ public abstract class DebugMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static void writeRestartLocal(IndentingPrintWriter writer, CodeItem codeItem, int register,
|
protected static void writeRestartLocal(IndentingWriter writer, CodeItem codeItem, int register,
|
||||||
StringIdItem name, TypeIdItem type, StringIdItem signature) {
|
StringIdItem name, TypeIdItem type, StringIdItem signature)
|
||||||
|
throws IOException {
|
||||||
writer.write(".restart local ");
|
writer.write(".restart local ");
|
||||||
RegisterFormatter.writeTo(writer, codeItem, register);
|
RegisterFormatter.writeTo(writer, codeItem, register);
|
||||||
|
|
||||||
@ -110,7 +114,7 @@ public abstract class DebugMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void writeSetFile(IndentingPrintWriter writer, String fileName) {
|
protected static void writeSetFile(IndentingWriter writer, String fileName) throws IOException {
|
||||||
writer.write(".source \"");
|
writer.write(".source \"");
|
||||||
writer.write(fileName);
|
writer.write(fileName);
|
||||||
writer.write('"');
|
writer.write('"');
|
||||||
|
@ -29,24 +29,24 @@
|
|||||||
package org.jf.baksmali.Adaptors.EncodedValue;
|
package org.jf.baksmali.Adaptors.EncodedValue;
|
||||||
|
|
||||||
import org.jf.baksmali.Adaptors.ReferenceFormatter;
|
import org.jf.baksmali.Adaptors.ReferenceFormatter;
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.EncodedValue.AnnotationEncodedSubValue;
|
import org.jf.dexlib.EncodedValue.AnnotationEncodedSubValue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class AnnotationEncodedValueAdaptor {
|
public abstract class AnnotationEncodedValueAdaptor {
|
||||||
|
|
||||||
public static void writeTo(IndentingPrintWriter writer, AnnotationEncodedSubValue encodedAnnotation)
|
public static void writeTo(IndentingWriter writer, AnnotationEncodedSubValue encodedAnnotation)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
writer.write(".subannotation ");
|
writer.write(".subannotation ");
|
||||||
ReferenceFormatter.writeTypeReference(writer, encodedAnnotation.annotationType);
|
ReferenceFormatter.writeTypeReference(writer, encodedAnnotation.annotationType);
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
|
|
||||||
writeElementsTo(writer, encodedAnnotation);
|
writeElementsTo(writer, encodedAnnotation);
|
||||||
writer.write(".end subannotation");
|
writer.write(".end subannotation");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeElementsTo(IndentingPrintWriter writer, AnnotationEncodedSubValue encodedAnnotation)
|
public static void writeElementsTo(IndentingWriter writer, AnnotationEncodedSubValue encodedAnnotation)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
writer.indent(4);
|
writer.indent(4);
|
||||||
for (int i=0; i<encodedAnnotation.names.length; i++) {
|
for (int i=0; i<encodedAnnotation.names.length; i++) {
|
||||||
@ -54,7 +54,7 @@ public abstract class AnnotationEncodedValueAdaptor {
|
|||||||
writer.write(" = ");
|
writer.write(" = ");
|
||||||
|
|
||||||
EncodedValueAdaptor.writeTo(writer, encodedAnnotation.values[i]);
|
EncodedValueAdaptor.writeTo(writer, encodedAnnotation.values[i]);
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
}
|
}
|
||||||
|
@ -28,34 +28,33 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors.EncodedValue;
|
package org.jf.baksmali.Adaptors.EncodedValue;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.EncodedValue.EncodedValue;
|
import org.jf.dexlib.EncodedValue.EncodedValue;
|
||||||
import org.jf.dexlib.EncodedValue.ArrayEncodedValue;
|
import org.jf.dexlib.EncodedValue.ArrayEncodedValue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ArrayEncodedValueAdaptor {
|
public class ArrayEncodedValueAdaptor {
|
||||||
public static void writeTo(IndentingPrintWriter writer, ArrayEncodedValue encodedArray) throws IOException {
|
public static void writeTo(IndentingWriter writer, ArrayEncodedValue encodedArray) throws IOException {
|
||||||
writer.print('{');
|
writer.write('{');
|
||||||
EncodedValue[] values = encodedArray.values;
|
EncodedValue[] values = encodedArray.values;
|
||||||
if (values == null || values.length == 0) {
|
if (values == null || values.length == 0) {
|
||||||
writer.print('}');
|
writer.write('}');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
writer.indent(4);
|
writer.indent(4);
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (EncodedValue encodedValue: encodedArray.values) {
|
for (EncodedValue encodedValue: encodedArray.values) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
writer.println(',');
|
writer.write(",\n");
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
EncodedValueAdaptor.writeTo(writer, encodedValue);
|
EncodedValueAdaptor.writeTo(writer, encodedValue);
|
||||||
}
|
}
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
writer.println();
|
writer.write("\n}");
|
||||||
writer.print('}');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,14 @@
|
|||||||
package org.jf.baksmali.Adaptors.EncodedValue;
|
package org.jf.baksmali.Adaptors.EncodedValue;
|
||||||
|
|
||||||
import org.jf.baksmali.Adaptors.ReferenceFormatter;
|
import org.jf.baksmali.Adaptors.ReferenceFormatter;
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.Renderers.*;
|
import org.jf.baksmali.Renderers.*;
|
||||||
import org.jf.dexlib.EncodedValue.*;
|
import org.jf.dexlib.EncodedValue.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class EncodedValueAdaptor {
|
public abstract class EncodedValueAdaptor {
|
||||||
public static void writeTo(IndentingPrintWriter writer, EncodedValue encodedValue) throws IOException {
|
public static void writeTo(IndentingWriter writer, EncodedValue encodedValue) throws IOException {
|
||||||
switch (encodedValue.getValueType()) {
|
switch (encodedValue.getValueType()) {
|
||||||
case VALUE_ANNOTATION:
|
case VALUE_ANNOTATION:
|
||||||
AnnotationEncodedValueAdaptor.writeTo(writer, (AnnotationEncodedValue)encodedValue);
|
AnnotationEncodedValueAdaptor.writeTo(writer, (AnnotationEncodedValue)encodedValue);
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
package org.jf.baksmali.Adaptors.EncodedValue;
|
package org.jf.baksmali.Adaptors.EncodedValue;
|
||||||
|
|
||||||
import org.jf.baksmali.Adaptors.ReferenceFormatter;
|
import org.jf.baksmali.Adaptors.ReferenceFormatter;
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.FieldIdItem;
|
import org.jf.dexlib.FieldIdItem;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class EnumEncodedValueAdaptor {
|
public class EnumEncodedValueAdaptor {
|
||||||
public static void writeTo(IndentingPrintWriter writer, FieldIdItem item) throws IOException {
|
public static void writeTo(IndentingWriter writer, FieldIdItem item) throws IOException {
|
||||||
writer.write(".enum ");
|
writer.write(".enum ");
|
||||||
ReferenceFormatter.writeFieldReference(writer, item);
|
ReferenceFormatter.writeFieldReference(writer, item);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.Adaptors.EncodedValue.EncodedValueAdaptor;
|
import org.jf.baksmali.Adaptors.EncodedValue.EncodedValueAdaptor;
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.ClassDataItem;
|
import org.jf.dexlib.ClassDataItem;
|
||||||
import org.jf.dexlib.EncodedValue.EncodedValue;
|
import org.jf.dexlib.EncodedValue.EncodedValue;
|
||||||
import org.jf.dexlib.EncodedValue.NullEncodedValue;
|
import org.jf.dexlib.EncodedValue.NullEncodedValue;
|
||||||
@ -39,7 +39,7 @@ import org.jf.dexlib.Util.AccessFlags;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class FieldDefinition {
|
public class FieldDefinition {
|
||||||
public static void writeTo(IndentingPrintWriter writer, ClassDataItem.EncodedField encodedField,
|
public static void writeTo(IndentingWriter writer, ClassDataItem.EncodedField encodedField,
|
||||||
EncodedValue initialValue, AnnotationSetItem annotationSet,
|
EncodedValue initialValue, AnnotationSetItem annotationSet,
|
||||||
boolean setInStaticConstructor) throws IOException {
|
boolean setInStaticConstructor) throws IOException {
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class FieldDefinition {
|
|||||||
initialValue != NullEncodedValue.NullValue
|
initialValue != NullEncodedValue.NullValue
|
||||||
)) {
|
)) {
|
||||||
|
|
||||||
writer.println("#the value of this static final field might be set in the static constructor");
|
writer.write("#the value of this static final field might be set in the static constructor\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write(".field ");
|
writer.write(".field ");
|
||||||
@ -68,17 +68,18 @@ public class FieldDefinition {
|
|||||||
EncodedValueAdaptor.writeTo(writer, initialValue);
|
EncodedValueAdaptor.writeTo(writer, initialValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
|
|
||||||
if (annotationSet != null) {
|
if (annotationSet != null) {
|
||||||
writer.indent(4);
|
writer.indent(4);
|
||||||
AnnotationFormatter.writeTo(writer, annotationSet);
|
AnnotationFormatter.writeTo(writer, annotationSet);
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
writer.println(".end field");
|
writer.write(".end field\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeAccessFlags(IndentingPrintWriter writer, ClassDataItem.EncodedField encodedField) {
|
private static void writeAccessFlags(IndentingWriter writer, ClassDataItem.EncodedField encodedField)
|
||||||
|
throws IOException {
|
||||||
for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForField(encodedField.accessFlags)) {
|
for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForField(encodedField.accessFlags)) {
|
||||||
writer.write(accessFlag.toString());
|
writer.write(accessFlag.toString());
|
||||||
writer.write(' ');
|
writer.write(' ');
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors.Format;
|
package org.jf.baksmali.Adaptors.Format;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.Renderers.ByteRenderer;
|
import org.jf.baksmali.Renderers.ByteRenderer;
|
||||||
import org.jf.dexlib.Code.Format.ArrayDataPseudoInstruction;
|
import org.jf.dexlib.Code.Format.ArrayDataPseudoInstruction;
|
||||||
import org.jf.dexlib.CodeItem;
|
import org.jf.dexlib.CodeItem;
|
||||||
@ -45,11 +45,11 @@ public class ArrayDataMethodItem extends InstructionMethodItem<ArrayDataPseudoIn
|
|||||||
this.dead = dead;
|
this.dead = dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
if (dead) {
|
if (dead) {
|
||||||
writer.print("#.array-data 0x");
|
writer.write("#.array-data 0x");
|
||||||
writer.printLongAsHex(instruction.getElementWidth());
|
writer.printLongAsHex(instruction.getElementWidth());
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
|
|
||||||
Iterator<ArrayDataPseudoInstruction.ArrayElement> iterator = instruction.getElements();
|
Iterator<ArrayDataPseudoInstruction.ArrayElement> iterator = instruction.getElements();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@ -62,13 +62,13 @@ public class ArrayDataMethodItem extends InstructionMethodItem<ArrayDataPseudoIn
|
|||||||
}
|
}
|
||||||
ByteRenderer.writeUnsignedTo(writer, element.buffer[element.bufferIndex+i]);
|
ByteRenderer.writeUnsignedTo(writer, element.buffer[element.bufferIndex+i]);
|
||||||
}
|
}
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
writer.print("#.end array-data");
|
writer.write("#.end array-data");
|
||||||
} else {
|
} else {
|
||||||
writer.print(".array-data 0x");
|
writer.write(".array-data 0x");
|
||||||
writer.printLongAsHex(instruction.getElementWidth());
|
writer.printLongAsHex(instruction.getElementWidth());
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
|
|
||||||
writer.indent(4);
|
writer.indent(4);
|
||||||
Iterator<ArrayDataPseudoInstruction.ArrayElement> iterator = instruction.getElements();
|
Iterator<ArrayDataPseudoInstruction.ArrayElement> iterator = instruction.getElements();
|
||||||
@ -81,10 +81,10 @@ public class ArrayDataMethodItem extends InstructionMethodItem<ArrayDataPseudoIn
|
|||||||
}
|
}
|
||||||
ByteRenderer.writeUnsignedTo(writer, element.buffer[element.bufferIndex+i]);
|
ByteRenderer.writeUnsignedTo(writer, element.buffer[element.bufferIndex+i]);
|
||||||
}
|
}
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
writer.print(".end array-data");
|
writer.write(".end array-data");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ package org.jf.baksmali.Adaptors.Format;
|
|||||||
import org.jf.baksmali.Adaptors.MethodItem;
|
import org.jf.baksmali.Adaptors.MethodItem;
|
||||||
import org.jf.baksmali.Adaptors.ReferenceFormatter;
|
import org.jf.baksmali.Adaptors.ReferenceFormatter;
|
||||||
import org.jf.baksmali.Adaptors.RegisterFormatter;
|
import org.jf.baksmali.Adaptors.RegisterFormatter;
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.Renderers.LongRenderer;
|
import org.jf.baksmali.Renderers.LongRenderer;
|
||||||
import org.jf.dexlib.*;
|
import org.jf.dexlib.*;
|
||||||
import org.jf.dexlib.Code.*;
|
import org.jf.dexlib.Code.*;
|
||||||
@ -54,7 +54,7 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
switch (instruction.getFormat()) {
|
switch (instruction.getFormat()) {
|
||||||
case Format10t:
|
case Format10t:
|
||||||
writeOpcode(writer);
|
writeOpcode(writer);
|
||||||
@ -203,33 +203,33 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeOpcode(IndentingPrintWriter writer) throws IOException {
|
protected void writeOpcode(IndentingWriter writer) throws IOException {
|
||||||
writer.write(instruction.opcode.name);
|
writer.write(instruction.opcode.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeTargetLabel(IndentingPrintWriter writer) throws IOException {
|
protected void writeTargetLabel(IndentingWriter writer) throws IOException {
|
||||||
//this method is overrided by OffsetInstructionMethodItem, and should only be called for the formats that
|
//this method is overrided by OffsetInstructionMethodItem, and should only be called for the formats that
|
||||||
//have a target
|
//have a target
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeRegister(IndentingPrintWriter writer, int registerNumber) throws IOException {
|
protected void writeRegister(IndentingWriter writer, int registerNumber) throws IOException {
|
||||||
RegisterFormatter.writeTo(writer, codeItem, registerNumber);
|
RegisterFormatter.writeTo(writer, codeItem, registerNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeFirstRegister(IndentingPrintWriter writer) throws IOException {
|
protected void writeFirstRegister(IndentingWriter writer) throws IOException {
|
||||||
writeRegister(writer, ((SingleRegisterInstruction)instruction).getRegisterA());
|
writeRegister(writer, ((SingleRegisterInstruction)instruction).getRegisterA());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeSecondRegister(IndentingPrintWriter writer) throws IOException {
|
protected void writeSecondRegister(IndentingWriter writer) throws IOException {
|
||||||
writeRegister(writer, ((TwoRegisterInstruction)instruction).getRegisterB());
|
writeRegister(writer, ((TwoRegisterInstruction)instruction).getRegisterB());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeThirdRegister(IndentingPrintWriter writer) throws IOException {
|
protected void writeThirdRegister(IndentingWriter writer) throws IOException {
|
||||||
writeRegister(writer, ((ThreeRegisterInstruction)instruction).getRegisterC());
|
writeRegister(writer, ((ThreeRegisterInstruction)instruction).getRegisterC());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeInvokeRegisters(IndentingPrintWriter writer) throws IOException {
|
protected void writeInvokeRegisters(IndentingWriter writer) throws IOException {
|
||||||
FiveRegisterInstruction instruction = (FiveRegisterInstruction)this.instruction;
|
FiveRegisterInstruction instruction = (FiveRegisterInstruction)this.instruction;
|
||||||
final int regCount = instruction.getRegCount();
|
final int regCount = instruction.getRegCount();
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
|||||||
writer.write('}');
|
writer.write('}');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeInvokeRangeRegisters(IndentingPrintWriter writer) throws IOException {
|
protected void writeInvokeRangeRegisters(IndentingWriter writer) throws IOException {
|
||||||
RegisterRangeInstruction instruction = (RegisterRangeInstruction)this.instruction;
|
RegisterRangeInstruction instruction = (RegisterRangeInstruction)this.instruction;
|
||||||
|
|
||||||
int regCount = instruction.getRegCount();
|
int regCount = instruction.getRegCount();
|
||||||
@ -286,21 +286,21 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeLiteral(IndentingPrintWriter writer) throws IOException {
|
protected void writeLiteral(IndentingWriter writer) throws IOException {
|
||||||
LongRenderer.writeSignedIntOrLongTo(writer, ((LiteralInstruction)instruction).getLiteral());
|
LongRenderer.writeSignedIntOrLongTo(writer, ((LiteralInstruction)instruction).getLiteral());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeFieldOffset(IndentingPrintWriter writer) throws IOException {
|
protected void writeFieldOffset(IndentingWriter writer) throws IOException {
|
||||||
writer.write("field@0x");
|
writer.write("field@0x");
|
||||||
writer.printLongAsHex(((OdexedFieldAccess)instruction).getFieldOffset());
|
writer.printLongAsHex(((OdexedFieldAccess)instruction).getFieldOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeVtableIndex(IndentingPrintWriter writer) throws IOException {
|
protected void writeVtableIndex(IndentingWriter writer) throws IOException {
|
||||||
writer.write("vtable@0x");
|
writer.write("vtable@0x");
|
||||||
writer.printLongAsHex(((OdexedInvokeVirtual)instruction).getMethodIndex());
|
writer.printLongAsHex(((OdexedInvokeVirtual)instruction).getMethodIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeReference(IndentingPrintWriter writer) throws IOException {
|
protected void writeReference(IndentingWriter writer) throws IOException {
|
||||||
Item item = ((InstructionWithReference)instruction).getReferencedItem();
|
Item item = ((InstructionWithReference)instruction).getReferencedItem();
|
||||||
ReferenceFormatter.writeReference(writer, item);
|
ReferenceFormatter.writeReference(writer, item);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors.Format;
|
package org.jf.baksmali.Adaptors.Format;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.Code.Opcode;
|
import org.jf.dexlib.Code.Opcode;
|
||||||
import org.jf.dexlib.CodeItem;
|
import org.jf.dexlib.CodeItem;
|
||||||
import org.jf.dexlib.Code.Instruction;
|
import org.jf.dexlib.Code.Instruction;
|
||||||
@ -52,7 +52,7 @@ public class OffsetInstructionFormatMethodItem<T extends Instruction & OffsetIns
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeTargetLabel(IndentingPrintWriter writer) throws IOException {
|
protected void writeTargetLabel(IndentingWriter writer) throws IOException {
|
||||||
label.writeTo(writer);
|
label.writeTo(writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors.Format;
|
package org.jf.baksmali.Adaptors.Format;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.Renderers.IntegerRenderer;
|
import org.jf.baksmali.Renderers.IntegerRenderer;
|
||||||
import org.jf.dexlib.Code.Format.PackedSwitchDataPseudoInstruction;
|
import org.jf.dexlib.Code.Format.PackedSwitchDataPseudoInstruction;
|
||||||
import org.jf.dexlib.CodeItem;
|
import org.jf.dexlib.CodeItem;
|
||||||
@ -65,25 +65,25 @@ public class PackedSwitchMethodItem extends InstructionMethodItem<PackedSwitchDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
if (dead) {
|
if (dead) {
|
||||||
writer.write("'#.packed-switch ");
|
writer.write("'#.packed-switch ");
|
||||||
IntegerRenderer.writeTo(writer, instruction.getFirstKey());
|
IntegerRenderer.writeTo(writer, instruction.getFirstKey());
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
for (LabelMethodItem label: labels) {
|
for (LabelMethodItem label: labels) {
|
||||||
writer.write("# ");
|
writer.write("# ");
|
||||||
label.writeTo(writer);
|
label.writeTo(writer);
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
writer.write("#.end packed-switch");
|
writer.write("#.end packed-switch");
|
||||||
} else {
|
} else {
|
||||||
writer.write(".packed-switch ");
|
writer.write(".packed-switch ");
|
||||||
IntegerRenderer.writeTo(writer, instruction.getFirstKey());
|
IntegerRenderer.writeTo(writer, instruction.getFirstKey());
|
||||||
writer.indent(4);
|
writer.indent(4);
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
for (LabelMethodItem label: labels) {
|
for (LabelMethodItem label: labels) {
|
||||||
label.writeTo(writer);
|
label.writeTo(writer);
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
writer.write(".end packed-switch");
|
writer.write(".end packed-switch");
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
package org.jf.baksmali.Adaptors.Format;
|
package org.jf.baksmali.Adaptors.Format;
|
||||||
|
|
||||||
import org.jf.baksmali.Adaptors.MethodDefinition;
|
import org.jf.baksmali.Adaptors.MethodDefinition;
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.Renderers.IntegerRenderer;
|
import org.jf.baksmali.Renderers.IntegerRenderer;
|
||||||
import org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction;
|
import org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction;
|
||||||
import org.jf.dexlib.CodeItem;
|
import org.jf.dexlib.CodeItem;
|
||||||
@ -70,24 +70,24 @@ public class SparseSwitchMethodItem extends InstructionMethodItem<SparseSwitchDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
if (dead) {
|
if (dead) {
|
||||||
writer.println("#.sparse-switch");
|
writer.write("#.sparse-switch\n");
|
||||||
for (SparseSwitchTarget target: targets) {
|
for (SparseSwitchTarget target: targets) {
|
||||||
IntegerRenderer.writeTo(writer, target.Key);
|
IntegerRenderer.writeTo(writer, target.Key);
|
||||||
writer.write(" -> ");
|
writer.write(" -> ");
|
||||||
target.Target.writeTo(writer);
|
target.Target.writeTo(writer);
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
writer.write("#.end sparse-switch");
|
writer.write("#.end sparse-switch");
|
||||||
} else {
|
} else {
|
||||||
writer.println(".sparse-switch");
|
writer.write(".sparse-switch\n");
|
||||||
writer.indent(4);
|
writer.indent(4);
|
||||||
for (SparseSwitchTarget target: targets) {
|
for (SparseSwitchTarget target: targets) {
|
||||||
IntegerRenderer.writeTo(writer, target.Key);
|
IntegerRenderer.writeTo(writer, target.Key);
|
||||||
writer.write(" -> ");
|
writer.write(" -> ");
|
||||||
target.Target.writeTo(writer);
|
target.Target.writeTo(writer);
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
writer.write(".end sparse-switch");
|
writer.write(".end sparse-switch");
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors.Format;
|
package org.jf.baksmali.Adaptors.Format;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.Code.Format.UnresolvedNullReference;
|
import org.jf.dexlib.Code.Format.UnresolvedNullReference;
|
||||||
import org.jf.dexlib.CodeItem;
|
import org.jf.dexlib.CodeItem;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public class UnresolvedNullReferenceMethodItem extends InstructionMethodItem<Unr
|
|||||||
this.isLastInstruction = isLastInstruction;
|
this.isLastInstruction = isLastInstruction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
switch (instruction.OriginalInstruction.opcode)
|
switch (instruction.OriginalInstruction.opcode)
|
||||||
{
|
{
|
||||||
case INVOKE_VIRTUAL_QUICK_RANGE:
|
case INVOKE_VIRTUAL_QUICK_RANGE:
|
||||||
@ -56,22 +56,22 @@ public class UnresolvedNullReferenceMethodItem extends InstructionMethodItem<Unr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeInvokeRangeTo(IndentingPrintWriter writer) throws IOException {
|
private void writeInvokeRangeTo(IndentingWriter writer) throws IOException {
|
||||||
writer.println("#Replaced unresolvable optimized invoke-*-range-quick instruction");
|
writer.write("#Replaced unresolvable optimized invoke-*-range-quick instruction\n");
|
||||||
writer.println("#with a generic method call that will throw a NullPointerException");
|
writer.write("#with a generic method call that will throw a NullPointerException\n");
|
||||||
writer.write("invoke-virtual/range {");
|
writer.write("invoke-virtual/range {");
|
||||||
writeRegister(writer, instruction.ObjectRegisterNum);
|
writeRegister(writer, instruction.ObjectRegisterNum);
|
||||||
writer.write(" .. ");
|
writer.write(" .. ");
|
||||||
writeRegister(writer, instruction.ObjectRegisterNum);
|
writeRegister(writer, instruction.ObjectRegisterNum);
|
||||||
writer.write("}, Ljava/lang/Object;->hashCode()I");
|
writer.write("}, Ljava/lang/Object;->hashCode()I");
|
||||||
if (isLastInstruction) {
|
if (isLastInstruction) {
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
writer.write("goto/32 0");
|
writer.write("goto/32 0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeThrowTo(IndentingPrintWriter writer) throws IOException {
|
private void writeThrowTo(IndentingWriter writer) throws IOException {
|
||||||
writer.println("#Replaced unresolvable optimized instruction with a throw");
|
writer.write("#Replaced unresolvable optimized instruction with a throw\n");
|
||||||
writer.write("throw ");
|
writer.write("throw ");
|
||||||
writeRegister(writer, instruction.ObjectRegisterNum);
|
writeRegister(writer, instruction.ObjectRegisterNum);
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,11 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.baksmali;
|
import org.jf.baksmali.baksmali;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class LabelMethodItem extends MethodItem {
|
public class LabelMethodItem extends MethodItem {
|
||||||
private final String labelPrefix;
|
private final String labelPrefix;
|
||||||
private int labelSequence;
|
private int labelSequence;
|
||||||
@ -77,7 +79,7 @@ public class LabelMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean writeTo(IndentingPrintWriter writer) {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writer.write(':');
|
writer.write(':');
|
||||||
writer.write(labelPrefix);
|
writer.write(labelPrefix);
|
||||||
if (baksmali.useSequentialLabels) {
|
if (baksmali.useSequentialLabels) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.Adaptors.Format.*;
|
import org.jf.baksmali.Adaptors.Format.*;
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.Renderers.IntegerRenderer;
|
import org.jf.baksmali.Renderers.IntegerRenderer;
|
||||||
import org.jf.baksmali.baksmali;
|
import org.jf.baksmali.baksmali;
|
||||||
import org.jf.dexlib.*;
|
import org.jf.dexlib.*;
|
||||||
@ -45,7 +45,7 @@ import org.jf.dexlib.Util.SparseIntArray;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
git
|
|
||||||
public class MethodDefinition {
|
public class MethodDefinition {
|
||||||
private final ClassDataItem.EncodedMethod encodedMethod;
|
private final ClassDataItem.EncodedMethod encodedMethod;
|
||||||
private final MethodAnalyzer methodAnalyzer;
|
private final MethodAnalyzer methodAnalyzer;
|
||||||
@ -99,14 +99,15 @@ public class MethodDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(IndentingPrintWriter writer, AnnotationSetItem annotationSet,
|
public void writeTo(IndentingWriter writer, AnnotationSetItem annotationSet,
|
||||||
AnnotationSetRefList parameterAnnotations) throws IOException {
|
AnnotationSetRefList parameterAnnotations) throws IOException {
|
||||||
final CodeItem codeItem = encodedMethod.codeItem;
|
final CodeItem codeItem = encodedMethod.codeItem;
|
||||||
|
|
||||||
writer.write(".method ");
|
writer.write(".method ");
|
||||||
writeAccessFlags(writer, encodedMethod);
|
writeAccessFlags(writer, encodedMethod);
|
||||||
writer.write(encodedMethod.method.getMethodName().getStringValue());
|
writer.write(encodedMethod.method.getMethodName().getStringValue());
|
||||||
writer.println(encodedMethod.method.getPrototype().getPrototypeString());
|
writer.write(encodedMethod.method.getPrototype().getPrototypeString());
|
||||||
|
writer.write('\n');
|
||||||
|
|
||||||
writer.indent(4);
|
writer.indent(4);
|
||||||
if (codeItem != null) {
|
if (codeItem != null) {
|
||||||
@ -115,13 +116,14 @@ public class MethodDefinition {
|
|||||||
} else {
|
} else {
|
||||||
writer.write(".registers ");
|
writer.write(".registers ");
|
||||||
}
|
}
|
||||||
writer.println(getRegisterCount(encodedMethod));
|
writer.printIntAsDec(getRegisterCount(encodedMethod));
|
||||||
|
writer.write('\n');
|
||||||
writeParameters(writer, codeItem, parameterAnnotations);
|
writeParameters(writer, codeItem, parameterAnnotations);
|
||||||
if (annotationSet != null) {
|
if (annotationSet != null) {
|
||||||
AnnotationFormatter.writeTo(writer, annotationSet);
|
AnnotationFormatter.writeTo(writer, annotationSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
|
|
||||||
for (MethodItem methodItem: getMethodItems()) {
|
for (MethodItem methodItem: getMethodItems()) {
|
||||||
if (methodItem.writeTo(writer)) {
|
if (methodItem.writeTo(writer)) {
|
||||||
@ -134,7 +136,7 @@ public class MethodDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
writer.println(".end method");
|
writer.write(".end method\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getRegisterCount(ClassDataItem.EncodedMethod encodedMethod)
|
private static int getRegisterCount(ClassDataItem.EncodedMethod encodedMethod)
|
||||||
@ -150,14 +152,15 @@ public class MethodDefinition {
|
|||||||
return totalRegisters;
|
return totalRegisters;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeAccessFlags(IndentingPrintWriter writer, ClassDataItem.EncodedMethod encodedMethod) {
|
private static void writeAccessFlags(IndentingWriter writer, ClassDataItem.EncodedMethod encodedMethod)
|
||||||
|
throws IOException {
|
||||||
for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForMethod(encodedMethod.accessFlags)) {
|
for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForMethod(encodedMethod.accessFlags)) {
|
||||||
writer.write(accessFlag.toString());
|
writer.write(accessFlag.toString());
|
||||||
writer.write(' ');
|
writer.write(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeParameters(IndentingPrintWriter writer, CodeItem codeItem,
|
private static void writeParameters(IndentingWriter writer, CodeItem codeItem,
|
||||||
AnnotationSetRefList parameterAnnotations) throws IOException {
|
AnnotationSetRefList parameterAnnotations) throws IOException {
|
||||||
DebugInfoItem debugInfoItem = null;
|
DebugInfoItem debugInfoItem = null;
|
||||||
if (baksmali.outputDebugInfo && codeItem != null) {
|
if (baksmali.outputDebugInfo && codeItem != null) {
|
||||||
@ -205,13 +208,13 @@ public class MethodDefinition {
|
|||||||
writer.write('"');
|
writer.write('"');
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
if (annotationSet != null) {
|
if (annotationSet != null) {
|
||||||
writer.indent(4);
|
writer.indent(4);
|
||||||
AnnotationFormatter.writeTo(writer, annotationSet);
|
AnnotationFormatter.writeTo(writer, annotationSet);
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
|
|
||||||
writer.println(".end parameter");
|
writer.write(".end parameter\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,7 +365,7 @@ public class MethodDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writer.write("#@");
|
writer.write("#@");
|
||||||
IntegerRenderer.writeUnsignedTo(writer, codeAddress);
|
IntegerRenderer.writeUnsignedTo(writer, codeAddress);
|
||||||
return true;
|
return true;
|
||||||
@ -483,7 +486,7 @@ public class MethodDefinition {
|
|||||||
final StringIdItem name, final TypeIdItem type) {
|
final StringIdItem name, final TypeIdItem type) {
|
||||||
methodItems.add(new DebugMethodItem(codeAddress, -1) {
|
methodItems.add(new DebugMethodItem(codeAddress, -1) {
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeStartLocal(writer, codeItem, registerNum, name, type, null);
|
writeStartLocal(writer, codeItem, registerNum, name, type, null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -496,7 +499,7 @@ public class MethodDefinition {
|
|||||||
final TypeIdItem type, final StringIdItem signature) {
|
final TypeIdItem type, final StringIdItem signature) {
|
||||||
methodItems.add(new DebugMethodItem(codeAddress, -1) {
|
methodItems.add(new DebugMethodItem(codeAddress, -1) {
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeStartLocal(writer, codeItem, registerNum, name, type, signature);
|
writeStartLocal(writer, codeItem, registerNum, name, type, signature);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -509,7 +512,7 @@ public class MethodDefinition {
|
|||||||
final StringIdItem signature) {
|
final StringIdItem signature) {
|
||||||
methodItems.add(new DebugMethodItem(codeAddress, -1) {
|
methodItems.add(new DebugMethodItem(codeAddress, -1) {
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeEndLocal(writer, codeItem, registerNum, name, type, signature);
|
writeEndLocal(writer, codeItem, registerNum, name, type, signature);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -522,7 +525,7 @@ public class MethodDefinition {
|
|||||||
final StringIdItem signature) {
|
final StringIdItem signature) {
|
||||||
methodItems.add(new DebugMethodItem(codeAddress, -1) {
|
methodItems.add(new DebugMethodItem(codeAddress, -1) {
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeRestartLocal(writer, codeItem, registerNum, name, type, signature);
|
writeRestartLocal(writer, codeItem, registerNum, name, type, signature);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -533,7 +536,7 @@ public class MethodDefinition {
|
|||||||
public void ProcessSetPrologueEnd(int codeAddress) {
|
public void ProcessSetPrologueEnd(int codeAddress) {
|
||||||
methodItems.add(new DebugMethodItem(codeAddress, -4) {
|
methodItems.add(new DebugMethodItem(codeAddress, -4) {
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeEndPrologue(writer);
|
writeEndPrologue(writer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -544,7 +547,7 @@ public class MethodDefinition {
|
|||||||
public void ProcessSetEpilogueBegin(int codeAddress) {
|
public void ProcessSetEpilogueBegin(int codeAddress) {
|
||||||
methodItems.add(new DebugMethodItem(codeAddress, -4) {
|
methodItems.add(new DebugMethodItem(codeAddress, -4) {
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeBeginEpilogue(writer);
|
writeBeginEpilogue(writer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -555,7 +558,7 @@ public class MethodDefinition {
|
|||||||
public void ProcessSetFile(int codeAddress, int length, final StringIdItem name) {
|
public void ProcessSetFile(int codeAddress, int length, final StringIdItem name) {
|
||||||
methodItems.add(new DebugMethodItem(codeAddress, -3) {
|
methodItems.add(new DebugMethodItem(codeAddress, -3) {
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeSetFile(writer, name.getStringValue());
|
writeSetFile(writer, name.getStringValue());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -566,7 +569,7 @@ public class MethodDefinition {
|
|||||||
public void ProcessLineEmit(int codeAddress, final int line) {
|
public void ProcessLineEmit(int codeAddress, final int line) {
|
||||||
methodItems.add(new DebugMethodItem(codeAddress, -2) {
|
methodItems.add(new DebugMethodItem(codeAddress, -2) {
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
writeLine(writer, line);
|
writeLine(writer, line);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -55,5 +55,5 @@ public abstract class MethodItem implements Comparable<MethodItem> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean writeTo(IndentingPrintWriter writer) throws IOException;
|
public abstract boolean writeTo(IndentingWriter writer) throws IOException;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.baksmali;
|
import org.jf.baksmali.baksmali;
|
||||||
import org.jf.baksmali.main;
|
import org.jf.baksmali.main;
|
||||||
import org.jf.dexlib.ClassDataItem;
|
import org.jf.dexlib.ClassDataItem;
|
||||||
@ -56,7 +56,7 @@ public class PostInstructionRegisterInfoMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
int registerInfo = baksmali.registerInfo;
|
int registerInfo = baksmali.registerInfo;
|
||||||
int registerCount = analyzedInstruction.getRegisterCount();
|
int registerCount = analyzedInstruction.getRegisterCount();
|
||||||
BitSet registers = new BitSet(registerCount);
|
BitSet registers = new BitSet(registerCount);
|
||||||
@ -83,7 +83,7 @@ public class PostInstructionRegisterInfoMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean writeRegisterInfo(IndentingPrintWriter writer, BitSet registers) throws IOException {
|
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException {
|
||||||
ClassDataItem.EncodedMethod encodedMethod = methodAnalyzer.getMethod();
|
ClassDataItem.EncodedMethod encodedMethod = methodAnalyzer.getMethod();
|
||||||
|
|
||||||
int registerNum = registers.nextSetBit(0);
|
int registerNum = registers.nextSetBit(0);
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.baksmali.baksmali;
|
import org.jf.baksmali.baksmali;
|
||||||
import org.jf.baksmali.main;
|
import org.jf.baksmali.main;
|
||||||
import org.jf.dexlib.ClassDataItem;
|
import org.jf.dexlib.ClassDataItem;
|
||||||
@ -58,7 +58,7 @@ public class PreInstructionRegisterInfoMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTo(IndentingPrintWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
int registerInfo = baksmali.registerInfo;
|
int registerInfo = baksmali.registerInfo;
|
||||||
int registerCount = analyzedInstruction.getRegisterCount();
|
int registerCount = analyzedInstruction.getRegisterCount();
|
||||||
BitSet registers = new BitSet(registerCount);
|
BitSet registers = new BitSet(registerCount);
|
||||||
@ -165,7 +165,7 @@ public class PreInstructionRegisterInfoMethodItem extends MethodItem {
|
|||||||
registers.set(registerCount-parameterRegisterCount, registerCount);
|
registers.set(registerCount-parameterRegisterCount, registerCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean writeFullMergeRegs(IndentingPrintWriter writer, BitSet registers, int registerCount)
|
private boolean writeFullMergeRegs(IndentingWriter writer, BitSet registers, int registerCount)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (analyzedInstruction.getPredecessorCount() <= 1) {
|
if (analyzedInstruction.getPredecessorCount() <= 1) {
|
||||||
return false;
|
return false;
|
||||||
@ -196,7 +196,7 @@ public class PreInstructionRegisterInfoMethodItem extends MethodItem {
|
|||||||
if (firstRegister) {
|
if (firstRegister) {
|
||||||
firstRegister = false;
|
firstRegister = false;
|
||||||
} else {
|
} else {
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write('#');
|
writer.write('#');
|
||||||
@ -233,7 +233,7 @@ public class PreInstructionRegisterInfoMethodItem extends MethodItem {
|
|||||||
return !firstRegister;
|
return !firstRegister;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean writeRegisterInfo(IndentingPrintWriter writer, BitSet registers,
|
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers,
|
||||||
boolean addNewline) throws IOException {
|
boolean addNewline) throws IOException {
|
||||||
ClassDataItem.EncodedMethod encodedMethod = methodAnalyzer.getMethod();
|
ClassDataItem.EncodedMethod encodedMethod = methodAnalyzer.getMethod();
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ public class PreInstructionRegisterInfoMethodItem extends MethodItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (addNewline) {
|
if (addNewline) {
|
||||||
writer.println();
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
writer.write('#');
|
writer.write('#');
|
||||||
for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
|
for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
|
||||||
|
@ -28,14 +28,14 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.*;
|
import org.jf.dexlib.*;
|
||||||
import org.jf.dexlib.Util.Utf8Utils;
|
import org.jf.dexlib.Util.Utf8Utils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ReferenceFormatter {
|
public class ReferenceFormatter {
|
||||||
public static void writeReference(IndentingPrintWriter writer, Item item) throws IOException {
|
public static void writeReference(IndentingWriter writer, Item item) throws IOException {
|
||||||
switch (item.getItemType()) {
|
switch (item.getItemType()) {
|
||||||
case TYPE_METHOD_ID_ITEM:
|
case TYPE_METHOD_ID_ITEM:
|
||||||
writeMethodReference(writer, (MethodIdItem)item);
|
writeMethodReference(writer, (MethodIdItem)item);
|
||||||
@ -52,14 +52,14 @@ public class ReferenceFormatter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeMethodReference(IndentingPrintWriter writer, MethodIdItem item) {
|
public static void writeMethodReference(IndentingWriter writer, MethodIdItem item) throws IOException {
|
||||||
writer.write(item.getContainingClass().getTypeDescriptor());
|
writer.write(item.getContainingClass().getTypeDescriptor());
|
||||||
writer.write("->");
|
writer.write("->");
|
||||||
writer.write(item.getMethodName().getStringValue());
|
writer.write(item.getMethodName().getStringValue());
|
||||||
writer.write(item.getPrototype().getPrototypeString());
|
writer.write(item.getPrototype().getPrototypeString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeFieldReference(IndentingPrintWriter writer, FieldIdItem item) {
|
public static void writeFieldReference(IndentingWriter writer, FieldIdItem item) throws IOException {
|
||||||
writer.write(item.getContainingClass().getTypeDescriptor());
|
writer.write(item.getContainingClass().getTypeDescriptor());
|
||||||
writer.write("->");
|
writer.write("->");
|
||||||
writer.write(item.getFieldName().getStringValue());
|
writer.write(item.getFieldName().getStringValue());
|
||||||
@ -67,13 +67,13 @@ public class ReferenceFormatter {
|
|||||||
writer.write(item.getFieldType().getTypeDescriptor());
|
writer.write(item.getFieldType().getTypeDescriptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeStringReference(IndentingPrintWriter writer, StringIdItem item) throws IOException {
|
public static void writeStringReference(IndentingWriter writer, StringIdItem item) throws IOException {
|
||||||
writer.write('"');
|
writer.write('"');
|
||||||
Utf8Utils.writeEscapedString(writer, item.getStringValue());
|
Utf8Utils.writeEscapedString(writer, item.getStringValue());
|
||||||
writer.write('"');
|
writer.write('"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeTypeReference(IndentingPrintWriter writer, TypeIdItem item) {
|
public static void writeTypeReference(IndentingWriter writer, TypeIdItem item) throws IOException {
|
||||||
writer.write(item.getTypeDescriptor());
|
writer.write(item.getTypeDescriptor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,13 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors;
|
package org.jf.baksmali.Adaptors;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.CodeItem;
|
import org.jf.dexlib.CodeItem;
|
||||||
import org.jf.dexlib.Util.AccessFlags;
|
import org.jf.dexlib.Util.AccessFlags;
|
||||||
import org.jf.baksmali.baksmali;
|
import org.jf.baksmali.baksmali;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains the logic used for formatting registers
|
* This class contains the logic used for formatting registers
|
||||||
*/
|
*/
|
||||||
@ -43,13 +45,13 @@ public class RegisterFormatter {
|
|||||||
* output the registers in the v<n> format. But if false, then it will check if *both* registers are parameter
|
* output the registers in the v<n> format. But if false, then it will check if *both* registers are parameter
|
||||||
* registers, and if so, use the p<n> format for both. If only the last register is a parameter register, it will
|
* registers, and if so, use the p<n> format for both. If only the last register is a parameter register, it will
|
||||||
* use the v<n> format for both, otherwise it would be confusing to have something like {v20 .. p1}
|
* use the v<n> format for both, otherwise it would be confusing to have something like {v20 .. p1}
|
||||||
* @param writer the <code>IndentingPrintWriter</code> to write to
|
* @param writer the <code>IndentingWriter</code> to write to
|
||||||
* @param codeItem the <code>CodeItem</code> that the register is from
|
* @param codeItem the <code>CodeItem</code> that the register is from
|
||||||
* @param startRegister the first register in the range
|
* @param startRegister the first register in the range
|
||||||
* @param lastRegister the last register in the range
|
* @param lastRegister the last register in the range
|
||||||
*/
|
*/
|
||||||
public static void writeRegisterRange(IndentingPrintWriter writer, CodeItem codeItem, int startRegister,
|
public static void writeRegisterRange(IndentingWriter writer, CodeItem codeItem, int startRegister,
|
||||||
int lastRegister) {
|
int lastRegister) throws IOException {
|
||||||
assert lastRegister >= startRegister;
|
assert lastRegister >= startRegister;
|
||||||
|
|
||||||
if (!baksmali.noParameterRegisters) {
|
if (!baksmali.noParameterRegisters) {
|
||||||
@ -61,17 +63,17 @@ public class RegisterFormatter {
|
|||||||
|
|
||||||
if (startRegister >= registerCount - parameterRegisterCount) {
|
if (startRegister >= registerCount - parameterRegisterCount) {
|
||||||
writer.write("{p");
|
writer.write("{p");
|
||||||
writer.print(startRegister - (registerCount - parameterRegisterCount));
|
writer.printIntAsDec(startRegister - (registerCount - parameterRegisterCount));
|
||||||
writer.write(" .. p");
|
writer.write(" .. p");
|
||||||
writer.print(lastRegister - (registerCount - parameterRegisterCount));
|
writer.printIntAsDec(lastRegister - (registerCount - parameterRegisterCount));
|
||||||
writer.write('}');
|
writer.write('}');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.write("{v");
|
writer.write("{v");
|
||||||
writer.print(startRegister);
|
writer.printIntAsDec(startRegister);
|
||||||
writer.write(" .. v");
|
writer.write(" .. v");
|
||||||
writer.print(lastRegister);
|
writer.printIntAsDec(lastRegister);
|
||||||
writer.write('}');
|
writer.write('}');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,22 +82,22 @@ public class RegisterFormatter {
|
|||||||
* output a register in the v<n> format. If false, then it determines if the register is a parameter register,
|
* output a register in the v<n> format. If false, then it determines if the register is a parameter register,
|
||||||
* and if so, formats it in the p<n> format instead.
|
* and if so, formats it in the p<n> format instead.
|
||||||
*
|
*
|
||||||
* @param writer the <code>IndentingPrintWriter</code> to write to
|
* @param writer the <code>IndentingWriter</code> to write to
|
||||||
* @param codeItem the <code>CodeItem</code> that the register is from
|
* @param codeItem the <code>CodeItem</code> that the register is from
|
||||||
* @param register the register number
|
* @param register the register number
|
||||||
*/
|
*/
|
||||||
public static void writeTo(IndentingPrintWriter writer, CodeItem codeItem, int register) {
|
public static void writeTo(IndentingWriter writer, CodeItem codeItem, int register) throws IOException {
|
||||||
if (!baksmali.noParameterRegisters) {
|
if (!baksmali.noParameterRegisters) {
|
||||||
int parameterRegisterCount = codeItem.getParent().method.getPrototype().getParameterRegisterCount()
|
int parameterRegisterCount = codeItem.getParent().method.getPrototype().getParameterRegisterCount()
|
||||||
+ (((codeItem.getParent().accessFlags & AccessFlags.STATIC.getValue())==0)?1:0);
|
+ (((codeItem.getParent().accessFlags & AccessFlags.STATIC.getValue())==0)?1:0);
|
||||||
int registerCount = codeItem.getRegisterCount();
|
int registerCount = codeItem.getRegisterCount();
|
||||||
if (register >= registerCount - parameterRegisterCount) {
|
if (register >= registerCount - parameterRegisterCount) {
|
||||||
writer.write('p');
|
writer.write('p');
|
||||||
writer.print((register - (registerCount - parameterRegisterCount)));
|
writer.printIntAsDec((register - (registerCount - parameterRegisterCount)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.write('v');
|
writer.write('v');
|
||||||
writer.print(register);
|
writer.printIntAsDec(register);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* [The "BSD licence"]
|
|
||||||
* Copyright (c) 2010 Ben Gruver
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.baksmali;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
public class IndentingPrintWriter extends PrintWriter {
|
|
||||||
private IndentingWriter writer;
|
|
||||||
private final char[] buffer = new char[16];
|
|
||||||
|
|
||||||
public IndentingPrintWriter(IndentingWriter writer) {
|
|
||||||
super(writer);
|
|
||||||
this.writer = writer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IndentingPrintWriter(IndentingWriter writer, boolean autoFlush) {
|
|
||||||
super(writer, autoFlush);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void indent(int indentAmount) {
|
|
||||||
writer.indent(indentAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deindent(int indentAmount) {
|
|
||||||
writer.deindent(indentAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printLongAsHex(long l) {
|
|
||||||
//synchronized(lock) {
|
|
||||||
int i=0;
|
|
||||||
do {
|
|
||||||
int digit = (int)(l & 15);
|
|
||||||
if (digit < 10) {
|
|
||||||
buffer[i++] = (char)(digit + '0');
|
|
||||||
} else {
|
|
||||||
buffer[i++] = (char)((digit - 10) + 'a');
|
|
||||||
}
|
|
||||||
|
|
||||||
l >>>= 4;
|
|
||||||
} while (l != 0);
|
|
||||||
|
|
||||||
while (i>0) {
|
|
||||||
write(buffer[--i]);
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
@ -33,6 +33,7 @@ import java.io.Writer;
|
|||||||
|
|
||||||
public class IndentingWriter extends Writer {
|
public class IndentingWriter extends Writer {
|
||||||
private final Writer writer;
|
private final Writer writer;
|
||||||
|
private final char[] buffer = new char[16];
|
||||||
private int indentLevel = 0;
|
private int indentLevel = 0;
|
||||||
private boolean beginningOfLine;
|
private boolean beginningOfLine;
|
||||||
|
|
||||||
@ -145,4 +146,42 @@ public class IndentingWriter extends Writer {
|
|||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printLongAsHex(long value) throws IOException {
|
||||||
|
int bufferIndex = 0;
|
||||||
|
do {
|
||||||
|
int digit = (int)(value & 15);
|
||||||
|
if (digit < 10) {
|
||||||
|
buffer[bufferIndex++] = (char)(digit + '0');
|
||||||
|
} else {
|
||||||
|
buffer[bufferIndex++] = (char)((digit - 10) + 'a');
|
||||||
|
}
|
||||||
|
|
||||||
|
value >>>= 4;
|
||||||
|
} while (value != 0);
|
||||||
|
|
||||||
|
while (bufferIndex>0) {
|
||||||
|
write(buffer[--bufferIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printIntAsDec(int value) throws IOException {
|
||||||
|
int bufferIndex = 0;
|
||||||
|
boolean negative = value < 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
int digit = value % 10;
|
||||||
|
buffer[bufferIndex++] = (char)(digit + '0');
|
||||||
|
|
||||||
|
value = value / 10;
|
||||||
|
} while (value != 0);
|
||||||
|
|
||||||
|
if (negative) {
|
||||||
|
write('-');
|
||||||
|
}
|
||||||
|
|
||||||
|
while (bufferIndex>0) {
|
||||||
|
write(buffer[--bufferIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Renderers;
|
package org.jf.baksmali.Renderers;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class BooleanRenderer {
|
public class BooleanRenderer {
|
||||||
public static void writeTo(IndentingPrintWriter writer, boolean val) {
|
public static void writeTo(IndentingWriter writer, boolean val) throws IOException {
|
||||||
if (val) {
|
if (val) {
|
||||||
writer.write("true");
|
writer.write("true");
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Renderers;
|
package org.jf.baksmali.Renderers;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ByteRenderer {
|
public class ByteRenderer {
|
||||||
public static void writeTo(IndentingPrintWriter writer, byte val) {
|
public static void writeTo(IndentingWriter writer, byte val) throws IOException {
|
||||||
if (val<0) {
|
if (val<0) {
|
||||||
writer.write("-0x");
|
writer.write("-0x");
|
||||||
writer.printLongAsHex(-val);
|
writer.printLongAsHex(-val);
|
||||||
@ -43,7 +45,7 @@ public class ByteRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeUnsignedTo(IndentingPrintWriter writer, byte val) {
|
public static void writeUnsignedTo(IndentingWriter writer, byte val) throws IOException {
|
||||||
writer.write("0x");
|
writer.write("0x");
|
||||||
writer.printLongAsHex(val & 0xFF);
|
writer.printLongAsHex(val & 0xFF);
|
||||||
writer.write('t');
|
writer.write('t');
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Renderers;
|
package org.jf.baksmali.Renderers;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
import org.jf.dexlib.Util.Utf8Utils;
|
import org.jf.dexlib.Util.Utf8Utils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CharRenderer {
|
public class CharRenderer {
|
||||||
public static void writeTo(IndentingPrintWriter writer, char val) throws IOException {
|
public static void writeTo(IndentingWriter writer, char val) throws IOException {
|
||||||
writer.write('\'');
|
writer.write('\'');
|
||||||
Utf8Utils.writeEscapedChar(writer, val);
|
Utf8Utils.writeEscapedChar(writer, val);
|
||||||
writer.write('\'');
|
writer.write('\'');
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Renderers;
|
package org.jf.baksmali.Renderers;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class DoubleRenderer {
|
public class DoubleRenderer {
|
||||||
public static void writeTo(IndentingPrintWriter writer, double val) {
|
public static void writeTo(IndentingWriter writer, double val) throws IOException {
|
||||||
writer.print(val);
|
writer.write(Double.toString(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,13 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Renderers;
|
package org.jf.baksmali.Renderers;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class FloatRenderer {
|
public class FloatRenderer {
|
||||||
public static void writeTo(IndentingPrintWriter writer, float val) {
|
public static void writeTo(IndentingWriter writer, float val) throws IOException {
|
||||||
writer.print(val);
|
writer.write(Float.toString(val));
|
||||||
writer.write('f');
|
writer.write('f');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Renderers;
|
package org.jf.baksmali.Renderers;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class IntegerRenderer {
|
public class IntegerRenderer {
|
||||||
public static void writeTo(IndentingPrintWriter writer, int val) {
|
public static void writeTo(IndentingWriter writer, int val) throws IOException {
|
||||||
if (val<0) {
|
if (val<0) {
|
||||||
writer.write("-0x");
|
writer.write("-0x");
|
||||||
writer.printLongAsHex(-((long)val));
|
writer.printLongAsHex(-((long)val));
|
||||||
@ -41,7 +43,7 @@ public class IntegerRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeUnsignedTo(IndentingPrintWriter writer, int val) {
|
public static void writeUnsignedTo(IndentingWriter writer, int val) throws IOException {
|
||||||
writer.write("0x");
|
writer.write("0x");
|
||||||
writer.printLongAsHex(val & 0xFFFFFFFF);
|
writer.printLongAsHex(val & 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Renderers;
|
package org.jf.baksmali.Renderers;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class LongRenderer {
|
public class LongRenderer {
|
||||||
public static void writeTo(IndentingPrintWriter writer, long val) {
|
public static void writeTo(IndentingWriter writer, long val) throws IOException {
|
||||||
if (val<0) {
|
if (val<0) {
|
||||||
writer.write("-0x");
|
writer.write("-0x");
|
||||||
writer.printLongAsHex(-val);
|
writer.printLongAsHex(-val);
|
||||||
@ -43,7 +45,7 @@ public class LongRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeSignedIntOrLongTo(IndentingPrintWriter writer, long val) {
|
public static void writeSignedIntOrLongTo(IndentingWriter writer, long val) throws IOException {
|
||||||
if (val<0) {
|
if (val<0) {
|
||||||
writer.write("-0x");
|
writer.write("-0x");
|
||||||
writer.printLongAsHex(-val);
|
writer.printLongAsHex(-val);
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Renderers;
|
package org.jf.baksmali.Renderers;
|
||||||
|
|
||||||
import org.jf.baksmali.IndentingPrintWriter;
|
import org.jf.baksmali.IndentingWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ShortRenderer {
|
public class ShortRenderer {
|
||||||
public static void writeTo(IndentingPrintWriter writer, short val) {
|
public static void writeTo(IndentingWriter writer, short val) throws IOException {
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
writer.write("-0x");
|
writer.write("-0x");
|
||||||
writer.printLongAsHex(-val);
|
writer.printLongAsHex(-val);
|
||||||
|
@ -29,11 +29,9 @@
|
|||||||
package org.jf.baksmali;
|
package org.jf.baksmali;
|
||||||
|
|
||||||
import org.jf.baksmali.Adaptors.ClassDefinition;
|
import org.jf.baksmali.Adaptors.ClassDefinition;
|
||||||
import org.jf.baksmali.Renderers.*;
|
|
||||||
import org.jf.dexlib.Code.Analysis.ClassPath;
|
import org.jf.dexlib.Code.Analysis.ClassPath;
|
||||||
import org.jf.dexlib.DexFile;
|
import org.jf.dexlib.DexFile;
|
||||||
import org.jf.dexlib.ClassDefItem;
|
import org.jf.dexlib.ClassDefItem;
|
||||||
import org.jf.dexlib.StringIdItem;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -163,8 +161,8 @@ public class baksmali {
|
|||||||
|
|
||||||
BufferedWriter bufWriter = new BufferedWriter(new FileWriter(smaliFile));
|
BufferedWriter bufWriter = new BufferedWriter(new FileWriter(smaliFile));
|
||||||
|
|
||||||
writer = new IndentingPrintWriter(new IndentingWriter(bufWriter));
|
writer = new IndentingWriter(bufWriter);
|
||||||
classDefinition.writeTo((IndentingPrintWriter)writer);
|
classDefinition.writeTo((IndentingWriter)writer);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.err.println("\n\nError occured while disassembling class " + classDescriptor.replace('/', '.') + " - skipping class");
|
System.err.println("\n\nError occured while disassembling class " + classDescriptor.replace('/', '.') + " - skipping class");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user