diff --git a/jode/jode/Decompiler.java b/jode/jode/Decompiler.java index da5f2d1..18a4715 100644 --- a/jode/jode/Decompiler.java +++ b/jode/jode/Decompiler.java @@ -28,14 +28,15 @@ public class Decompiler { public static boolean debugAnalyze = false; public static boolean showLVT = false; public static boolean doChecks = false; + public static boolean prettyLocals = false; public static boolean immediateOutput = false; public static int importPackageLimit = 3; public static int importClassLimit = 3; public static void usage() { - System.err.println("use: jode [-v][-imm][-debug][-analyze][-flow]" - +"[-type][-inout][-lvt][-check]" - +"[-import pkglimit clslimit]" + System.err.println("use: jode [-v][--imm][--debug][--analyze][--flow]" + +"[--type][--inout][--lvt][--check]" + +"[--import pkglimit clslimit]" +" class1 [class2 ...]"); } @@ -45,23 +46,25 @@ public class Decompiler { for (i=0; i0) + result.append(", "); + result.append(locals[i].getName()); + } + return result.append("]").toString(); + } } diff --git a/jode/jode/type/ArrayType.java b/jode/jode/type/ArrayType.java index 785413b..b4be2bd 100644 --- a/jode/jode/type/ArrayType.java +++ b/jode/jode/type/ArrayType.java @@ -116,6 +116,10 @@ public class ArrayType extends Type { return elementType.toString()+"[]"; } + public String getDefaultName() { + return "arr_"+elementType.getDefaultName(); + } + public boolean equals(Object o) { if (o == this) return true; diff --git a/jode/jode/type/ClassInterfacesType.java b/jode/jode/type/ClassInterfacesType.java index cb5c192..1513b67 100644 --- a/jode/jode/type/ClassInterfacesType.java +++ b/jode/jode/type/ClassInterfacesType.java @@ -427,6 +427,24 @@ public class ClassInterfacesType extends Type { return true; } + public String getDefaultName() { + Class type; + if (clazz != null) + type = clazz; + else if (ifaces.length > 0) + type = ifaces[0]; + else + type = cObject; + String name = type.getName(); + int dot = name.lastIndexOf('.'); + if (dot >= 0) + name = name.substring(dot+1); + if (Character.isUpperCase(name.charAt(0))) + return name.toLowerCase(); + else + return name+"_var"; + } + public boolean equals(Object o) { if (o == this) return true; diff --git a/jode/jode/type/RangeType.java b/jode/jode/type/RangeType.java index 82d9975..0c3f962 100644 --- a/jode/jode/type/RangeType.java +++ b/jode/jode/type/RangeType.java @@ -98,6 +98,13 @@ public class RangeType extends Type { return bottomType.toString(); } + public String getDefaultName() { + if (topType.isClassType() || bottomType == tUnknown) + return topType.getDefaultName(); + else + return bottomType.getDefaultName(); + } + public boolean equals(Object o) { if (o instanceof RangeType) { RangeType type = (RangeType) o; diff --git a/jode/jode/type/Type.java b/jode/jode/type/Type.java index eb49364..11c0d39 100644 --- a/jode/jode/type/Type.java +++ b/jode/jode/type/Type.java @@ -463,6 +463,31 @@ public class Type { /* No action needed for simple types */ } + public String getDefaultName() { + switch (typecode) { + case TC_BOOLINT: + case TC_BOOLBYTE: + case TC_BOOLEAN: + return "bool"; + case TC_BYTE: + return "i"; + case TC_CHAR: + return "c"; + case TC_SHORT: + return "i"; + case TC_INT: + return "i"; + case TC_LONG: + return "l"; + case TC_FLOAT: + return "f"; + case TC_DOUBLE: + return "d"; + default: + return "local"; + } + } + public String toString() { switch (typecode) { case TC_BOOLINT: diff --git a/jode/jode/type/UnfoundClassType.java b/jode/jode/type/UnfoundClassType.java index 66eeed5..b463fdb 100644 --- a/jode/jode/type/UnfoundClassType.java +++ b/jode/jode/type/UnfoundClassType.java @@ -106,6 +106,17 @@ public class UnfoundClassType extends Type { return true; } + public String getDefaultName() { + String name = clazzName; + int dot = name.lastIndexOf('.'); + if (dot >= 0) + name = name.substring(dot+1); + if (Character.isUpperCase(name.charAt(0))) + return name.toLowerCase(); + else + return name+"_var"; + } + public boolean equals(Object o) { return o == this || (o instanceof UnfoundClassType