From 89b40fd28a40f9d55c808932352154603f809a75 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 5 Nov 2014 12:41:52 +0100 Subject: [PATCH] java-decompiler: (var, version) class renamed and made immutable --- .../java/decompiler/main/ClassWriter.java | 12 +-- .../decompiler/main/ClassesProcessor.java | 4 +- .../java/decompiler/main/EnumProcessor.java | 4 +- .../decompiler/main/InitializerProcessor.java | 6 +- .../decompiler/main/rels/ClassWrapper.java | 6 +- .../decompiler/main/rels/MethodWrapper.java | 4 +- .../main/rels/NestedClassProcessor.java | 52 ++++++------ .../main/rels/NestedMemberAccess.java | 6 +- .../modules/decompiler/FinallyProcessor.java | 8 +- .../decompiler/SecondaryFunctionsHelper.java | 4 +- .../decompiler/SimplifyExprentsHelper.java | 24 +++--- .../decompiler/StackVarsProcessor.java | 82 +++++++++---------- .../modules/decompiler/exps/Exprent.java | 8 +- .../modules/decompiler/exps/FieldExprent.java | 4 +- .../decompiler/exps/InvocationExprent.java | 10 +-- .../modules/decompiler/exps/NewExprent.java | 16 ++-- .../modules/decompiler/exps/VarExprent.java | 8 +- .../sforms/SSAConstructorSparseEx.java | 18 ++-- .../sforms/SSAUConstructorSparseEx.java | 72 ++++++++-------- .../decompiler/vars/VarDefinitionHelper.java | 12 +-- .../modules/decompiler/vars/VarProcessor.java | 36 ++++---- .../decompiler/vars/VarTypeProcessor.java | 36 ++++---- .../decompiler/vars/VarVersionNode.java | 4 +- ...arVersionPaar.java => VarVersionPair.java} | 16 ++-- .../decompiler/vars/VarVersionsGraph.java | 6 +- .../decompiler/vars/VarVersionsProcessor.java | 72 ++++++++-------- 26 files changed, 265 insertions(+), 265 deletions(-) rename src/org/jetbrains/java/decompiler/modules/decompiler/vars/{VarVersionPaar.java => VarVersionPair.java} (80%) diff --git a/src/org/jetbrains/java/decompiler/main/ClassWriter.java b/src/org/jetbrains/java/decompiler/main/ClassWriter.java index 1129172..9847814 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassWriter.java +++ b/src/org/jetbrains/java/decompiler/main/ClassWriter.java @@ -29,7 +29,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.NewExprent; import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarTypeProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.modules.renamer.PoolInterceptor; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructField; @@ -130,7 +130,7 @@ public class ClassWriter { buffer.append(", "); } - String parameterName = methodWrapper.varproc.getVarName(new VarVersionPaar(index, 0)); + String parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0)); buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors firstParameter = false; @@ -506,7 +506,7 @@ public class ClassWriter { buffer.append(typeName); buffer.append(" "); - String parameterName = methodWrapper.varproc.getVarName(new VarVersionPaar(index, 0)); + String parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0)); buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors firstParameter = false; @@ -671,7 +671,7 @@ public class ClassWriter { buffer.append('('); // parameters - List signFields = methodWrapper.signatureFields; + List signFields = methodWrapper.signatureFields; int lastVisibleParameterIndex = -1; for (int i = 0; i < md.params.length; i++) { @@ -692,7 +692,7 @@ public class ClassWriter { appendParameterAnnotations(buffer, mt, paramCount); - if (methodWrapper.varproc.getVarFinal(new VarVersionPaar(index, 0)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) { + if (methodWrapper.varproc.getVarFinal(new VarVersionPair(index, 0)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) { buffer.append("final "); } @@ -738,7 +738,7 @@ public class ClassWriter { } buffer.append(' '); - String parameterName = methodWrapper.varproc.getVarName(new VarVersionPaar(index, 0)); + String parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0)); buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors firstParameter = false; diff --git a/src/org/jetbrains/java/decompiler/main/ClassesProcessor.java b/src/org/jetbrains/java/decompiler/main/ClassesProcessor.java index 857c41c..2f20ece 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassesProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/ClassesProcessor.java @@ -27,7 +27,7 @@ import org.jetbrains.java.decompiler.main.rels.LambdaProcessor; import org.jetbrains.java.decompiler.main.rels.NestedClassProcessor; import org.jetbrains.java.decompiler.main.rels.NestedMemberAccess; import org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructContext; import org.jetbrains.java.decompiler.struct.StructMethod; @@ -357,7 +357,7 @@ public class ClassesProcessor { public ClassWrapper wrapper; public String enclosingMethod; public InvocationExprent superInvocation; - public Map mapFieldsToVars = new HashMap(); + public Map mapFieldsToVars = new HashMap(); public VarType anonymousClassType; public List nested = new ArrayList(); public Set enclosingClasses = new HashSet(); diff --git a/src/org/jetbrains/java/decompiler/main/EnumProcessor.java b/src/org/jetbrains/java/decompiler/main/EnumProcessor.java index e4c45eb..d3a0db1 100644 --- a/src/org/jetbrains/java/decompiler/main/EnumProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/EnumProcessor.java @@ -21,7 +21,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.struct.StructMethod; @@ -101,7 +101,7 @@ public class EnumProcessor { if (inv.getFunctype() == InvocationExprent.TYP_INIT) { if (inv.getInstance().type == Exprent.EXPRENT_VAR) { VarExprent instvar = (VarExprent)inv.getInstance(); - VarVersionPaar varpaar = new VarVersionPaar(instvar); + VarVersionPair varpaar = new VarVersionPair(instvar); String classname = meth.varproc.getThisVars().get(varpaar); diff --git a/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java b/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java index 0135239..d85e754 100644 --- a/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java @@ -23,7 +23,7 @@ import org.jetbrains.java.decompiler.main.rels.MethodWrapper; import org.jetbrains.java.decompiler.modules.decompiler.exps.*; import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.util.InterpreterUtil; @@ -260,7 +260,7 @@ public class InitializerProcessor { for (Exprent expr : lst) { switch (expr.type) { case Exprent.EXPRENT_VAR: - VarVersionPaar varpaar = new VarVersionPaar((VarExprent)expr); + VarVersionPair varpaar = new VarVersionPair((VarExprent)expr); if (!meth.varproc.getExternalVars().contains(varpaar)) { String varname = meth.varproc.getVarName(varpaar); @@ -306,7 +306,7 @@ public class InitializerProcessor { if (inv.getFunctype() == InvocationExprent.TYP_INIT) { if (inv.getInstance().type == Exprent.EXPRENT_VAR) { VarExprent instvar = (VarExprent)inv.getInstance(); - VarVersionPaar varpaar = new VarVersionPaar(instvar); + VarVersionPair varpaar = new VarVersionPair(instvar); String classname = meth.varproc.getThisVars().get(varpaar); diff --git a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java index b26e031..4717549 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java +++ b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java @@ -24,7 +24,7 @@ import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.struct.StructMethod; @@ -124,14 +124,14 @@ public class ClassWrapper { int paramcount = 0; if (thisvar) { - varproc.getThisVars().put(new VarVersionPaar(0, 0), classStruct.qualifiedName); + varproc.getThisVars().put(new VarVersionPair(0, 0), classStruct.qualifiedName); paramcount = 1; } paramcount += md.params.length; int varindex = 0; for (int i = 0; i < paramcount; i++) { - varproc.setVarName(new VarVersionPaar(varindex, 0), vc.getFreeName(varindex)); + varproc.setVarName(new VarVersionPair(varindex, 0), vc.getFreeName(varindex)); if (thisvar) { if (i == 0) { diff --git a/src/org/jetbrains/java/decompiler/main/rels/MethodWrapper.java b/src/org/jetbrains/java/decompiler/main/rels/MethodWrapper.java index d36b8bc..9d99a81 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/MethodWrapper.java +++ b/src/org/jetbrains/java/decompiler/main/rels/MethodWrapper.java @@ -20,7 +20,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.sforms.DirectGraph; import org.jetbrains.java.decompiler.modules.decompiler.sforms.FlattenStatementsHelper; import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructMethod; import java.util.HashSet; @@ -39,7 +39,7 @@ public class MethodWrapper { public DirectGraph graph; - public List signatureFields; + public List signatureFields; public boolean decompiledWithErrors; diff --git a/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java b/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java index f1cce77..1525226 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java @@ -29,7 +29,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.stats.DoStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarTypeProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.struct.StructMethod; @@ -127,14 +127,14 @@ public class NestedClassProcessor { // this pointer if (!is_static_lambda_content && DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS)) { - meth.varproc.getThisVars().put(new VarVersionPaar(0, 0), parent_class_name); - meth.varproc.setVarName(new VarVersionPaar(0, 0), parent.simpleName + ".this"); + meth.varproc.getThisVars().put(new VarVersionPair(0, 0), parent_class_name); + meth.varproc.setVarName(new VarVersionPair(0, 0), parent.simpleName + ".this"); } // local variables DirectGraph graph = encmeth.getOrBuildGraph(); - final HashMap mapNewNames = new HashMap(); + final HashMap mapNewNames = new HashMap(); graph.iterateExprents(new DirectGraph.ExprentIterator() { public int processExprent(Exprent exprent) { @@ -158,11 +158,11 @@ public class NestedClassProcessor { Exprent param = inv_dynamic.getLstParameters().get(param_index + i); if (param.type == Exprent.EXPRENT_VAR) { - VarVersionPaar enc_varpaar = new VarVersionPaar((VarExprent)param); + VarVersionPair enc_varpaar = new VarVersionPair((VarExprent)param); String enc_varname = encmeth.varproc.getVarName(enc_varpaar); - //meth.varproc.setVarName(new VarVersionPaar(varindex, 0), enc_varname); - mapNewNames.put(new VarVersionPaar(varindex, 0), enc_varname); + //meth.varproc.setVarName(new VarVersionPair(varindex, 0), enc_varname); + mapNewNames.put(new VarVersionPair(varindex, 0), enc_varname); } varindex += md_content.params[i].stackSize; @@ -182,7 +182,7 @@ public class NestedClassProcessor { meth.varproc.refreshVarNames(new VarNamesCollector(setNewOuterNames)); meth.setOuterVarNames.addAll(setNewOuterNames); - for (Entry entr : mapNewNames.entrySet()) { + for (Entry entr : mapNewNames.entrySet()) { meth.varproc.setVarName(entr.getKey(), entr.getValue()); } } @@ -327,7 +327,7 @@ public class NestedClassProcessor { VarFieldPair pair = null; if (param.type == Exprent.EXPRENT_VAR && mask.get(i) != null) { - VarVersionPaar varpaar = new VarVersionPaar((VarExprent)param); + VarVersionPair varpaar = new VarVersionPair((VarExprent)param); // FIXME: final flags of variables are wrong! Correct the entire final functionality. // if(meth.varproc.getVarFinal(varpaar) != VarTypeProcessor.VAR_NON_FINAL) { @@ -424,7 +424,7 @@ public class NestedClassProcessor { mergeListSignatures(entmt.getValue(), intrPairMask, false); MethodWrapper meth = nestedNode.wrapper.getMethodWrapper("", entmt.getKey()); - meth.signatureFields = new ArrayList(); + meth.signatureFields = new ArrayList(); for (VarFieldPair pair : entmt.getValue()) { meth.signatureFields.add(pair == null ? null : pair.varpaar); @@ -444,19 +444,19 @@ public class NestedClassProcessor { if (meth.root != null) { // neither abstract nor native // local var names - HashMap mapNewNames = new HashMap(); + HashMap mapNewNames = new HashMap(); // local var types - HashMap mapNewTypes = new HashMap(); + HashMap mapNewTypes = new HashMap(); - final HashMap mapParamsToNewVars = new HashMap(); + final HashMap mapParamsToNewVars = new HashMap(); if (meth.signatureFields != null) { int index = 0; int varindex = 1; MethodDescriptor md = MethodDescriptor.parseDescriptor(meth.methodStruct.getDescriptor()); - for (VarVersionPaar paar : meth.signatureFields) { + for (VarVersionPair paar : meth.signatureFields) { if (paar != null) { - VarVersionPaar newvar = new VarVersionPaar(meth.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER), 0); + VarVersionPair newvar = new VarVersionPair(meth.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER), 0); mapParamsToNewVars.put(varindex, newvar); @@ -489,12 +489,12 @@ public class NestedClassProcessor { } // new vars - final HashMap mapFieldsToNewVars = new HashMap(); + final HashMap mapFieldsToNewVars = new HashMap(); for (ClassNode clnode = child; clnode != null; clnode = clnode.parent) { - for (Entry entr : clnode.mapFieldsToVars.entrySet()) { - VarVersionPaar newvar = new VarVersionPaar(meth.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER), 0); + for (Entry entr : clnode.mapFieldsToVars.entrySet()) { + VarVersionPair newvar = new VarVersionPair(meth.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER), 0); mapFieldsToNewVars.put(InterpreterUtil.makeUniqueKey(clnode.classStruct.qualifiedName, entr.getKey()), newvar); @@ -539,8 +539,8 @@ public class NestedClassProcessor { meth.varproc.refreshVarNames(new VarNamesCollector(setNewOuterNames)); meth.setOuterVarNames.addAll(setNewOuterNames); - for (Entry entr : mapNewNames.entrySet()) { - VarVersionPaar varpaar = entr.getKey(); + for (Entry entr : mapNewNames.entrySet()) { + VarVersionPair varpaar = entr.getKey(); VarType vartype = mapNewTypes.get(varpaar); meth.varproc.setVarName(varpaar, entr.getValue()); @@ -593,7 +593,7 @@ public class NestedClassProcessor { if (exprent.type == Exprent.EXPRENT_VAR) { int varindex = ((VarExprent)exprent).getIndex(); if (mapParamsToNewVars.containsKey(varindex)) { - VarVersionPaar newvar = mapParamsToNewVars.get(varindex); + VarVersionPair newvar = mapParamsToNewVars.get(varindex); meth.varproc.getExternalVars().add(newvar); return new VarExprent(newvar.var, meth.varproc.getVarType(newvar), meth.varproc); } @@ -607,7 +607,7 @@ public class NestedClassProcessor { if (mapFieldsToNewVars.containsKey(keyField)) { //if(fexpr.getClassname().equals(child.classStruct.qualifiedName) && // mapFieldsToNewVars.containsKey(keyField)) { - VarVersionPaar newvar = mapFieldsToNewVars.get(keyField); + VarVersionPair newvar = mapFieldsToNewVars.get(keyField); meth.varproc.getExternalVars().add(newvar); return new VarExprent(newvar.var, meth.varproc.getVarType(newvar), meth.varproc); } @@ -655,7 +655,7 @@ public class NestedClassProcessor { int varindex = 1; for (int i = 0; i < md.params.length; i++) { // no static methods allowed String keyField = getEnclosingVarField(cl, meth, graph, varindex); - fields.add(keyField == null ? null : new VarFieldPair(keyField, new VarVersionPaar(-1, 0))); // TODO: null? + fields.add(keyField == null ? null : new VarFieldPair(keyField, new VarVersionPair(-1, 0))); // TODO: null? varindex += md.params[i].stackSize; } mapMasks.put(mt.getDescriptor(), fields); @@ -671,7 +671,7 @@ public class NestedClassProcessor { String field = ""; // parameter variable final - if (meth.varproc.getVarFinal(new VarVersionPaar(index, 0)) == VarTypeProcessor.VAR_NON_FINAL) { + if (meth.varproc.getVarFinal(new VarVersionPair(index, 0)) == VarTypeProcessor.VAR_NON_FINAL) { return null; } @@ -1005,9 +1005,9 @@ public class NestedClassProcessor { private static class VarFieldPair { public String keyfield = ""; - public VarVersionPaar varpaar; + public VarVersionPair varpaar; - public VarFieldPair(String field, VarVersionPaar varpaar) { + public VarFieldPair(String field, VarVersionPair varpaar) { this.keyfield = field; this.varpaar = varpaar; } diff --git a/src/org/jetbrains/java/decompiler/main/rels/NestedMemberAccess.java b/src/org/jetbrains/java/decompiler/main/rels/NestedMemberAccess.java index 2abe5d3..c5d5c18 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/NestedMemberAccess.java +++ b/src/org/jetbrains/java/decompiler/main/rels/NestedMemberAccess.java @@ -24,7 +24,7 @@ import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; import org.jetbrains.java.decompiler.modules.decompiler.exps.*; import org.jetbrains.java.decompiler.modules.decompiler.sforms.DirectGraph; import org.jetbrains.java.decompiler.modules.decompiler.sforms.DirectNode; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; import org.jetbrains.java.decompiler.util.InterpreterUtil; @@ -364,7 +364,7 @@ public class NestedMemberAccess { ExitExprent exsource = (ExitExprent)source; if (exsource.getValue().type == Exprent.EXPRENT_VAR) { // qualified this VarExprent var = (VarExprent)exsource.getValue(); - String varname = methsource.varproc.getVarName(new VarVersionPaar(var)); + String varname = methsource.varproc.getVarName(new VarVersionPair(var)); if (!methdest.setOuterVarNames.contains(varname)) { VarNamesCollector vnc = new VarNamesCollector(); @@ -376,7 +376,7 @@ public class NestedMemberAccess { int index = methdest.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER); VarExprent ret = new VarExprent(index, var.getVarType(), methdest.varproc); - methdest.varproc.setVarName(new VarVersionPaar(index, 0), varname); + methdest.varproc.setVarName(new VarVersionPair(index, 0), varname); retexprent = ret; } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java index cfd8746..9d21784 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java @@ -36,7 +36,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.stats.CatchAllStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.gen.VarType; import org.jetbrains.java.decompiler.util.InterpreterUtil; @@ -217,7 +217,7 @@ public class FinallyProcessor { List lstExprents = firstBlockStatement.getExprents(); - VarVersionPaar varpaar = new VarVersionPaar((VarExprent)((AssignmentExprent)lstExprents.get(firstcode == 2 ? 1 : 0)).getLeft()); + VarVersionPair varpaar = new VarVersionPair((VarExprent)((AssignmentExprent)lstExprents.get(firstcode == 2 ? 1 : 0)).getLeft()); FlattenStatementsHelper flatthelper = new FlattenStatementsHelper(); DirectGraph dgraph = flatthelper.buildDirectGraph(root); @@ -259,7 +259,7 @@ public class FinallyProcessor { boolean found = false; for (Exprent expr : lst) { - if (expr.type == Exprent.EXPRENT_VAR && new VarVersionPaar((VarExprent)expr).equals(varpaar)) { + if (expr.type == Exprent.EXPRENT_VAR && new VarVersionPair((VarExprent)expr).equals(varpaar)) { found = true; break; } @@ -287,7 +287,7 @@ public class FinallyProcessor { if (exprent.type == Exprent.EXPRENT_ASSIGNMENT) { AssignmentExprent assexpr = (AssignmentExprent)exprent; if (assexpr.getRight().type == Exprent.EXPRENT_VAR && - new VarVersionPaar((VarExprent)assexpr.getRight()).equals(varpaar)) { + new VarVersionPair((VarExprent)assexpr.getRight()).equals(varpaar)) { Exprent next = null; if (i == node.exprents.size() - 1) { diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/SecondaryFunctionsHelper.java b/src/org/jetbrains/java/decompiler/modules/decompiler/SecondaryFunctionsHelper.java index 84cb1d6..356b7e7 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/SecondaryFunctionsHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/SecondaryFunctionsHelper.java @@ -22,7 +22,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.exps.*; import org.jetbrains.java.decompiler.modules.decompiler.stats.IfStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.gen.VarType; import java.util.ArrayList; @@ -315,7 +315,7 @@ public class SecondaryFunctionsHelper { lstOperands.get(1)), null), null), ConstExprent.getZeroConstant(type.type)), null); - processor.setVarType(new VarVersionPaar(var, 0), type); + processor.setVarType(new VarVersionPair(var, 0), type); return new FunctionExprent(FunctionExprent.FUNCTION_IIF, Arrays.asList( head, new ConstExprent(VarType.VARTYPE_INT, new Integer(0), null), iff), fexpr.bytecode); diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java b/src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java index fc67259..f78be6b 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java @@ -23,7 +23,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.exps.*; import org.jetbrains.java.decompiler.modules.decompiler.sforms.SSAConstructorSparseEx; import org.jetbrains.java.decompiler.modules.decompiler.stats.IfStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.gen.VarType; import org.jetbrains.java.decompiler.util.FastSparseSetFactory.FastSparseSet; @@ -538,12 +538,12 @@ public class SimplifyExprentsHelper { // // NewExprent newexpr = (NewExprent)as.getRight(); // VarType newtype = newexpr.getNewType(); - // VarVersionPaar leftPaar = new VarVersionPaar((VarExprent)as.getLeft()); + // VarVersionPair leftPaar = new VarVersionPair((VarExprent)as.getLeft()); // // if(newtype.type == CodeConstants.TYPE_OBJECT && newtype.arrayDim == 0 && // newexpr.getConstructor() == null) { // - // Set setChangedVars = new HashSet(); + // Set setChangedVars = new HashSet(); // // for(int i = index + 1; i < list.size(); i++) { // Exprent remote = list.get(i); @@ -554,7 +554,7 @@ public class SimplifyExprentsHelper { // if(in.getFuncType() == InvocationExprent.TYP_INIT && in.getInstance().type == Exprent.EXPRENT_VAR // && as.getLeft().equals(in.getInstance())) { // - // Set setVars = remote.getAllVariables(); + // Set setVars = remote.getAllVariables(); // setVars.remove(leftPaar); // setVars.retainAll(setChangedVars); // @@ -581,7 +581,7 @@ public class SimplifyExprentsHelper { // AssignmentExprent asremote = (AssignmentExprent)remote; // if(asremote.getLeft().type == Exprent.EXPRENT_VAR && // asremote.getRight().type == Exprent.EXPRENT_VAR) { - // setChangedVars.add(new VarVersionPaar((VarExprent)asremote.getLeft())); + // setChangedVars.add(new VarVersionPair((VarExprent)asremote.getLeft())); // isTempAssignment = true; // } // @@ -592,7 +592,7 @@ public class SimplifyExprentsHelper { //// List lstRightExprents = asremote.getRight().getAllExprents(true); //// lstRightExprents.add(asremote.getRight()); //// - //// Set setTempChangedVars = new HashSet(); + //// Set setTempChangedVars = new HashSet(); //// boolean isTemp = true; //// //// for(Exprent expr : lstRightExprents) { @@ -600,7 +600,7 @@ public class SimplifyExprentsHelper { //// isTemp = false; //// break; //// } else if(expr.type == Exprent.EXPRENT_VAR) { - //// setTempChangedVars.add(new VarVersionPaar((VarExprent)expr)); + //// setTempChangedVars.add(new VarVersionPair((VarExprent)expr)); //// } //// } //// @@ -614,14 +614,14 @@ public class SimplifyExprentsHelper { //// if(fexpr.getFuncType() == FunctionExprent.FUNCTION_IPP || fexpr.getFuncType() == FunctionExprent.FUNCTION_IMM //// || fexpr.getFuncType() == FunctionExprent.FUNCTION_PPI || fexpr.getFuncType() == FunctionExprent.FUNCTION_MMI) { //// if(fexpr.getLstOperands().get(0).type == Exprent.EXPRENT_VAR) { - //// setChangedVars.add(new VarVersionPaar((VarExprent)fexpr.getLstOperands().get(0))); + //// setChangedVars.add(new VarVersionPair((VarExprent)fexpr.getLstOperands().get(0))); //// isTempAssignment = true; //// } //// } // } // // if(!isTempAssignment) { - // Set setVars = remote.getAllVariables(); + // Set setVars = remote.getAllVariables(); // if(setVars.contains(leftPaar)) { // return false; // } else { @@ -648,7 +648,7 @@ public class SimplifyExprentsHelper { NewExprent newexpr = (NewExprent)as.getRight(); VarType newtype = newexpr.getNewType(); - VarVersionPaar leftPaar = new VarVersionPaar((VarExprent)as.getLeft()); + VarVersionPair leftPaar = new VarVersionPair((VarExprent)as.getLeft()); if (newtype.type == CodeConstants.TYPE_OBJECT && newtype.arrayDim == 0 && newexpr.getConstructor() == null) { @@ -673,7 +673,7 @@ public class SimplifyExprentsHelper { } // check for variable in use - Set setVars = remote.getAllVariables(); + Set setVars = remote.getAllVariables(); if (setVars.contains(leftPaar)) { // variable used somewhere in between -> exit, need a better reduced code return false; } @@ -776,7 +776,7 @@ public class SimplifyExprentsHelper { boolean found = false; - for (Entry> ent : ssa.getPhi().entrySet()) { + for (Entry> ent : ssa.getPhi().entrySet()) { if (ent.getKey().var == ifvar.getIndex()) { if (ent.getValue().contains(ifvar.getVersion()) && ent.getValue().contains(elsevar.getVersion())) { found = true; diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/StackVarsProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/StackVarsProcessor.java index 14b99c4..62d3465 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/StackVarsProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/StackVarsProcessor.java @@ -23,7 +23,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionEdge; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionNode; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionsGraph; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructMethod; @@ -151,15 +151,15 @@ public class StackVarsProcessor { HashSet setVisited = new HashSet(); LinkedList stack = new LinkedList(); - LinkedList> stackMaps = new LinkedList>(); + LinkedList> stackMaps = new LinkedList>(); stack.add(dgraph.first); - stackMaps.add(new HashMap()); + stackMaps.add(new HashMap()); while (!stack.isEmpty()) { DirectNode nd = stack.removeFirst(); - HashMap mapVarValues = stackMaps.removeFirst(); + HashMap mapVarValues = stackMaps.removeFirst(); if (setVisited.contains(nd)) { continue; @@ -211,7 +211,7 @@ public class StackVarsProcessor { for (DirectNode ndx : nd.succs) { stack.add(ndx); - stackMaps.add(new HashMap(mapVarValues)); + stackMaps.add(new HashMap(mapVarValues)); } // make sure the 3 special exprent lists in a loop (init, condition, increment) are not empty @@ -236,13 +236,13 @@ public class StackVarsProcessor { } - private static Exprent isReplaceableVar(Exprent exprent, HashMap mapVarValues, SSAUConstructorSparseEx ssau) { + private static Exprent isReplaceableVar(Exprent exprent, HashMap mapVarValues, SSAUConstructorSparseEx ssau) { Exprent dest = null; if (exprent.type == Exprent.EXPRENT_VAR) { VarExprent var = (VarExprent)exprent; - dest = mapVarValues.get(new VarVersionPaar(var)); + dest = mapVarValues.get(new VarVersionPair(var)); } return dest; @@ -253,10 +253,10 @@ public class StackVarsProcessor { parent.replaceExprent(var, dest); // live sets - SFormsFastMapDirect livemap = ssau.getLiveVarVersionsMap(new VarVersionPaar(var)); - HashSet setVars = getAllVersions(dest); + SFormsFastMapDirect livemap = ssau.getLiveVarVersionsMap(new VarVersionPair(var)); + HashSet setVars = getAllVersions(dest); - for (VarVersionPaar varpaar : setVars) { + for (VarVersionPair varpaar : setVars) { VarVersionNode node = ssau.getSsuversions().nodes.getWithKey(varpaar); for (Iterator>> itent = node.live.entryList().iterator(); itent.hasNext(); ) { @@ -279,7 +279,7 @@ public class StackVarsProcessor { } } - private int[] iterateExprent(List lstExprents, int index, Exprent next, HashMap lstExprents, int index, Exprent next, HashMap mapVarValues, SSAUConstructorSparseEx ssau) { Exprent exprent = lstExprents.get(index); @@ -327,7 +327,7 @@ public class StackVarsProcessor { return new int[]{-1, changed}; } - VarVersionPaar leftpaar = new VarVersionPaar(left); + VarVersionPair leftpaar = new VarVersionPair(left); List usedVers = new ArrayList(); boolean notdom = getUsedVersions(ssau, leftpaar, usedVers); @@ -368,14 +368,14 @@ public class StackVarsProcessor { return new int[]{-1, changed}; } - HashMap> mapVars = getAllVarVersions(leftpaar, right, ssau); + HashMap> mapVars = getAllVarVersions(leftpaar, right, ssau); boolean isSelfReference = mapVars.containsKey(leftpaar.var); if (isSelfReference && notdom) { return new int[]{-1, changed}; } - HashSet setNextVars = next == null ? null : getAllVersions(next); + HashSet setNextVars = next == null ? null : getAllVersions(next); // FIXME: fix the entire method! if (right.type != Exprent.EXPRENT_CONST && @@ -383,7 +383,7 @@ public class StackVarsProcessor { setNextVars != null && mapVars.containsKey(leftpaar.var)) { for (VarVersionNode usedvar : usedVers) { - if (!setNextVars.contains(new VarVersionPaar(usedvar.var, usedvar.version))) { + if (!setNextVars.contains(new VarVersionPair(usedvar.var, usedvar.version))) { return new int[]{-1, changed}; } } @@ -395,10 +395,10 @@ public class StackVarsProcessor { boolean verreplaced = false; - HashSet setTempUsedVers = new HashSet(); + HashSet setTempUsedVers = new HashSet(); for (VarVersionNode usedvar : usedVers) { - VarVersionPaar usedver = new VarVersionPaar(usedvar.var, usedvar.version); + VarVersionPair usedver = new VarVersionPair(usedvar.var, usedvar.version); if (isVersionToBeReplaced(usedver, mapVars, ssau, leftpaar) && (right.type == Exprent.EXPRENT_CONST || right.type == Exprent.EXPRENT_VAR || right.type == Exprent.EXPRENT_FIELD || setNextVars == null || setNextVars.contains(usedver))) { @@ -415,7 +415,7 @@ public class StackVarsProcessor { return new int[]{-1, changed}; } else { - for (VarVersionPaar usedver : setTempUsedVers) { + for (VarVersionPair usedver : setTempUsedVers) { Exprent copy = right.copy(); if (right.type == Exprent.EXPRENT_FIELD && ssau.getMapFieldVars().containsKey(right.id)) { ssau.getMapFieldVars().put(copy.id, ssau.getMapFieldVars().get(right.id)); @@ -438,9 +438,9 @@ public class StackVarsProcessor { } } - private static HashSet getAllVersions(Exprent exprent) { + private static HashSet getAllVersions(Exprent exprent) { - HashSet res = new HashSet(); + HashSet res = new HashSet(); List listTemp = new ArrayList(exprent.getAllExprents(true)); listTemp.add(exprent); @@ -448,7 +448,7 @@ public class StackVarsProcessor { for (Exprent expr : listTemp) { if (expr.type == Exprent.EXPRENT_VAR) { VarExprent var = (VarExprent)expr; - res.add(new VarVersionPaar(var)); + res.add(new VarVersionPair(var)); } } @@ -458,7 +458,7 @@ public class StackVarsProcessor { private static Object[] iterateChildExprent(Exprent exprent, Exprent parent, Exprent next, - HashMap mapVarValues, + HashMap mapVarValues, SSAUConstructorSparseEx ssau) { boolean changed = false; @@ -521,7 +521,7 @@ public class StackVarsProcessor { return new Object[]{null, changed, false}; } - VarVersionPaar leftpaar = new VarVersionPaar(left); + VarVersionPair leftpaar = new VarVersionPair(left); List usedVers = new ArrayList(); boolean notdom = getUsedVersions(ssau, leftpaar, usedVers); @@ -541,7 +541,7 @@ public class StackVarsProcessor { return new Object[]{null, changed, false}; } - HashMap> mapVars = getAllVarVersions(leftpaar, right, ssau); + HashMap> mapVars = getAllVarVersions(leftpaar, right, ssau); if (mapVars.containsKey(leftpaar.var) && notdom) { return new Object[]{null, changed, false}; @@ -550,17 +550,17 @@ public class StackVarsProcessor { mapVars.remove(leftpaar.var); - HashSet setAllowedVars = getAllVersions(parent); + HashSet setAllowedVars = getAllVersions(parent); if (next != null) { setAllowedVars.addAll(getAllVersions(next)); } boolean vernotreplaced = false; - HashSet setTempUsedVers = new HashSet(); + HashSet setTempUsedVers = new HashSet(); for (VarVersionNode usedvar : usedVers) { - VarVersionPaar usedver = new VarVersionPaar(usedvar.var, usedvar.version); + VarVersionPair usedver = new VarVersionPair(usedvar.var, usedvar.version); if (isVersionToBeReplaced(usedver, mapVars, ssau, leftpaar) && (right.type == Exprent.EXPRENT_VAR || setAllowedVars.contains(usedver))) { @@ -573,7 +573,7 @@ public class StackVarsProcessor { if (!notdom && !vernotreplaced) { - for (VarVersionPaar usedver : setTempUsedVers) { + for (VarVersionPair usedver : setTempUsedVers) { Exprent copy = right.copy(); if (right.type == Exprent.EXPRENT_FIELD && ssau.getMapFieldVars().containsKey(right.id)) { ssau.getMapFieldVars().put(copy.id, ssau.getMapFieldVars().get(right.id)); @@ -589,7 +589,7 @@ public class StackVarsProcessor { return new Object[]{null, changed, false}; } - private static boolean getUsedVersions(SSAUConstructorSparseEx ssa, VarVersionPaar var, List res) { + private static boolean getUsedVersions(SSAUConstructorSparseEx ssa, VarVersionPair var, List res) { VarVersionsGraph ssuversions = ssa.getSsuversions(); VarVersionNode varnode = ssuversions.nodes.getWithKey(var); @@ -638,10 +638,10 @@ public class StackVarsProcessor { return !setNotDoms.isEmpty(); } - private static boolean isVersionToBeReplaced(VarVersionPaar usedvar, - HashMap> mapVars, + private static boolean isVersionToBeReplaced(VarVersionPair usedvar, + HashMap> mapVars, SSAUConstructorSparseEx ssau, - VarVersionPaar leftpaar) { + VarVersionPair leftpaar) { VarVersionsGraph ssuversions = ssau.getSsuversions(); @@ -657,21 +657,21 @@ public class StackVarsProcessor { return false; } - for (Entry> ent : mapVars.entrySet()) { + for (Entry> ent : mapVars.entrySet()) { FastSparseSet liveverset = mapLiveVars.get(ent.getKey()); if (liveverset == null) { return false; } HashSet domset = new HashSet(); - for (VarVersionPaar verpaar : ent.getValue()) { + for (VarVersionPair verpaar : ent.getValue()) { domset.add(ssuversions.nodes.getWithKey(verpaar)); } boolean isdom = false; for (Integer livever : liveverset) { - VarVersionNode node = ssuversions.nodes.getWithKey(new VarVersionPaar(ent.getKey().intValue(), livever.intValue())); + VarVersionNode node = ssuversions.nodes.getWithKey(new VarVersionPair(ent.getKey().intValue(), livever.intValue())); if (ssuversions.isDominatorSet(node, domset)) { isdom = true; @@ -687,11 +687,11 @@ public class StackVarsProcessor { return true; } - private static HashMap> getAllVarVersions(VarVersionPaar leftvar, + private static HashMap> getAllVarVersions(VarVersionPair leftvar, Exprent exprent, SSAUConstructorSparseEx ssau) { - HashMap> map = new HashMap>(); + HashMap> map = new HashMap>(); SFormsFastMapDirect mapLiveVars = ssau.getLiveVarVersionsMap(leftvar); List lst = exprent.getAllExprents(true); @@ -702,9 +702,9 @@ public class StackVarsProcessor { int varindex = ((VarExprent)expr).getIndex(); if (leftvar.var != varindex) { if (mapLiveVars.containsKey(varindex)) { - HashSet verset = new HashSet(); + HashSet verset = new HashSet(); for (Integer vers : mapLiveVars.get(varindex)) { - verset.add(new VarVersionPaar(varindex, vers.intValue())); + verset.add(new VarVersionPair(varindex, vers.intValue())); } map.put(varindex, verset); } @@ -720,9 +720,9 @@ public class StackVarsProcessor { if (ssau.getMapFieldVars().containsKey(expr.id)) { int varindex = ssau.getMapFieldVars().get(expr.id); if (mapLiveVars.containsKey(varindex)) { - HashSet verset = new HashSet(); + HashSet verset = new HashSet(); for (Integer vers : mapLiveVars.get(varindex)) { - verset.add(new VarVersionPaar(varindex, vers.intValue())); + verset.add(new VarVersionPair(varindex, vers.intValue())); } map.put(varindex, verset); } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java index 16646f1..21a3be8 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java @@ -20,7 +20,7 @@ import org.jetbrains.java.decompiler.main.TextBuffer; import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; import org.jetbrains.java.decompiler.main.collectors.CounterContainer; import org.jetbrains.java.decompiler.modules.decompiler.vars.CheckTypesResult; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.gen.VarType; import java.util.*; @@ -94,14 +94,14 @@ public class Exprent { return lst; } - public Set getAllVariables() { + public Set getAllVariables() { List lstAllExprents = getAllExprents(true); lstAllExprents.add(this); - Set set = new HashSet(); + Set set = new HashSet(); for (Exprent expr : lstAllExprents) { if (expr.type == EXPRENT_VAR) { - set.add(new VarVersionPaar((VarExprent)expr)); + set.add(new VarVersionPair((VarExprent)expr)); } } return set; diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/FieldExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/FieldExprent.java index 725a77a..bfdd8db 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/FieldExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/FieldExprent.java @@ -22,7 +22,7 @@ import org.jetbrains.java.decompiler.main.TextBuffer; import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; import org.jetbrains.java.decompiler.main.rels.MethodWrapper; import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.consts.LinkConstant; import org.jetbrains.java.decompiler.struct.gen.FieldDescriptor; import org.jetbrains.java.decompiler.struct.gen.VarType; @@ -96,7 +96,7 @@ public class FieldExprent extends Exprent { if (instance != null && instance.type == Exprent.EXPRENT_VAR) { VarExprent instVar = (VarExprent)instance; - VarVersionPaar pair = new VarVersionPaar(instVar); + VarVersionPair pair = new VarVersionPair(instVar); MethodWrapper currentMethod = (MethodWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER); diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java index 1083af6..c64f5a7 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java @@ -25,7 +25,7 @@ import org.jetbrains.java.decompiler.main.rels.MethodWrapper; import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; import org.jetbrains.java.decompiler.modules.decompiler.vars.CheckTypesResult; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.consts.LinkConstant; @@ -233,7 +233,7 @@ public class InvocationExprent extends Exprent { if (instance != null && instance.type == Exprent.EXPRENT_VAR) { VarExprent instvar = (VarExprent)instance; - VarVersionPaar varpaar = new VarVersionPaar(instvar); + VarVersionPair varpaar = new VarVersionPair(instvar); VarProcessor vproc = instvar.getProcessor(); if (vproc == null) { @@ -318,7 +318,7 @@ public class InvocationExprent extends Exprent { } } - List sigFields = null; + List sigFields = null; boolean isEnum = false; if (functype == TYP_INIT) { ClassNode newNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(classname); @@ -329,8 +329,8 @@ public class InvocationExprent extends Exprent { } else { if (newNode.type == ClassNode.CLASS_MEMBER && (newNode.access & CodeConstants.ACC_STATIC) == 0) { // non-static member class - sigFields = new ArrayList(Collections.nCopies(lstParameters.size(), (VarVersionPaar)null)); - sigFields.set(0, new VarVersionPaar(-1, 0)); + sigFields = new ArrayList(Collections.nCopies(lstParameters.size(), (VarVersionPair)null)); + sigFields.set(0, new VarVersionPair(-1, 0)); } } isEnum = newNode.classStruct.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM); diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java index f5b9226..f3d6d2a 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java @@ -24,7 +24,7 @@ import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; import org.jetbrains.java.decompiler.modules.decompiler.vars.CheckTypesResult; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.gen.VarType; import org.jetbrains.java.decompiler.util.InterpreterUtil; @@ -174,7 +174,7 @@ public class NewExprent extends Exprent { ClassNode newnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(invsuper.getClassname()); - List sigFields = null; + List sigFields = null; if (newnode != null) { // own class if (newnode.wrapper != null) { sigFields = newnode.wrapper.getMethodWrapper("", invsuper.getStringDescriptor()).signatureFields; @@ -182,8 +182,8 @@ public class NewExprent extends Exprent { else { if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 && !constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance - sigFields = new ArrayList(Collections.nCopies(constructor.getLstParameters().size(), (VarVersionPaar)null)); - sigFields.set(0, new VarVersionPaar(-1, 0)); + sigFields = new ArrayList(Collections.nCopies(constructor.getLstParameters().size(), (VarVersionPair)null)); + sigFields.set(0, new VarVersionPair(-1, 0)); } } } @@ -280,7 +280,7 @@ public class NewExprent extends Exprent { ClassNode newnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(constructor.getClassname()); - List sigFields = null; + List sigFields = null; if (newnode != null) { // own class if (newnode.wrapper != null) { sigFields = newnode.wrapper.getMethodWrapper("", constructor.getStringDescriptor()).signatureFields; @@ -288,8 +288,8 @@ public class NewExprent extends Exprent { else { if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 && !constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance - sigFields = new ArrayList(Collections.nCopies(lstParameters.size(), (VarVersionPaar)null)); - sigFields.set(0, new VarVersionPaar(-1, 0)); + sigFields = new ArrayList(Collections.nCopies(lstParameters.size(), (VarVersionPair)null)); + sigFields.set(0, new VarVersionPair(-1, 0)); } } } @@ -399,7 +399,7 @@ public class NewExprent extends Exprent { VarExprent varEnclosing = (VarExprent)enclosing; StructClass current_class = ((ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_NODE)).classStruct; - String this_classname = varEnclosing.getProcessor().getThisVars().get(new VarVersionPaar(varEnclosing)); + String this_classname = varEnclosing.getProcessor().getThisVars().get(new VarVersionPair(varEnclosing)); if (!current_class.qualifiedName.equals(this_classname)) { isQualifiedNew = true; diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java index dfbbbaa..70ea2bc 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java @@ -24,7 +24,7 @@ import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarTypeProcessor; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.gen.VarType; import org.jetbrains.java.decompiler.util.InterpreterUtil; @@ -89,11 +89,11 @@ public class VarExprent extends Exprent { else { String name = null; if (processor != null) { - name = processor.getVarName(new VarVersionPaar(index, version)); + name = processor.getVarName(new VarVersionPair(index, version)); } if (definition) { - if (processor != null && processor.getVarFinal(new VarVersionPaar(index, version)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) { + if (processor != null && processor.getVarFinal(new VarVersionPair(index, version)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) { buffer.append("final "); } buffer.append(ExprProcessor.getCastTypeName(getVarType())).append(" "); @@ -126,7 +126,7 @@ public class VarExprent extends Exprent { public VarType getVarType() { VarType vt = null; if (processor != null) { - vt = processor.getVarType(new VarVersionPaar(index, version)); + vt = processor.getVarType(new VarVersionPair(index, version)); } if (vt == null || (varType != null && varType.type != CodeConstants.TYPE_UNKNOWN)) { diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAConstructorSparseEx.java b/src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAConstructorSparseEx.java index dad7c9d..2419359 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAConstructorSparseEx.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAConstructorSparseEx.java @@ -25,7 +25,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.stats.CatchAllStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.CatchStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; import org.jetbrains.java.decompiler.util.FastSparseSetFactory; @@ -54,12 +54,12 @@ public class SSAConstructorSparseEx { private HashMap extraVarVersions = new HashMap(); // (var, version), version - private HashMap> phi = new HashMap>(); + private HashMap> phi = new HashMap>(); // var, version private HashMap lastversion = new HashMap(); - private List startVars = new ArrayList(); + private List startVars = new ArrayList(); // set factory private FastSparseSetFactory factory; @@ -265,7 +265,7 @@ public class SSAConstructorSparseEx { else if (cardinality == 2) { // size > 1 Integer current_vers = vardest.getVersion(); - VarVersionPaar currpaar = new VarVersionPaar(varindex, current_vers); + VarVersionPair currpaar = new VarVersionPair(varindex, current_vers); if (current_vers != 0 && phi.containsKey(currpaar)) { setCurrentVar(varmap, varindex, current_vers); // update phi node @@ -279,7 +279,7 @@ public class SSAConstructorSparseEx { setCurrentVar(varmap, varindex, nextver); // create new phi node - phi.put(new VarVersionPaar(varindex, nextver), vers); + phi.put(new VarVersionPair(varindex, nextver), vers); } } // 0 means uninitialized variable, which is impossible } @@ -477,7 +477,7 @@ public class SSAConstructorSparseEx { setCurrentVar(map, varindex, version); extraVarVersions.put(dgraph.nodes.getWithKey(flatthelper.getMapDestinationNodes().get(stat.getStats().get(i).id)[0]).id, map); - startVars.add(new VarVersionPaar(varindex, version)); + startVars.add(new VarVersionPair(varindex, version)); } } @@ -501,7 +501,7 @@ public class SSAConstructorSparseEx { FastSparseSet set = factory.spawnEmptySet(); set.add(version); map.put(varindex, set); - startVars.add(new VarVersionPaar(varindex, version)); + startVars.add(new VarVersionPair(varindex, version)); if (thisvar) { if (i == 0) { @@ -519,11 +519,11 @@ public class SSAConstructorSparseEx { return map; } - public HashMap> getPhi() { + public HashMap> getPhi() { return phi; } - public List getStartVars() { + public List getStartVars() { return startVars; } } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAUConstructorSparseEx.java b/src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAUConstructorSparseEx.java index c6f4dfe..b039d91 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAUConstructorSparseEx.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAUConstructorSparseEx.java @@ -21,7 +21,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.sforms.FlattenStatements import org.jetbrains.java.decompiler.modules.decompiler.stats.*; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionEdge; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionNode; -import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPaar; +import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionsGraph; import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; @@ -56,20 +56,20 @@ public class SSAUConstructorSparseEx { //private HashMap>> extraVarVersions = new HashMap>>(); // (var, version), version - private HashMap> phi = new HashMap>(); + private HashMap> phi = new HashMap>(); // var, version private HashMap lastversion = new HashMap(); // version, protected ranges (catch, finally) - private HashMap mapVersionFirstRange = new HashMap(); + private HashMap mapVersionFirstRange = new HashMap(); // version, version - private HashMap phantomppnodes = new HashMap(); // ++ and -- + private HashMap phantomppnodes = new HashMap(); // ++ and -- // node.id, version, version - private HashMap> phantomexitnodes = - new HashMap>(); // finally exits + private HashMap> phantomexitnodes = + new HashMap>(); // finally exits // versions memory dependencies private VarVersionsGraph ssuversions = new VarVersionsGraph(); @@ -264,7 +264,7 @@ public class SSAUConstructorSparseEx { mapFieldVars.put(expr.id, index); // ssu graph - ssuversions.createNode(new VarVersionPaar(index, 1)); + ssuversions.createNode(new VarVersionPair(index, 1)); } setCurrentVar(varmap, index, 1); @@ -306,13 +306,13 @@ public class SSAUConstructorSparseEx { varassign.setVersion(nextver); // ssu graph - ssuversions.createNode(new VarVersionPaar(varindex, nextver)); + ssuversions.createNode(new VarVersionPair(varindex, nextver)); setCurrentVar(varmap, varindex, nextver); } else { if (calcLiveVars) { - varMapToGraph(new VarVersionPaar(varindex.intValue(), varassign.getVersion()), varmap); + varMapToGraph(new VarVersionPair(varindex.intValue(), varassign.getVersion()), varmap); } setCurrentVar(varmap, varindex, varassign.getVersion()); } @@ -329,14 +329,14 @@ public class SSAUConstructorSparseEx { if (func.getLstOperands().get(0).type == Exprent.EXPRENT_VAR) { VarExprent var = (VarExprent)func.getLstOperands().get(0); Integer varindex = var.getIndex(); - VarVersionPaar varpaar = new VarVersionPaar(varindex.intValue(), var.getVersion()); + VarVersionPair varpaar = new VarVersionPair(varindex.intValue(), var.getVersion()); // ssu graph - VarVersionPaar phantomver = phantomppnodes.get(varpaar); + VarVersionPair phantomver = phantomppnodes.get(varpaar); if (phantomver == null) { // get next version Integer nextver = getNextFreeVersion(varindex, null); - phantomver = new VarVersionPaar(varindex, nextver); + phantomver = new VarVersionPair(varindex, nextver); //ssuversions.createOrGetNode(phantomver); ssuversions.createNode(phantomver); @@ -375,7 +375,7 @@ public class SSAUConstructorSparseEx { if (cardinality == 1) { // size == 1 if (current_vers.intValue() != 0) { if (calcLiveVars) { - varMapToGraph(new VarVersionPaar(varindex, current_vers), varmap); + varMapToGraph(new VarVersionPair(varindex, current_vers), varmap); } setCurrentVar(varmap, varindex, current_vers); } @@ -389,8 +389,8 @@ public class SSAUConstructorSparseEx { // ssu graph Integer lastver = vers.iterator().next(); - VarVersionNode prenode = ssuversions.nodes.getWithKey(new VarVersionPaar(varindex, lastver)); - VarVersionNode usenode = ssuversions.createNode(new VarVersionPaar(varindex, usever)); + VarVersionNode prenode = ssuversions.nodes.getWithKey(new VarVersionPair(varindex, lastver)); + VarVersionNode usenode = ssuversions.createNode(new VarVersionPair(varindex, usever)); VarVersionEdge edge = new VarVersionEdge(VarVersionEdge.EDGE_GENERAL, prenode, usenode); prenode.addSuccessor(edge); usenode.addPredecessor(edge); @@ -400,7 +400,7 @@ public class SSAUConstructorSparseEx { if (current_vers.intValue() != 0) { if (calcLiveVars) { - varMapToGraph(new VarVersionPaar(varindex, current_vers), varmap); + varMapToGraph(new VarVersionPair(varindex, current_vers), varmap); } setCurrentVar(varmap, varindex, current_vers); } @@ -411,19 +411,19 @@ public class SSAUConstructorSparseEx { vardest.setVersion(usever); // ssu node - ssuversions.createNode(new VarVersionPaar(varindex, usever)); + ssuversions.createNode(new VarVersionPair(varindex, usever)); setCurrentVar(varmap, varindex, usever); current_vers = usever; } - createOrUpdatePhiNode(new VarVersionPaar(varindex, current_vers), vers, stat); + createOrUpdatePhiNode(new VarVersionPair(varindex, current_vers), vers, stat); } // vers.size() == 0 means uninitialized variable, which is impossible } } - private void createOrUpdatePhiNode(VarVersionPaar phivar, FastSparseSet vers, Statement stat) { + private void createOrUpdatePhiNode(VarVersionPair phivar, FastSparseSet vers, Statement stat) { FastSparseSet versCopy = vers.getCopy(); HashSet phiVers = new HashSet(); @@ -455,18 +455,18 @@ public class SSAUConstructorSparseEx { } List colnodes = new ArrayList(); - List colpaars = new ArrayList(); + List colpaars = new ArrayList(); for (Integer ver : versCopy) { - VarVersionNode prenode = ssuversions.nodes.getWithKey(new VarVersionPaar(phivar.var, ver.intValue())); + VarVersionNode prenode = ssuversions.nodes.getWithKey(new VarVersionPair(phivar.var, ver.intValue())); Integer tempver = getNextFreeVersion(phivar.var, stat); VarVersionNode tempnode = new VarVersionNode(phivar.var, tempver.intValue()); colnodes.add(tempnode); - colpaars.add(new VarVersionPaar(phivar.var, tempver.intValue())); + colpaars.add(new VarVersionPair(phivar.var, tempver.intValue())); VarVersionEdge edge = new VarVersionEdge(VarVersionEdge.EDGE_GENERAL, prenode, tempnode); @@ -487,9 +487,9 @@ public class SSAUConstructorSparseEx { phi.put(phivar, phiVers); } - private void varMapToGraph(VarVersionPaar varpaar, SFormsFastMapDirect varmap) { + private void varMapToGraph(VarVersionPair varpaar, SFormsFastMapDirect varmap) { - VBStyleCollection nodes = ssuversions.nodes; + VBStyleCollection nodes = ssuversions.nodes; VarVersionNode node = nodes.getWithKey(varpaar); @@ -512,7 +512,7 @@ public class SSAUConstructorSparseEx { if (stat != null) { // null iff phantom version Integer firstRangeId = getFirstProtectedRange(stat); if (firstRangeId != null) { - mapVersionFirstRange.put(new VarVersionPaar(var, nextver), firstRangeId); + mapVersionFirstRange.put(new VarVersionPair(var, nextver), firstRangeId); } } @@ -633,9 +633,9 @@ public class SSAUConstructorSparseEx { if (!mapTrueSource.isEmpty() && !mapNew.isEmpty()) { // FIXME: what for?? // replace phi versions with corresponding phantom ones - HashMap mapPhantom = phantomexitnodes.get(predid); + HashMap mapPhantom = phantomexitnodes.get(predid); if (mapPhantom == null) { - mapPhantom = new HashMap(); + mapPhantom = new HashMap(); } SFormsFastMapDirect mapExitVar = mapNew.getCopy(); @@ -645,17 +645,17 @@ public class SSAUConstructorSparseEx { for (Integer version : ent.getValue()) { Integer varindex = ent.getKey(); - VarVersionPaar exitvar = new VarVersionPaar(varindex, version); + VarVersionPair exitvar = new VarVersionPair(varindex, version); FastSparseSet newSet = mapNew.get(varindex); // remove the actual exit version newSet.remove(version); // get or create phantom version - VarVersionPaar phantomvar = mapPhantom.get(exitvar); + VarVersionPair phantomvar = mapPhantom.get(exitvar); if (phantomvar == null) { Integer newversion = getNextFreeVersion(exitvar.var, null); - phantomvar = new VarVersionPaar(exitvar.var, newversion.intValue()); + phantomvar = new VarVersionPair(exitvar.var, newversion.intValue()); VarVersionNode exitnode = ssuversions.nodes.getWithKey(exitvar); VarVersionNode phantomnode = ssuversions.createNode(phantomvar); @@ -745,8 +745,8 @@ public class SSAUConstructorSparseEx { setCurrentVar(map, varindex, version); extraVarVersions.put(dgraph.nodes.getWithKey(flatthelper.getMapDestinationNodes().get(stat.getStats().get(i).id)[0]).id, map); - //ssuversions.createOrGetNode(new VarVersionPaar(varindex, version)); - ssuversions.createNode(new VarVersionPaar(varindex, version)); + //ssuversions.createOrGetNode(new VarVersionPair(varindex, version)); + ssuversions.createNode(new VarVersionPair(varindex, version)); } } @@ -770,7 +770,7 @@ public class SSAUConstructorSparseEx { FastSparseSet set = factory.spawnEmptySet(); set.add(version); map.put(varindex, set); - ssuversions.createNode(new VarVersionPaar(varindex, version)); + ssuversions.createNode(new VarVersionPair(varindex, version)); if (thisvar) { if (i == 0) { @@ -815,7 +815,7 @@ public class SSAUConstructorSparseEx { return null; } - public HashMap> getPhi() { + public HashMap> getPhi() { return phi; } @@ -823,7 +823,7 @@ public class SSAUConstructorSparseEx { return ssuversions; } - public SFormsFastMapDirect getLiveVarVersionsMap(VarVersionPaar varpaar) { + public SFormsFastMapDirect getLiveVarVersionsMap(VarVersionPair varpaar) { VarVersionNode node = ssuversions.nodes.getWithKey(varpaar); @@ -834,7 +834,7 @@ public class SSAUConstructorSparseEx { return null; } - public HashMap getMapVersionFirstRange() { + public HashMap getMapVersionFirstRange() { return mapVersionFirstRange; } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarDefinitionHelper.java b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarDefinitionHelper.java index 6999671..23a4e8d 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarDefinitionHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarDefinitionHelper.java @@ -68,7 +68,7 @@ public class VarDefinitionHelper { int varindex = 0; for (int i = 0; i < paramcount; i++) { implDefVars.add(varindex); - varproc.setVarName(new VarVersionPaar(varindex, 0), vc.getFreeName(varindex)); + varproc.setVarName(new VarVersionPair(varindex, 0), vc.getFreeName(varindex)); if (thisvar) { if (i == 0) { @@ -86,8 +86,8 @@ public class VarDefinitionHelper { if (thisvar) { StructClass current_class = (StructClass)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS); - varproc.getThisVars().put(new VarVersionPaar(0, 0), current_class.qualifiedName); - varproc.setVarName(new VarVersionPaar(0, 0), "this"); + varproc.getThisVars().put(new VarVersionPair(0, 0), current_class.qualifiedName); + varproc.setVarName(new VarVersionPair(0, 0), "this"); vc.addName("this"); } @@ -109,7 +109,7 @@ public class VarDefinitionHelper { if (lstVars != null) { for (VarExprent var : lstVars) { implDefVars.add(var.getIndex()); - varproc.setVarName(new VarVersionPaar(var), vc.getFreeName(var.getIndex())); + varproc.setVarName(new VarVersionPair(var), vc.getFreeName(var.getIndex())); var.setDefinition(true); } } @@ -134,7 +134,7 @@ public class VarDefinitionHelper { continue; } - varproc.setVarName(new VarVersionPaar(index.intValue(), 0), vc.getFreeName(index)); + varproc.setVarName(new VarVersionPair(index.intValue(), 0), vc.getFreeName(index)); // special case for if (stat.type == Statement.TYPE_DO) { @@ -196,7 +196,7 @@ public class VarDefinitionHelper { } if (!defset) { - VarExprent var = new VarExprent(index.intValue(), varproc.getVarType(new VarVersionPaar(index.intValue(), 0)), varproc); + VarExprent var = new VarExprent(index.intValue(), varproc.getVarType(new VarVersionPair(index.intValue(), 0)), varproc); var.setDefinition(true); lst.add(addindex, var); diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java index 47e531d..1e78895 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java @@ -27,10 +27,10 @@ import java.util.Map.Entry; public class VarProcessor { - private Map mapVarNames = new HashMap(); + private Map mapVarNames = new HashMap(); private VarVersionsProcessor varVersions; - private Map thisVars = new HashMap(); - private Set externalVars = new HashSet(); + private Map thisVars = new HashMap(); + private Set externalVars = new HashSet(); public void setVarVersions(RootStatement root) { varVersions = new VarVersionsProcessor(); @@ -38,7 +38,7 @@ public class VarProcessor { } public void setVarDefinitions(Statement root) { - mapVarNames = new HashMap(); + mapVarNames = new HashMap(); StructMethod mt = (StructMethod)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD); new VarDefinitionHelper(root, mt, this).setVarDefinitions(); @@ -51,17 +51,17 @@ public class VarProcessor { Map mapOriginalVarIndices = varVersions.getMapOriginalVarIndices(); - List listVars = new ArrayList(mapVarNames.keySet()); - Collections.sort(listVars, new Comparator() { + List listVars = new ArrayList(mapVarNames.keySet()); + Collections.sort(listVars, new Comparator() { @Override - public int compare(VarVersionPaar o1, VarVersionPaar o2) { + public int compare(VarVersionPair o1, VarVersionPair o2) { return o1.var - o2.var; } }); Map mapNames = new HashMap(); - for (VarVersionPaar pair : listVars) { + for (VarVersionPair pair : listVars) { String name = mapVarNames.get(pair); Integer index = mapOriginalVarIndices.get(pair.var); @@ -81,41 +81,41 @@ public class VarProcessor { } public void refreshVarNames(VarNamesCollector vc) { - Map tempVarNames = new HashMap(mapVarNames); - for (Entry ent : tempVarNames.entrySet()) { + Map tempVarNames = new HashMap(mapVarNames); + for (Entry ent : tempVarNames.entrySet()) { mapVarNames.put(ent.getKey(), vc.getFreeName(ent.getValue())); } } - public VarType getVarType(VarVersionPaar pair) { + public VarType getVarType(VarVersionPair pair) { return varVersions == null ? null : varVersions.getVarType(pair); } - public void setVarType(VarVersionPaar pair, VarType type) { + public void setVarType(VarVersionPair pair, VarType type) { varVersions.setVarType(pair, type); } - public String getVarName(VarVersionPaar pair) { + public String getVarName(VarVersionPair pair) { return mapVarNames == null ? null : mapVarNames.get(pair); } - public void setVarName(VarVersionPaar pair, String name) { + public void setVarName(VarVersionPair pair, String name) { mapVarNames.put(pair, name); } - public int getVarFinal(VarVersionPaar pair) { + public int getVarFinal(VarVersionPair pair) { return varVersions == null ? VarTypeProcessor.VAR_FINAL : varVersions.getVarFinal(pair); } - public void setVarFinal(VarVersionPaar pair, int finalType) { + public void setVarFinal(VarVersionPair pair, int finalType) { varVersions.setVarFinal(pair, finalType); } - public Map getThisVars() { + public Map getThisVars() { return thisVars; } - public Set getExternalVars() { + public Set getExternalVars() { return externalVars; } } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarTypeProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarTypeProcessor.java index b17f277..e2bc5fb 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarTypeProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarTypeProcessor.java @@ -39,9 +39,9 @@ public class VarTypeProcessor { public static final int VAR_EXPLICIT_FINAL = 2; public static final int VAR_FINAL = 3; - private Map mapExprentMinTypes = new HashMap(); - private Map mapExprentMaxTypes = new HashMap(); - private Map mapFinalVars = new HashMap(); + private Map mapExprentMinTypes = new HashMap(); + private Map mapExprentMaxTypes = new HashMap(); + private Map mapFinalVars = new HashMap(); private void setInitVars(RootStatement root) { StructMethod mt = (StructMethod)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD); @@ -53,14 +53,14 @@ public class VarTypeProcessor { if (thisVar) { StructClass cl = (StructClass)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS); VarType clType = new VarType(CodeConstants.TYPE_OBJECT, 0, cl.qualifiedName); - mapExprentMinTypes.put(new VarVersionPaar(0, 1), clType); - mapExprentMaxTypes.put(new VarVersionPaar(0, 1), clType); + mapExprentMinTypes.put(new VarVersionPair(0, 1), clType); + mapExprentMaxTypes.put(new VarVersionPair(0, 1), clType); } int varIndex = 0; for (int i = 0; i < md.params.length; i++) { - mapExprentMinTypes.put(new VarVersionPaar(varIndex + (thisVar ? 1 : 0), 1), md.params[i]); - mapExprentMaxTypes.put(new VarVersionPaar(varIndex + (thisVar ? 1 : 0), 1), md.params[i]); + mapExprentMinTypes.put(new VarVersionPair(varIndex + (thisVar ? 1 : 0), 1), md.params[i]); + mapExprentMaxTypes.put(new VarVersionPair(varIndex + (thisVar ? 1 : 0), 1), md.params[i]); varIndex += md.params[i].stackSize; } @@ -81,8 +81,8 @@ public class VarTypeProcessor { if (lstVars != null) { for (VarExprent var : lstVars) { - mapExprentMinTypes.put(new VarVersionPaar(var.getIndex(), 1), var.getVarType()); - mapExprentMaxTypes.put(new VarVersionPaar(var.getIndex(), 1), var.getVarType()); + mapExprentMinTypes.put(new VarVersionPair(var.getIndex(), 1), var.getVarType()); + mapExprentMaxTypes.put(new VarVersionPair(var.getIndex(), 1), var.getVarType()); } } @@ -142,7 +142,7 @@ public class VarTypeProcessor { if (exprent.type == Exprent.EXPRENT_CONST) { ConstExprent constExpr = (ConstExprent)exprent; if (constExpr.getConstType().typeFamily <= CodeConstants.TYPE_FAMILY_INTEGER) { // boolean or integer - VarVersionPaar pair = new VarVersionPaar(constExpr.id, -1); + VarVersionPair pair = new VarVersionPair(constExpr.id, -1); if (!mapExprentMinTypes.containsKey(pair)) { mapExprentMinTypes.put(pair, constExpr.getConstType()); } @@ -184,13 +184,13 @@ public class VarTypeProcessor { } } case Exprent.EXPRENT_VAR: - VarVersionPaar pair = null; + VarVersionPair pair = null; if (exprent.type == Exprent.EXPRENT_CONST) { - pair = new VarVersionPaar(((ConstExprent)exprent).id, -1); + pair = new VarVersionPair(((ConstExprent)exprent).id, -1); } else if (exprent.type == Exprent.EXPRENT_VAR) { //noinspection ConstantConditions - pair = new VarVersionPaar((VarExprent)exprent); + pair = new VarVersionPair((VarExprent)exprent); } if (minMax == 0) { // min @@ -255,23 +255,23 @@ public class VarTypeProcessor { return res; } - public Map getMapExprentMaxTypes() { + public Map getMapExprentMaxTypes() { return mapExprentMaxTypes; } - public Map getMapExprentMinTypes() { + public Map getMapExprentMinTypes() { return mapExprentMinTypes; } - public Map getMapFinalVars() { + public Map getMapFinalVars() { return mapFinalVars; } - public void setVarType(VarVersionPaar pair, VarType type) { + public void setVarType(VarVersionPair pair, VarType type) { mapExprentMinTypes.put(pair, type); } - public VarType getVarType(VarVersionPaar pair) { + public VarType getVarType(VarVersionPair pair) { return mapExprentMinTypes.get(pair); } } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionNode.java b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionNode.java index 587c653..acc88b0 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionNode.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionNode.java @@ -45,8 +45,8 @@ public class VarVersionNode implements IGraphNode { this.version = version; } - public VarVersionPaar getVarPaar() { - return new VarVersionPaar(var, version); + public VarVersionPair getVarPaar() { + return new VarVersionPair(var, version); } public List getPredecessors() { diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionPaar.java b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionPair.java similarity index 80% rename from src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionPaar.java rename to src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionPair.java index 5f3e520..ab9e5d4 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionPaar.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionPair.java @@ -17,24 +17,24 @@ package org.jetbrains.java.decompiler.modules.decompiler.vars; import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; -public class VarVersionPaar { +public class VarVersionPair { - public int var; - public int version; + public final int var; + public final int version; private int hashCode = -1; - public VarVersionPaar(int var, int version) { + public VarVersionPair(int var, int version) { this.var = var; this.version = version; } - public VarVersionPaar(Integer var, Integer version) { + public VarVersionPair(Integer var, Integer version) { this.var = var.intValue(); this.version = version.intValue(); } - public VarVersionPaar(VarExprent var) { + public VarVersionPair(VarExprent var) { this.var = var.getIndex(); this.version = var.getVersion(); } @@ -42,9 +42,9 @@ public class VarVersionPaar { @Override public boolean equals(Object o) { if (o == this) return true; - if (o == null || !(o instanceof VarVersionPaar)) return false; + if (o == null || !(o instanceof VarVersionPair)) return false; - VarVersionPaar paar = (VarVersionPaar)o; + VarVersionPair paar = (VarVersionPair)o; return var == paar.var && version == paar.version; } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsGraph.java b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsGraph.java index f839a05..0077d95 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsGraph.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsGraph.java @@ -27,17 +27,17 @@ public class VarVersionsGraph { public int counter = 0; - public VBStyleCollection nodes = new VBStyleCollection(); + public VBStyleCollection nodes = new VBStyleCollection(); private GenericDominatorEngine engine; - public VarVersionNode createNode(VarVersionPaar ver) { + public VarVersionNode createNode(VarVersionPair ver) { VarVersionNode node; nodes.addWithKey(node = new VarVersionNode(ver.var, ver.version), ver); return node; } - public void addNodes(Collection colnodes, Collection colpaars) { + public void addNodes(Collection colnodes, Collection colpaars) { nodes.addAllWithKey(colnodes, colpaars); } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsProcessor.java index 661a833..31f0f86 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsProcessor.java @@ -62,17 +62,17 @@ public class VarVersionsProcessor { private static void mergePhiVersions(SSAConstructorSparseEx ssa, DirectGraph graph) { // collect phi versions - List> lst = new ArrayList>(); - for (Entry> ent : ssa.getPhi().entrySet()) { - Set set = new HashSet(); + List> lst = new ArrayList>(); + for (Entry> ent : ssa.getPhi().entrySet()) { + Set set = new HashSet(); set.add(ent.getKey()); for (Integer version : ent.getValue()) { - set.add(new VarVersionPaar(ent.getKey().var, version.intValue())); + set.add(new VarVersionPair(ent.getKey().var, version.intValue())); } for (int i = lst.size() - 1; i >= 0; i--) { - Set tset = lst.get(i); - Set intersection = new HashSet(set); + Set tset = lst.get(i); + Set intersection = new HashSet(set); intersection.retainAll(tset); if (!intersection.isEmpty()) { @@ -84,24 +84,24 @@ public class VarVersionsProcessor { lst.add(set); } - Map phiVersions = new HashMap(); - for (Set set : lst) { + Map phiVersions = new HashMap(); + for (Set set : lst) { int min = Integer.MAX_VALUE; - for (VarVersionPaar paar : set) { + for (VarVersionPair paar : set) { if (paar.version < min) { min = paar.version; } } - for (VarVersionPaar paar : set) { - phiVersions.put(new VarVersionPaar(paar.var, paar.version), min); + for (VarVersionPair paar : set) { + phiVersions.put(new VarVersionPair(paar.var, paar.version), min); } } updateVersions(graph, phiVersions); } - private static void updateVersions(DirectGraph graph, final Map versions) { + private static void updateVersions(DirectGraph graph, final Map versions) { graph.iterateExprents(new DirectGraph.ExprentIterator() { @Override public int processExprent(Exprent exprent) { @@ -111,7 +111,7 @@ public class VarVersionsProcessor { for (Exprent expr : lst) { if (expr.type == Exprent.EXPRENT_VAR) { VarExprent var = (VarExprent)expr; - Integer version = versions.get(new VarVersionPaar(var)); + Integer version = versions.get(new VarVersionPair(var)); if (version != null) { var.setVersion(version); } @@ -124,11 +124,11 @@ public class VarVersionsProcessor { } private static void eliminateNonJavaTypes(VarTypeProcessor typeProcessor) { - Map mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); - Map mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); + Map mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); + Map mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); - Set set = new HashSet(mapExprentMinTypes.keySet()); - for (VarVersionPaar paar : set) { + Set set = new HashSet(mapExprentMinTypes.keySet()); + for (VarVersionPair paar : set) { VarType type = mapExprentMinTypes.get(paar); VarType maxType = mapExprentMaxTypes.get(paar); @@ -150,12 +150,12 @@ public class VarVersionsProcessor { } private static void simpleMerge(VarTypeProcessor typeProcessor, DirectGraph graph, StructMethod mt) { - Map mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); - Map mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); + Map mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); + Map mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); Map> mapVarVersions = new HashMap>(); - for (VarVersionPaar pair : mapExprentMinTypes.keySet()) { + for (VarVersionPair pair : mapExprentMinTypes.keySet()) { if (pair.version >= 0) { // don't merge constants Set set = mapVarVersions.get(pair.var); if (set == null) { @@ -168,7 +168,7 @@ public class VarVersionsProcessor { boolean is_method_static = mt.hasModifier(CodeConstants.ACC_STATIC); - Map mapMergedVersions = new HashMap(); + Map mapMergedVersions = new HashMap(); for (Entry> ent : mapVarVersions.entrySet()) { @@ -177,7 +177,7 @@ public class VarVersionsProcessor { Collections.sort(lstVersions); for (int i = 0; i < lstVersions.size(); i++) { - VarVersionPaar firstPair = new VarVersionPaar(ent.getKey(), lstVersions.get(i)); + VarVersionPair firstPair = new VarVersionPair(ent.getKey(), lstVersions.get(i)); VarType firstType = mapExprentMinTypes.get(firstPair); if (firstPair.var == 0 && firstPair.version == 1 && !is_method_static) { @@ -185,7 +185,7 @@ public class VarVersionsProcessor { } for (int j = i + 1; j < lstVersions.size(); j++) { - VarVersionPaar secondPair = new VarVersionPaar(ent.getKey(), lstVersions.get(j)); + VarVersionPair secondPair = new VarVersionPair(ent.getKey(), lstVersions.get(j)); VarType secondType = mapExprentMinTypes.get(secondPair); if (firstType.equals(secondType) || @@ -225,23 +225,23 @@ public class VarVersionsProcessor { } private void setNewVarIndices(VarTypeProcessor typeProcessor, DirectGraph graph) { - final Map mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); - Map mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); - Map mapFinalVars = typeProcessor.getMapFinalVars(); + final Map mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); + Map mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); + Map mapFinalVars = typeProcessor.getMapFinalVars(); CounterContainer counters = DecompilerContext.getCounterContainer(); - final Map mapVarPaar = new HashMap(); + final Map mapVarPaar = new HashMap(); Map mapOriginalVarIndices = new HashMap(); // map var-version pairs on new var indexes - Set set = new HashSet(mapExprentMinTypes.keySet()); - for (VarVersionPaar pair : set) { + Set set = new HashSet(mapExprentMinTypes.keySet()); + for (VarVersionPair pair : set) { if (pair.version >= 0) { int newIndex = pair.version == 1 ? pair.var : counters.getCounterAndIncrement(CounterContainer.VAR_COUNTER); - VarVersionPaar newVar = new VarVersionPaar(newIndex, 0); + VarVersionPair newVar = new VarVersionPair(newIndex, 0); mapExprentMinTypes.put(newVar, mapExprentMinTypes.get(pair)); mapExprentMaxTypes.put(newVar, mapExprentMaxTypes.get(pair)); @@ -265,14 +265,14 @@ public class VarVersionsProcessor { for (Exprent expr : lst) { if (expr.type == Exprent.EXPRENT_VAR) { VarExprent newVar = (VarExprent)expr; - Integer newVarIndex = mapVarPaar.get(new VarVersionPaar(newVar)); + Integer newVarIndex = mapVarPaar.get(new VarVersionPair(newVar)); if (newVarIndex != null) { newVar.setIndex(newVarIndex); newVar.setVersion(0); } } else if (expr.type == Exprent.EXPRENT_CONST) { - VarType maxType = mapExprentMaxTypes.get(new VarVersionPaar(expr.id, -1)); + VarType maxType = mapExprentMaxTypes.get(new VarVersionPair(expr.id, -1)); if (maxType != null && maxType.equals(VarType.VARTYPE_CHAR)) { ((ConstExprent)expr).setConstType(maxType); } @@ -286,15 +286,15 @@ public class VarVersionsProcessor { this.mapOriginalVarIndices = mapOriginalVarIndices; } - public VarType getVarType(VarVersionPaar pair) { + public VarType getVarType(VarVersionPair pair) { return typeProcessor == null ? null : typeProcessor.getVarType(pair); } - public void setVarType(VarVersionPaar pair, VarType type) { + public void setVarType(VarVersionPair pair, VarType type) { typeProcessor.setVarType(pair, type); } - public int getVarFinal(VarVersionPaar pair) { + public int getVarFinal(VarVersionPair pair) { int ret = VarTypeProcessor.VAR_FINAL; if (typeProcessor != null) { Integer fin = typeProcessor.getMapFinalVars().get(pair); @@ -304,7 +304,7 @@ public class VarVersionsProcessor { return ret; } - public void setVarFinal(VarVersionPaar pair, int finalType) { + public void setVarFinal(VarVersionPair pair, int finalType) { typeProcessor.getMapFinalVars().put(pair, finalType); }