From 04b5c9abb177ced644caa520c252f783327a0cbf Mon Sep 17 00:00:00 2001 From: Stiver Date: Wed, 13 Aug 2014 22:08:06 +0200 Subject: [PATCH] Fixed 'IDEA-128595: Variable name set to "this"' --- .../decompiler/vars/VarVersionsProcessor.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/de/fernflower/modules/decompiler/vars/VarVersionsProcessor.java b/src/de/fernflower/modules/decompiler/vars/VarVersionsProcessor.java index c30e75a..a301a5b 100644 --- a/src/de/fernflower/modules/decompiler/vars/VarVersionsProcessor.java +++ b/src/de/fernflower/modules/decompiler/vars/VarVersionsProcessor.java @@ -60,7 +60,7 @@ public class VarVersionsProcessor { typeproc = new VarTypeProcessor(); typeproc.calculateVarTypes(root, dgraph); - simpleMerge(typeproc, dgraph); + simpleMerge(typeproc, dgraph, mt); // FIXME: advanced merging @@ -146,6 +146,8 @@ public class VarVersionsProcessor { type = type.type == CodeConstants.TYPE_BYTECHAR?VarType.VARTYPE_BYTE:VarType.VARTYPE_SHORT; } mapExprentMinTypes.put(paar, type); + //} else if(type.type == CodeConstants.TYPE_CHAR && (maxtype == null || maxtype.type == CodeConstants.TYPE_INT)) { // when possible, lift char to int + // mapExprentMinTypes.put(paar, VarType.VARTYPE_INT); } else if(type.type == CodeConstants.TYPE_NULL) { mapExprentMinTypes.put(paar, VarType.VARTYPE_OBJECT); } @@ -153,7 +155,7 @@ public class VarVersionsProcessor { } - private void simpleMerge(VarTypeProcessor typeproc, DirectGraph dgraph) { + private void simpleMerge(VarTypeProcessor typeproc, DirectGraph dgraph, StructMethod mt) { HashMap mapExprentMaxTypes = typeproc.getMapExprentMaxTypes(); HashMap mapExprentMinTypes = typeproc.getMapExprentMinTypes(); @@ -171,6 +173,8 @@ public class VarVersionsProcessor { } } + boolean is_method_static = (mt.getAccessFlags() & CodeConstants.ACC_STATIC) != 0; + final HashMap mapMergedVersions = new HashMap(); for(Entry> ent: mapVarVersions.entrySet()) { @@ -183,6 +187,10 @@ public class VarVersionsProcessor { VarVersionPaar firstpaar = new VarVersionPaar(ent.getKey(), lstVersions.get(i)); VarType firsttype = mapExprentMinTypes.get(firstpaar); + if(firstpaar.var == 0 && firstpaar.version == 1 && !is_method_static) { + continue; // don't merge 'this' variable + } + for(int j=i+1;j