java-decompiler: (var, version) class renamed and made immutable

master
Roman Shevchenko 10 years ago
parent 82a2939271
commit 89b40fd28a
  1. 12
      src/org/jetbrains/java/decompiler/main/ClassWriter.java
  2. 4
      src/org/jetbrains/java/decompiler/main/ClassesProcessor.java
  3. 4
      src/org/jetbrains/java/decompiler/main/EnumProcessor.java
  4. 6
      src/org/jetbrains/java/decompiler/main/InitializerProcessor.java
  5. 6
      src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java
  6. 4
      src/org/jetbrains/java/decompiler/main/rels/MethodWrapper.java
  7. 52
      src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java
  8. 6
      src/org/jetbrains/java/decompiler/main/rels/NestedMemberAccess.java
  9. 8
      src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java
  10. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/SecondaryFunctionsHelper.java
  11. 24
      src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java
  12. 82
      src/org/jetbrains/java/decompiler/modules/decompiler/StackVarsProcessor.java
  13. 8
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java
  14. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/FieldExprent.java
  15. 10
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java
  16. 16
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java
  17. 8
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java
  18. 18
      src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAConstructorSparseEx.java
  19. 72
      src/org/jetbrains/java/decompiler/modules/decompiler/sforms/SSAUConstructorSparseEx.java
  20. 12
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarDefinitionHelper.java
  21. 36
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java
  22. 36
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarTypeProcessor.java
  23. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionNode.java
  24. 16
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionPair.java
  25. 6
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsGraph.java
  26. 72
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsProcessor.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.exps.NewExprent;
import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; 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.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.modules.renamer.PoolInterceptor;
import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructClass;
import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.struct.StructField;
@ -130,7 +130,7 @@ public class ClassWriter {
buffer.append(", "); 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 buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors
firstParameter = false; firstParameter = false;
@ -506,7 +506,7 @@ public class ClassWriter {
buffer.append(typeName); buffer.append(typeName);
buffer.append(" "); 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 buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors
firstParameter = false; firstParameter = false;
@ -671,7 +671,7 @@ public class ClassWriter {
buffer.append('('); buffer.append('(');
// parameters // parameters
List<VarVersionPaar> signFields = methodWrapper.signatureFields; List<VarVersionPair> signFields = methodWrapper.signatureFields;
int lastVisibleParameterIndex = -1; int lastVisibleParameterIndex = -1;
for (int i = 0; i < md.params.length; i++) { for (int i = 0; i < md.params.length; i++) {
@ -692,7 +692,7 @@ public class ClassWriter {
appendParameterAnnotations(buffer, mt, paramCount); 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 "); buffer.append("final ");
} }
@ -738,7 +738,7 @@ public class ClassWriter {
} }
buffer.append(' '); 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 buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors
firstParameter = false; firstParameter = false;

@ -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.NestedClassProcessor;
import org.jetbrains.java.decompiler.main.rels.NestedMemberAccess; import org.jetbrains.java.decompiler.main.rels.NestedMemberAccess;
import org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent; 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.StructClass;
import org.jetbrains.java.decompiler.struct.StructContext; import org.jetbrains.java.decompiler.struct.StructContext;
import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.StructMethod;
@ -357,7 +357,7 @@ public class ClassesProcessor {
public ClassWrapper wrapper; public ClassWrapper wrapper;
public String enclosingMethod; public String enclosingMethod;
public InvocationExprent superInvocation; public InvocationExprent superInvocation;
public Map<String, VarVersionPaar> mapFieldsToVars = new HashMap<String, VarVersionPaar>(); public Map<String, VarVersionPair> mapFieldsToVars = new HashMap<String, VarVersionPair>();
public VarType anonymousClassType; public VarType anonymousClassType;
public List<ClassNode> nested = new ArrayList<ClassNode>(); public List<ClassNode> nested = new ArrayList<ClassNode>();
public Set<String> enclosingClasses = new HashSet<String>(); public Set<String> enclosingClasses = new HashSet<String>();

@ -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.InvocationExprent;
import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; 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.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.StructClass;
import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.struct.StructField;
import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.StructMethod;
@ -101,7 +101,7 @@ public class EnumProcessor {
if (inv.getFunctype() == InvocationExprent.TYP_INIT) { if (inv.getFunctype() == InvocationExprent.TYP_INIT) {
if (inv.getInstance().type == Exprent.EXPRENT_VAR) { if (inv.getInstance().type == Exprent.EXPRENT_VAR) {
VarExprent instvar = (VarExprent)inv.getInstance(); VarExprent instvar = (VarExprent)inv.getInstance();
VarVersionPaar varpaar = new VarVersionPaar(instvar); VarVersionPair varpaar = new VarVersionPair(instvar);
String classname = meth.varproc.getThisVars().get(varpaar); String classname = meth.varproc.getThisVars().get(varpaar);

@ -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.exps.*;
import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; 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.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.StructClass;
import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.struct.StructField;
import org.jetbrains.java.decompiler.util.InterpreterUtil; import org.jetbrains.java.decompiler.util.InterpreterUtil;
@ -260,7 +260,7 @@ public class InitializerProcessor {
for (Exprent expr : lst) { for (Exprent expr : lst) {
switch (expr.type) { switch (expr.type) {
case Exprent.EXPRENT_VAR: case Exprent.EXPRENT_VAR:
VarVersionPaar varpaar = new VarVersionPaar((VarExprent)expr); VarVersionPair varpaar = new VarVersionPair((VarExprent)expr);
if (!meth.varproc.getExternalVars().contains(varpaar)) { if (!meth.varproc.getExternalVars().contains(varpaar)) {
String varname = meth.varproc.getVarName(varpaar); String varname = meth.varproc.getVarName(varpaar);
@ -306,7 +306,7 @@ public class InitializerProcessor {
if (inv.getFunctype() == InvocationExprent.TYP_INIT) { if (inv.getFunctype() == InvocationExprent.TYP_INIT) {
if (inv.getInstance().type == Exprent.EXPRENT_VAR) { if (inv.getInstance().type == Exprent.EXPRENT_VAR) {
VarExprent instvar = (VarExprent)inv.getInstance(); VarExprent instvar = (VarExprent)inv.getInstance();
VarVersionPaar varpaar = new VarVersionPaar(instvar); VarVersionPair varpaar = new VarVersionPair(instvar);
String classname = meth.varproc.getThisVars().get(varpaar); String classname = meth.varproc.getThisVars().get(varpaar);

@ -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.exps.Exprent;
import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; 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.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.StructClass;
import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.struct.StructField;
import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.StructMethod;
@ -124,14 +124,14 @@ public class ClassWrapper {
int paramcount = 0; int paramcount = 0;
if (thisvar) { if (thisvar) {
varproc.getThisVars().put(new VarVersionPaar(0, 0), classStruct.qualifiedName); varproc.getThisVars().put(new VarVersionPair(0, 0), classStruct.qualifiedName);
paramcount = 1; paramcount = 1;
} }
paramcount += md.params.length; paramcount += md.params.length;
int varindex = 0; int varindex = 0;
for (int i = 0; i < paramcount; i++) { 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 (thisvar) {
if (i == 0) { if (i == 0) {

@ -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.sforms.FlattenStatementsHelper;
import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; 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.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.StructMethod;
import java.util.HashSet; import java.util.HashSet;
@ -39,7 +39,7 @@ public class MethodWrapper {
public DirectGraph graph; public DirectGraph graph;
public List<VarVersionPaar> signatureFields; public List<VarVersionPair> signatureFields;
public boolean decompiledWithErrors; public boolean decompiledWithErrors;

@ -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.RootStatement;
import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; 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.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.StructClass;
import org.jetbrains.java.decompiler.struct.StructField; import org.jetbrains.java.decompiler.struct.StructField;
import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.StructMethod;
@ -127,14 +127,14 @@ public class NestedClassProcessor {
// this pointer // this pointer
if (!is_static_lambda_content && DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS)) { 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.getThisVars().put(new VarVersionPair(0, 0), parent_class_name);
meth.varproc.setVarName(new VarVersionPaar(0, 0), parent.simpleName + ".this"); meth.varproc.setVarName(new VarVersionPair(0, 0), parent.simpleName + ".this");
} }
// local variables // local variables
DirectGraph graph = encmeth.getOrBuildGraph(); DirectGraph graph = encmeth.getOrBuildGraph();
final HashMap<VarVersionPaar, String> mapNewNames = new HashMap<VarVersionPaar, String>(); final HashMap<VarVersionPair, String> mapNewNames = new HashMap<VarVersionPair, String>();
graph.iterateExprents(new DirectGraph.ExprentIterator() { graph.iterateExprents(new DirectGraph.ExprentIterator() {
public int processExprent(Exprent exprent) { public int processExprent(Exprent exprent) {
@ -158,11 +158,11 @@ public class NestedClassProcessor {
Exprent param = inv_dynamic.getLstParameters().get(param_index + i); Exprent param = inv_dynamic.getLstParameters().get(param_index + i);
if (param.type == Exprent.EXPRENT_VAR) { 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); String enc_varname = encmeth.varproc.getVarName(enc_varpaar);
//meth.varproc.setVarName(new VarVersionPaar(varindex, 0), enc_varname); //meth.varproc.setVarName(new VarVersionPair(varindex, 0), enc_varname);
mapNewNames.put(new VarVersionPaar(varindex, 0), enc_varname); mapNewNames.put(new VarVersionPair(varindex, 0), enc_varname);
} }
varindex += md_content.params[i].stackSize; varindex += md_content.params[i].stackSize;
@ -182,7 +182,7 @@ public class NestedClassProcessor {
meth.varproc.refreshVarNames(new VarNamesCollector(setNewOuterNames)); meth.varproc.refreshVarNames(new VarNamesCollector(setNewOuterNames));
meth.setOuterVarNames.addAll(setNewOuterNames); meth.setOuterVarNames.addAll(setNewOuterNames);
for (Entry<VarVersionPaar, String> entr : mapNewNames.entrySet()) { for (Entry<VarVersionPair, String> entr : mapNewNames.entrySet()) {
meth.varproc.setVarName(entr.getKey(), entr.getValue()); meth.varproc.setVarName(entr.getKey(), entr.getValue());
} }
} }
@ -327,7 +327,7 @@ public class NestedClassProcessor {
VarFieldPair pair = null; VarFieldPair pair = null;
if (param.type == Exprent.EXPRENT_VAR && mask.get(i) != 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. // FIXME: final flags of variables are wrong! Correct the entire final functionality.
// if(meth.varproc.getVarFinal(varpaar) != VarTypeProcessor.VAR_NON_FINAL) { // if(meth.varproc.getVarFinal(varpaar) != VarTypeProcessor.VAR_NON_FINAL) {
@ -424,7 +424,7 @@ public class NestedClassProcessor {
mergeListSignatures(entmt.getValue(), intrPairMask, false); mergeListSignatures(entmt.getValue(), intrPairMask, false);
MethodWrapper meth = nestedNode.wrapper.getMethodWrapper("<init>", entmt.getKey()); MethodWrapper meth = nestedNode.wrapper.getMethodWrapper("<init>", entmt.getKey());
meth.signatureFields = new ArrayList<VarVersionPaar>(); meth.signatureFields = new ArrayList<VarVersionPair>();
for (VarFieldPair pair : entmt.getValue()) { for (VarFieldPair pair : entmt.getValue()) {
meth.signatureFields.add(pair == null ? null : pair.varpaar); meth.signatureFields.add(pair == null ? null : pair.varpaar);
@ -444,19 +444,19 @@ public class NestedClassProcessor {
if (meth.root != null) { // neither abstract nor native if (meth.root != null) { // neither abstract nor native
// local var names // local var names
HashMap<VarVersionPaar, String> mapNewNames = new HashMap<VarVersionPaar, String>(); HashMap<VarVersionPair, String> mapNewNames = new HashMap<VarVersionPair, String>();
// local var types // local var types
HashMap<VarVersionPaar, VarType> mapNewTypes = new HashMap<VarVersionPaar, VarType>(); HashMap<VarVersionPair, VarType> mapNewTypes = new HashMap<VarVersionPair, VarType>();
final HashMap<Integer, VarVersionPaar> mapParamsToNewVars = new HashMap<Integer, VarVersionPaar>(); final HashMap<Integer, VarVersionPair> mapParamsToNewVars = new HashMap<Integer, VarVersionPair>();
if (meth.signatureFields != null) { if (meth.signatureFields != null) {
int index = 0; int index = 0;
int varindex = 1; int varindex = 1;
MethodDescriptor md = MethodDescriptor.parseDescriptor(meth.methodStruct.getDescriptor()); MethodDescriptor md = MethodDescriptor.parseDescriptor(meth.methodStruct.getDescriptor());
for (VarVersionPaar paar : meth.signatureFields) { for (VarVersionPair paar : meth.signatureFields) {
if (paar != null) { 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); mapParamsToNewVars.put(varindex, newvar);
@ -489,12 +489,12 @@ public class NestedClassProcessor {
} }
// new vars // new vars
final HashMap<String, VarVersionPaar> mapFieldsToNewVars = new HashMap<String, VarVersionPaar>(); final HashMap<String, VarVersionPair> mapFieldsToNewVars = new HashMap<String, VarVersionPair>();
for (ClassNode clnode = child; clnode != null; clnode = clnode.parent) { for (ClassNode clnode = child; clnode != null; clnode = clnode.parent) {
for (Entry<String, VarVersionPaar> entr : clnode.mapFieldsToVars.entrySet()) { for (Entry<String, VarVersionPair> entr : clnode.mapFieldsToVars.entrySet()) {
VarVersionPaar newvar = new VarVersionPaar(meth.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER), 0); VarVersionPair newvar = new VarVersionPair(meth.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER), 0);
mapFieldsToNewVars.put(InterpreterUtil.makeUniqueKey(clnode.classStruct.qualifiedName, entr.getKey()), newvar); mapFieldsToNewVars.put(InterpreterUtil.makeUniqueKey(clnode.classStruct.qualifiedName, entr.getKey()), newvar);
@ -539,8 +539,8 @@ public class NestedClassProcessor {
meth.varproc.refreshVarNames(new VarNamesCollector(setNewOuterNames)); meth.varproc.refreshVarNames(new VarNamesCollector(setNewOuterNames));
meth.setOuterVarNames.addAll(setNewOuterNames); meth.setOuterVarNames.addAll(setNewOuterNames);
for (Entry<VarVersionPaar, String> entr : mapNewNames.entrySet()) { for (Entry<VarVersionPair, String> entr : mapNewNames.entrySet()) {
VarVersionPaar varpaar = entr.getKey(); VarVersionPair varpaar = entr.getKey();
VarType vartype = mapNewTypes.get(varpaar); VarType vartype = mapNewTypes.get(varpaar);
meth.varproc.setVarName(varpaar, entr.getValue()); meth.varproc.setVarName(varpaar, entr.getValue());
@ -593,7 +593,7 @@ public class NestedClassProcessor {
if (exprent.type == Exprent.EXPRENT_VAR) { if (exprent.type == Exprent.EXPRENT_VAR) {
int varindex = ((VarExprent)exprent).getIndex(); int varindex = ((VarExprent)exprent).getIndex();
if (mapParamsToNewVars.containsKey(varindex)) { if (mapParamsToNewVars.containsKey(varindex)) {
VarVersionPaar newvar = mapParamsToNewVars.get(varindex); VarVersionPair newvar = mapParamsToNewVars.get(varindex);
meth.varproc.getExternalVars().add(newvar); meth.varproc.getExternalVars().add(newvar);
return new VarExprent(newvar.var, meth.varproc.getVarType(newvar), meth.varproc); return new VarExprent(newvar.var, meth.varproc.getVarType(newvar), meth.varproc);
} }
@ -607,7 +607,7 @@ public class NestedClassProcessor {
if (mapFieldsToNewVars.containsKey(keyField)) { if (mapFieldsToNewVars.containsKey(keyField)) {
//if(fexpr.getClassname().equals(child.classStruct.qualifiedName) && //if(fexpr.getClassname().equals(child.classStruct.qualifiedName) &&
// mapFieldsToNewVars.containsKey(keyField)) { // mapFieldsToNewVars.containsKey(keyField)) {
VarVersionPaar newvar = mapFieldsToNewVars.get(keyField); VarVersionPair newvar = mapFieldsToNewVars.get(keyField);
meth.varproc.getExternalVars().add(newvar); meth.varproc.getExternalVars().add(newvar);
return new VarExprent(newvar.var, meth.varproc.getVarType(newvar), meth.varproc); return new VarExprent(newvar.var, meth.varproc.getVarType(newvar), meth.varproc);
} }
@ -655,7 +655,7 @@ public class NestedClassProcessor {
int varindex = 1; int varindex = 1;
for (int i = 0; i < md.params.length; i++) { // no static methods allowed for (int i = 0; i < md.params.length; i++) { // no static methods allowed
String keyField = getEnclosingVarField(cl, meth, graph, varindex); 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; varindex += md.params[i].stackSize;
} }
mapMasks.put(mt.getDescriptor(), fields); mapMasks.put(mt.getDescriptor(), fields);
@ -671,7 +671,7 @@ public class NestedClassProcessor {
String field = ""; String field = "";
// parameter variable final // 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; return null;
} }
@ -1005,9 +1005,9 @@ public class NestedClassProcessor {
private static class VarFieldPair { private static class VarFieldPair {
public String keyfield = ""; 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.keyfield = field;
this.varpaar = varpaar; this.varpaar = varpaar;
} }

@ -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.exps.*;
import org.jetbrains.java.decompiler.modules.decompiler.sforms.DirectGraph; 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.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.StructMethod;
import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor;
import org.jetbrains.java.decompiler.util.InterpreterUtil; import org.jetbrains.java.decompiler.util.InterpreterUtil;
@ -364,7 +364,7 @@ public class NestedMemberAccess {
ExitExprent exsource = (ExitExprent)source; ExitExprent exsource = (ExitExprent)source;
if (exsource.getValue().type == Exprent.EXPRENT_VAR) { // qualified this if (exsource.getValue().type == Exprent.EXPRENT_VAR) { // qualified this
VarExprent var = (VarExprent)exsource.getValue(); 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)) { if (!methdest.setOuterVarNames.contains(varname)) {
VarNamesCollector vnc = new VarNamesCollector(); VarNamesCollector vnc = new VarNamesCollector();
@ -376,7 +376,7 @@ public class NestedMemberAccess {
int index = methdest.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER); int index = methdest.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER);
VarExprent ret = new VarExprent(index, var.getVarType(), methdest.varproc); 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; retexprent = ret;
} }

@ -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.RootStatement;
import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; 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.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.StructMethod;
import org.jetbrains.java.decompiler.struct.gen.VarType; import org.jetbrains.java.decompiler.struct.gen.VarType;
import org.jetbrains.java.decompiler.util.InterpreterUtil; import org.jetbrains.java.decompiler.util.InterpreterUtil;
@ -217,7 +217,7 @@ public class FinallyProcessor {
List<Exprent> lstExprents = firstBlockStatement.getExprents(); List<Exprent> 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(); FlattenStatementsHelper flatthelper = new FlattenStatementsHelper();
DirectGraph dgraph = flatthelper.buildDirectGraph(root); DirectGraph dgraph = flatthelper.buildDirectGraph(root);
@ -259,7 +259,7 @@ public class FinallyProcessor {
boolean found = false; boolean found = false;
for (Exprent expr : lst) { 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; found = true;
break; break;
} }
@ -287,7 +287,7 @@ public class FinallyProcessor {
if (exprent.type == Exprent.EXPRENT_ASSIGNMENT) { if (exprent.type == Exprent.EXPRENT_ASSIGNMENT) {
AssignmentExprent assexpr = (AssignmentExprent)exprent; AssignmentExprent assexpr = (AssignmentExprent)exprent;
if (assexpr.getRight().type == Exprent.EXPRENT_VAR && if (assexpr.getRight().type == Exprent.EXPRENT_VAR &&
new VarVersionPaar((VarExprent)assexpr.getRight()).equals(varpaar)) { new VarVersionPair((VarExprent)assexpr.getRight()).equals(varpaar)) {
Exprent next = null; Exprent next = null;
if (i == node.exprents.size() - 1) { if (i == node.exprents.size() - 1) {

@ -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.IfStatement;
import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; 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.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 org.jetbrains.java.decompiler.struct.gen.VarType;
import java.util.ArrayList; import java.util.ArrayList;
@ -315,7 +315,7 @@ public class SecondaryFunctionsHelper {
lstOperands.get(1)), null), null), lstOperands.get(1)), null), null),
ConstExprent.getZeroConstant(type.type)), 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( return new FunctionExprent(FunctionExprent.FUNCTION_IIF, Arrays.asList(
head, new ConstExprent(VarType.VARTYPE_INT, new Integer(0), null), iff), fexpr.bytecode); head, new ConstExprent(VarType.VARTYPE_INT, new Integer(0), null), iff), fexpr.bytecode);

@ -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.sforms.SSAConstructorSparseEx;
import org.jetbrains.java.decompiler.modules.decompiler.stats.IfStatement; 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.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.StructClass;
import org.jetbrains.java.decompiler.struct.gen.VarType; import org.jetbrains.java.decompiler.struct.gen.VarType;
import org.jetbrains.java.decompiler.util.FastSparseSetFactory.FastSparseSet; import org.jetbrains.java.decompiler.util.FastSparseSetFactory.FastSparseSet;
@ -538,12 +538,12 @@ public class SimplifyExprentsHelper {
// //
// NewExprent newexpr = (NewExprent)as.getRight(); // NewExprent newexpr = (NewExprent)as.getRight();
// VarType newtype = newexpr.getNewType(); // 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 && // if(newtype.type == CodeConstants.TYPE_OBJECT && newtype.arrayDim == 0 &&
// newexpr.getConstructor() == null) { // newexpr.getConstructor() == null) {
// //
// Set<VarVersionPaar> setChangedVars = new HashSet<VarVersionPaar>(); // Set<VarVersionPair> setChangedVars = new HashSet<VarVersionPair>();
// //
// for(int i = index + 1; i < list.size(); i++) { // for(int i = index + 1; i < list.size(); i++) {
// Exprent remote = list.get(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 // if(in.getFuncType() == InvocationExprent.TYP_INIT && in.getInstance().type == Exprent.EXPRENT_VAR
// && as.getLeft().equals(in.getInstance())) { // && as.getLeft().equals(in.getInstance())) {
// //
// Set<VarVersionPaar> setVars = remote.getAllVariables(); // Set<VarVersionPair> setVars = remote.getAllVariables();
// setVars.remove(leftPaar); // setVars.remove(leftPaar);
// setVars.retainAll(setChangedVars); // setVars.retainAll(setChangedVars);
// //
@ -581,7 +581,7 @@ public class SimplifyExprentsHelper {
// AssignmentExprent asremote = (AssignmentExprent)remote; // AssignmentExprent asremote = (AssignmentExprent)remote;
// if(asremote.getLeft().type == Exprent.EXPRENT_VAR && // if(asremote.getLeft().type == Exprent.EXPRENT_VAR &&
// asremote.getRight().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; // isTempAssignment = true;
// } // }
// //
@ -592,7 +592,7 @@ public class SimplifyExprentsHelper {
//// List<Exprent> lstRightExprents = asremote.getRight().getAllExprents(true); //// List<Exprent> lstRightExprents = asremote.getRight().getAllExprents(true);
//// lstRightExprents.add(asremote.getRight()); //// lstRightExprents.add(asremote.getRight());
//// ////
//// Set<VarVersionPaar> setTempChangedVars = new HashSet<VarVersionPaar>(); //// Set<VarVersionPair> setTempChangedVars = new HashSet<VarVersionPair>();
//// boolean isTemp = true; //// boolean isTemp = true;
//// ////
//// for(Exprent expr : lstRightExprents) { //// for(Exprent expr : lstRightExprents) {
@ -600,7 +600,7 @@ public class SimplifyExprentsHelper {
//// isTemp = false; //// isTemp = false;
//// break; //// break;
//// } else if(expr.type == Exprent.EXPRENT_VAR) { //// } 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 //// if(fexpr.getFuncType() == FunctionExprent.FUNCTION_IPP || fexpr.getFuncType() == FunctionExprent.FUNCTION_IMM
//// || fexpr.getFuncType() == FunctionExprent.FUNCTION_PPI || fexpr.getFuncType() == FunctionExprent.FUNCTION_MMI) { //// || fexpr.getFuncType() == FunctionExprent.FUNCTION_PPI || fexpr.getFuncType() == FunctionExprent.FUNCTION_MMI) {
//// if(fexpr.getLstOperands().get(0).type == Exprent.EXPRENT_VAR) { //// 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; //// isTempAssignment = true;
//// } //// }
//// } //// }
// } // }
// //
// if(!isTempAssignment) { // if(!isTempAssignment) {
// Set<VarVersionPaar> setVars = remote.getAllVariables(); // Set<VarVersionPair> setVars = remote.getAllVariables();
// if(setVars.contains(leftPaar)) { // if(setVars.contains(leftPaar)) {
// return false; // return false;
// } else { // } else {
@ -648,7 +648,7 @@ public class SimplifyExprentsHelper {
NewExprent newexpr = (NewExprent)as.getRight(); NewExprent newexpr = (NewExprent)as.getRight();
VarType newtype = newexpr.getNewType(); 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) { if (newtype.type == CodeConstants.TYPE_OBJECT && newtype.arrayDim == 0 && newexpr.getConstructor() == null) {
@ -673,7 +673,7 @@ public class SimplifyExprentsHelper {
} }
// check for variable in use // check for variable in use
Set<VarVersionPaar> setVars = remote.getAllVariables(); Set<VarVersionPair> setVars = remote.getAllVariables();
if (setVars.contains(leftPaar)) { // variable used somewhere in between -> exit, need a better reduced code if (setVars.contains(leftPaar)) { // variable used somewhere in between -> exit, need a better reduced code
return false; return false;
} }
@ -776,7 +776,7 @@ public class SimplifyExprentsHelper {
boolean found = false; boolean found = false;
for (Entry<VarVersionPaar, FastSparseSet<Integer>> ent : ssa.getPhi().entrySet()) { for (Entry<VarVersionPair, FastSparseSet<Integer>> ent : ssa.getPhi().entrySet()) {
if (ent.getKey().var == ifvar.getIndex()) { if (ent.getKey().var == ifvar.getIndex()) {
if (ent.getValue().contains(ifvar.getVersion()) && ent.getValue().contains(elsevar.getVersion())) { if (ent.getValue().contains(ifvar.getVersion()) && ent.getValue().contains(elsevar.getVersion())) {
found = true; found = true;

@ -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.stats.Statement;
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionEdge; 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.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.modules.decompiler.vars.VarVersionsGraph;
import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.StructClass;
import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.StructMethod;
@ -151,15 +151,15 @@ public class StackVarsProcessor {
HashSet<DirectNode> setVisited = new HashSet<DirectNode>(); HashSet<DirectNode> setVisited = new HashSet<DirectNode>();
LinkedList<DirectNode> stack = new LinkedList<DirectNode>(); LinkedList<DirectNode> stack = new LinkedList<DirectNode>();
LinkedList<HashMap<VarVersionPaar, Exprent>> stackMaps = new LinkedList<HashMap<VarVersionPaar, Exprent>>(); LinkedList<HashMap<VarVersionPair, Exprent>> stackMaps = new LinkedList<HashMap<VarVersionPair, Exprent>>();
stack.add(dgraph.first); stack.add(dgraph.first);
stackMaps.add(new HashMap<VarVersionPaar, Exprent>()); stackMaps.add(new HashMap<VarVersionPair, Exprent>());
while (!stack.isEmpty()) { while (!stack.isEmpty()) {
DirectNode nd = stack.removeFirst(); DirectNode nd = stack.removeFirst();
HashMap<VarVersionPaar, Exprent> mapVarValues = stackMaps.removeFirst(); HashMap<VarVersionPair, Exprent> mapVarValues = stackMaps.removeFirst();
if (setVisited.contains(nd)) { if (setVisited.contains(nd)) {
continue; continue;
@ -211,7 +211,7 @@ public class StackVarsProcessor {
for (DirectNode ndx : nd.succs) { for (DirectNode ndx : nd.succs) {
stack.add(ndx); stack.add(ndx);
stackMaps.add(new HashMap<VarVersionPaar, Exprent>(mapVarValues)); stackMaps.add(new HashMap<VarVersionPair, Exprent>(mapVarValues));
} }
// make sure the 3 special exprent lists in a loop (init, condition, increment) are not empty // 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<VarVersionPaar, Exprent> mapVarValues, SSAUConstructorSparseEx ssau) { private static Exprent isReplaceableVar(Exprent exprent, HashMap<VarVersionPair, Exprent> mapVarValues, SSAUConstructorSparseEx ssau) {
Exprent dest = null; Exprent dest = null;
if (exprent.type == Exprent.EXPRENT_VAR) { if (exprent.type == Exprent.EXPRENT_VAR) {
VarExprent var = (VarExprent)exprent; VarExprent var = (VarExprent)exprent;
dest = mapVarValues.get(new VarVersionPaar(var)); dest = mapVarValues.get(new VarVersionPair(var));
} }
return dest; return dest;
@ -253,10 +253,10 @@ public class StackVarsProcessor {
parent.replaceExprent(var, dest); parent.replaceExprent(var, dest);
// live sets // live sets
SFormsFastMapDirect livemap = ssau.getLiveVarVersionsMap(new VarVersionPaar(var)); SFormsFastMapDirect livemap = ssau.getLiveVarVersionsMap(new VarVersionPair(var));
HashSet<VarVersionPaar> setVars = getAllVersions(dest); HashSet<VarVersionPair> setVars = getAllVersions(dest);
for (VarVersionPaar varpaar : setVars) { for (VarVersionPair varpaar : setVars) {
VarVersionNode node = ssau.getSsuversions().nodes.getWithKey(varpaar); VarVersionNode node = ssau.getSsuversions().nodes.getWithKey(varpaar);
for (Iterator<Entry<Integer, FastSparseSet<Integer>>> itent = node.live.entryList().iterator(); itent.hasNext(); ) { for (Iterator<Entry<Integer, FastSparseSet<Integer>>> itent = node.live.entryList().iterator(); itent.hasNext(); ) {
@ -279,7 +279,7 @@ public class StackVarsProcessor {
} }
} }
private int[] iterateExprent(List<Exprent> lstExprents, int index, Exprent next, HashMap<VarVersionPaar, private int[] iterateExprent(List<Exprent> lstExprents, int index, Exprent next, HashMap<VarVersionPair,
Exprent> mapVarValues, SSAUConstructorSparseEx ssau) { Exprent> mapVarValues, SSAUConstructorSparseEx ssau) {
Exprent exprent = lstExprents.get(index); Exprent exprent = lstExprents.get(index);
@ -327,7 +327,7 @@ public class StackVarsProcessor {
return new int[]{-1, changed}; return new int[]{-1, changed};
} }
VarVersionPaar leftpaar = new VarVersionPaar(left); VarVersionPair leftpaar = new VarVersionPair(left);
List<VarVersionNode> usedVers = new ArrayList<VarVersionNode>(); List<VarVersionNode> usedVers = new ArrayList<VarVersionNode>();
boolean notdom = getUsedVersions(ssau, leftpaar, usedVers); boolean notdom = getUsedVersions(ssau, leftpaar, usedVers);
@ -368,14 +368,14 @@ public class StackVarsProcessor {
return new int[]{-1, changed}; return new int[]{-1, changed};
} }
HashMap<Integer, HashSet<VarVersionPaar>> mapVars = getAllVarVersions(leftpaar, right, ssau); HashMap<Integer, HashSet<VarVersionPair>> mapVars = getAllVarVersions(leftpaar, right, ssau);
boolean isSelfReference = mapVars.containsKey(leftpaar.var); boolean isSelfReference = mapVars.containsKey(leftpaar.var);
if (isSelfReference && notdom) { if (isSelfReference && notdom) {
return new int[]{-1, changed}; return new int[]{-1, changed};
} }
HashSet<VarVersionPaar> setNextVars = next == null ? null : getAllVersions(next); HashSet<VarVersionPair> setNextVars = next == null ? null : getAllVersions(next);
// FIXME: fix the entire method! // FIXME: fix the entire method!
if (right.type != Exprent.EXPRENT_CONST && if (right.type != Exprent.EXPRENT_CONST &&
@ -383,7 +383,7 @@ public class StackVarsProcessor {
setNextVars != null && setNextVars != null &&
mapVars.containsKey(leftpaar.var)) { mapVars.containsKey(leftpaar.var)) {
for (VarVersionNode usedvar : usedVers) { 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}; return new int[]{-1, changed};
} }
} }
@ -395,10 +395,10 @@ public class StackVarsProcessor {
boolean verreplaced = false; boolean verreplaced = false;
HashSet<VarVersionPaar> setTempUsedVers = new HashSet<VarVersionPaar>(); HashSet<VarVersionPair> setTempUsedVers = new HashSet<VarVersionPair>();
for (VarVersionNode usedvar : usedVers) { 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) && if (isVersionToBeReplaced(usedver, mapVars, ssau, leftpaar) &&
(right.type == Exprent.EXPRENT_CONST || right.type == Exprent.EXPRENT_VAR || right.type == Exprent.EXPRENT_FIELD (right.type == Exprent.EXPRENT_CONST || right.type == Exprent.EXPRENT_VAR || right.type == Exprent.EXPRENT_FIELD
|| setNextVars == null || setNextVars.contains(usedver))) { || setNextVars == null || setNextVars.contains(usedver))) {
@ -415,7 +415,7 @@ public class StackVarsProcessor {
return new int[]{-1, changed}; return new int[]{-1, changed};
} }
else { else {
for (VarVersionPaar usedver : setTempUsedVers) { for (VarVersionPair usedver : setTempUsedVers) {
Exprent copy = right.copy(); Exprent copy = right.copy();
if (right.type == Exprent.EXPRENT_FIELD && ssau.getMapFieldVars().containsKey(right.id)) { if (right.type == Exprent.EXPRENT_FIELD && ssau.getMapFieldVars().containsKey(right.id)) {
ssau.getMapFieldVars().put(copy.id, ssau.getMapFieldVars().get(right.id)); ssau.getMapFieldVars().put(copy.id, ssau.getMapFieldVars().get(right.id));
@ -438,9 +438,9 @@ public class StackVarsProcessor {
} }
} }
private static HashSet<VarVersionPaar> getAllVersions(Exprent exprent) { private static HashSet<VarVersionPair> getAllVersions(Exprent exprent) {
HashSet<VarVersionPaar> res = new HashSet<VarVersionPaar>(); HashSet<VarVersionPair> res = new HashSet<VarVersionPair>();
List<Exprent> listTemp = new ArrayList<Exprent>(exprent.getAllExprents(true)); List<Exprent> listTemp = new ArrayList<Exprent>(exprent.getAllExprents(true));
listTemp.add(exprent); listTemp.add(exprent);
@ -448,7 +448,7 @@ public class StackVarsProcessor {
for (Exprent expr : listTemp) { for (Exprent expr : listTemp) {
if (expr.type == Exprent.EXPRENT_VAR) { if (expr.type == Exprent.EXPRENT_VAR) {
VarExprent var = (VarExprent)expr; 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, private static Object[] iterateChildExprent(Exprent exprent,
Exprent parent, Exprent parent,
Exprent next, Exprent next,
HashMap<VarVersionPaar, Exprent> mapVarValues, HashMap<VarVersionPair, Exprent> mapVarValues,
SSAUConstructorSparseEx ssau) { SSAUConstructorSparseEx ssau) {
boolean changed = false; boolean changed = false;
@ -521,7 +521,7 @@ public class StackVarsProcessor {
return new Object[]{null, changed, false}; return new Object[]{null, changed, false};
} }
VarVersionPaar leftpaar = new VarVersionPaar(left); VarVersionPair leftpaar = new VarVersionPair(left);
List<VarVersionNode> usedVers = new ArrayList<VarVersionNode>(); List<VarVersionNode> usedVers = new ArrayList<VarVersionNode>();
boolean notdom = getUsedVersions(ssau, leftpaar, usedVers); boolean notdom = getUsedVersions(ssau, leftpaar, usedVers);
@ -541,7 +541,7 @@ public class StackVarsProcessor {
return new Object[]{null, changed, false}; return new Object[]{null, changed, false};
} }
HashMap<Integer, HashSet<VarVersionPaar>> mapVars = getAllVarVersions(leftpaar, right, ssau); HashMap<Integer, HashSet<VarVersionPair>> mapVars = getAllVarVersions(leftpaar, right, ssau);
if (mapVars.containsKey(leftpaar.var) && notdom) { if (mapVars.containsKey(leftpaar.var) && notdom) {
return new Object[]{null, changed, false}; return new Object[]{null, changed, false};
@ -550,17 +550,17 @@ public class StackVarsProcessor {
mapVars.remove(leftpaar.var); mapVars.remove(leftpaar.var);
HashSet<VarVersionPaar> setAllowedVars = getAllVersions(parent); HashSet<VarVersionPair> setAllowedVars = getAllVersions(parent);
if (next != null) { if (next != null) {
setAllowedVars.addAll(getAllVersions(next)); setAllowedVars.addAll(getAllVersions(next));
} }
boolean vernotreplaced = false; boolean vernotreplaced = false;
HashSet<VarVersionPaar> setTempUsedVers = new HashSet<VarVersionPaar>(); HashSet<VarVersionPair> setTempUsedVers = new HashSet<VarVersionPair>();
for (VarVersionNode usedvar : usedVers) { 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) && if (isVersionToBeReplaced(usedver, mapVars, ssau, leftpaar) &&
(right.type == Exprent.EXPRENT_VAR || setAllowedVars.contains(usedver))) { (right.type == Exprent.EXPRENT_VAR || setAllowedVars.contains(usedver))) {
@ -573,7 +573,7 @@ public class StackVarsProcessor {
if (!notdom && !vernotreplaced) { if (!notdom && !vernotreplaced) {
for (VarVersionPaar usedver : setTempUsedVers) { for (VarVersionPair usedver : setTempUsedVers) {
Exprent copy = right.copy(); Exprent copy = right.copy();
if (right.type == Exprent.EXPRENT_FIELD && ssau.getMapFieldVars().containsKey(right.id)) { if (right.type == Exprent.EXPRENT_FIELD && ssau.getMapFieldVars().containsKey(right.id)) {
ssau.getMapFieldVars().put(copy.id, ssau.getMapFieldVars().get(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}; return new Object[]{null, changed, false};
} }
private static boolean getUsedVersions(SSAUConstructorSparseEx ssa, VarVersionPaar var, List<VarVersionNode> res) { private static boolean getUsedVersions(SSAUConstructorSparseEx ssa, VarVersionPair var, List<VarVersionNode> res) {
VarVersionsGraph ssuversions = ssa.getSsuversions(); VarVersionsGraph ssuversions = ssa.getSsuversions();
VarVersionNode varnode = ssuversions.nodes.getWithKey(var); VarVersionNode varnode = ssuversions.nodes.getWithKey(var);
@ -638,10 +638,10 @@ public class StackVarsProcessor {
return !setNotDoms.isEmpty(); return !setNotDoms.isEmpty();
} }
private static boolean isVersionToBeReplaced(VarVersionPaar usedvar, private static boolean isVersionToBeReplaced(VarVersionPair usedvar,
HashMap<Integer, HashSet<VarVersionPaar>> mapVars, HashMap<Integer, HashSet<VarVersionPair>> mapVars,
SSAUConstructorSparseEx ssau, SSAUConstructorSparseEx ssau,
VarVersionPaar leftpaar) { VarVersionPair leftpaar) {
VarVersionsGraph ssuversions = ssau.getSsuversions(); VarVersionsGraph ssuversions = ssau.getSsuversions();
@ -657,21 +657,21 @@ public class StackVarsProcessor {
return false; return false;
} }
for (Entry<Integer, HashSet<VarVersionPaar>> ent : mapVars.entrySet()) { for (Entry<Integer, HashSet<VarVersionPair>> ent : mapVars.entrySet()) {
FastSparseSet<Integer> liveverset = mapLiveVars.get(ent.getKey()); FastSparseSet<Integer> liveverset = mapLiveVars.get(ent.getKey());
if (liveverset == null) { if (liveverset == null) {
return false; return false;
} }
HashSet<VarVersionNode> domset = new HashSet<VarVersionNode>(); HashSet<VarVersionNode> domset = new HashSet<VarVersionNode>();
for (VarVersionPaar verpaar : ent.getValue()) { for (VarVersionPair verpaar : ent.getValue()) {
domset.add(ssuversions.nodes.getWithKey(verpaar)); domset.add(ssuversions.nodes.getWithKey(verpaar));
} }
boolean isdom = false; boolean isdom = false;
for (Integer livever : liveverset) { 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)) { if (ssuversions.isDominatorSet(node, domset)) {
isdom = true; isdom = true;
@ -687,11 +687,11 @@ public class StackVarsProcessor {
return true; return true;
} }
private static HashMap<Integer, HashSet<VarVersionPaar>> getAllVarVersions(VarVersionPaar leftvar, private static HashMap<Integer, HashSet<VarVersionPair>> getAllVarVersions(VarVersionPair leftvar,
Exprent exprent, Exprent exprent,
SSAUConstructorSparseEx ssau) { SSAUConstructorSparseEx ssau) {
HashMap<Integer, HashSet<VarVersionPaar>> map = new HashMap<Integer, HashSet<VarVersionPaar>>(); HashMap<Integer, HashSet<VarVersionPair>> map = new HashMap<Integer, HashSet<VarVersionPair>>();
SFormsFastMapDirect mapLiveVars = ssau.getLiveVarVersionsMap(leftvar); SFormsFastMapDirect mapLiveVars = ssau.getLiveVarVersionsMap(leftvar);
List<Exprent> lst = exprent.getAllExprents(true); List<Exprent> lst = exprent.getAllExprents(true);
@ -702,9 +702,9 @@ public class StackVarsProcessor {
int varindex = ((VarExprent)expr).getIndex(); int varindex = ((VarExprent)expr).getIndex();
if (leftvar.var != varindex) { if (leftvar.var != varindex) {
if (mapLiveVars.containsKey(varindex)) { if (mapLiveVars.containsKey(varindex)) {
HashSet<VarVersionPaar> verset = new HashSet<VarVersionPaar>(); HashSet<VarVersionPair> verset = new HashSet<VarVersionPair>();
for (Integer vers : mapLiveVars.get(varindex)) { for (Integer vers : mapLiveVars.get(varindex)) {
verset.add(new VarVersionPaar(varindex, vers.intValue())); verset.add(new VarVersionPair(varindex, vers.intValue()));
} }
map.put(varindex, verset); map.put(varindex, verset);
} }
@ -720,9 +720,9 @@ public class StackVarsProcessor {
if (ssau.getMapFieldVars().containsKey(expr.id)) { if (ssau.getMapFieldVars().containsKey(expr.id)) {
int varindex = ssau.getMapFieldVars().get(expr.id); int varindex = ssau.getMapFieldVars().get(expr.id);
if (mapLiveVars.containsKey(varindex)) { if (mapLiveVars.containsKey(varindex)) {
HashSet<VarVersionPaar> verset = new HashSet<VarVersionPaar>(); HashSet<VarVersionPair> verset = new HashSet<VarVersionPair>();
for (Integer vers : mapLiveVars.get(varindex)) { for (Integer vers : mapLiveVars.get(varindex)) {
verset.add(new VarVersionPaar(varindex, vers.intValue())); verset.add(new VarVersionPair(varindex, vers.intValue()));
} }
map.put(varindex, verset); map.put(varindex, verset);
} }

@ -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.BytecodeMappingTracer;
import org.jetbrains.java.decompiler.main.collectors.CounterContainer; 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.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 org.jetbrains.java.decompiler.struct.gen.VarType;
import java.util.*; import java.util.*;
@ -94,14 +94,14 @@ public class Exprent {
return lst; return lst;
} }
public Set<VarVersionPaar> getAllVariables() { public Set<VarVersionPair> getAllVariables() {
List<Exprent> lstAllExprents = getAllExprents(true); List<Exprent> lstAllExprents = getAllExprents(true);
lstAllExprents.add(this); lstAllExprents.add(this);
Set<VarVersionPaar> set = new HashSet<VarVersionPaar>(); Set<VarVersionPair> set = new HashSet<VarVersionPair>();
for (Exprent expr : lstAllExprents) { for (Exprent expr : lstAllExprents) {
if (expr.type == EXPRENT_VAR) { if (expr.type == EXPRENT_VAR) {
set.add(new VarVersionPaar((VarExprent)expr)); set.add(new VarVersionPair((VarExprent)expr));
} }
} }
return set; return set;

@ -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.collectors.BytecodeMappingTracer;
import org.jetbrains.java.decompiler.main.rels.MethodWrapper; import org.jetbrains.java.decompiler.main.rels.MethodWrapper;
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; 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.consts.LinkConstant;
import org.jetbrains.java.decompiler.struct.gen.FieldDescriptor; import org.jetbrains.java.decompiler.struct.gen.FieldDescriptor;
import org.jetbrains.java.decompiler.struct.gen.VarType; 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) { if (instance != null && instance.type == Exprent.EXPRENT_VAR) {
VarExprent instVar = (VarExprent)instance; VarExprent instVar = (VarExprent)instance;
VarVersionPaar pair = new VarVersionPaar(instVar); VarVersionPair pair = new VarVersionPair(instVar);
MethodWrapper currentMethod = (MethodWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER); MethodWrapper currentMethod = (MethodWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER);

@ -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.ExprProcessor;
import org.jetbrains.java.decompiler.modules.decompiler.vars.CheckTypesResult; 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.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.StructClass;
import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.StructMethod;
import org.jetbrains.java.decompiler.struct.consts.LinkConstant; 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) { if (instance != null && instance.type == Exprent.EXPRENT_VAR) {
VarExprent instvar = (VarExprent)instance; VarExprent instvar = (VarExprent)instance;
VarVersionPaar varpaar = new VarVersionPaar(instvar); VarVersionPair varpaar = new VarVersionPair(instvar);
VarProcessor vproc = instvar.getProcessor(); VarProcessor vproc = instvar.getProcessor();
if (vproc == null) { if (vproc == null) {
@ -318,7 +318,7 @@ public class InvocationExprent extends Exprent {
} }
} }
List<VarVersionPaar> sigFields = null; List<VarVersionPair> sigFields = null;
boolean isEnum = false; boolean isEnum = false;
if (functype == TYP_INIT) { if (functype == TYP_INIT) {
ClassNode newNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(classname); ClassNode newNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(classname);
@ -329,8 +329,8 @@ public class InvocationExprent extends Exprent {
} }
else { else {
if (newNode.type == ClassNode.CLASS_MEMBER && (newNode.access & CodeConstants.ACC_STATIC) == 0) { // non-static member class if (newNode.type == ClassNode.CLASS_MEMBER && (newNode.access & CodeConstants.ACC_STATIC) == 0) { // non-static member class
sigFields = new ArrayList<VarVersionPaar>(Collections.nCopies(lstParameters.size(), (VarVersionPaar)null)); sigFields = new ArrayList<VarVersionPair>(Collections.nCopies(lstParameters.size(), (VarVersionPair)null));
sigFields.set(0, new VarVersionPaar(-1, 0)); sigFields.set(0, new VarVersionPair(-1, 0));
} }
} }
isEnum = newNode.classStruct.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM); isEnum = newNode.classStruct.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM);

@ -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.main.extern.IFernflowerPreferences;
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; 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.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.StructClass;
import org.jetbrains.java.decompiler.struct.gen.VarType; import org.jetbrains.java.decompiler.struct.gen.VarType;
import org.jetbrains.java.decompiler.util.InterpreterUtil; import org.jetbrains.java.decompiler.util.InterpreterUtil;
@ -174,7 +174,7 @@ public class NewExprent extends Exprent {
ClassNode newnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(invsuper.getClassname()); ClassNode newnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(invsuper.getClassname());
List<VarVersionPaar> sigFields = null; List<VarVersionPair> sigFields = null;
if (newnode != null) { // own class if (newnode != null) { // own class
if (newnode.wrapper != null) { if (newnode.wrapper != null) {
sigFields = newnode.wrapper.getMethodWrapper("<init>", invsuper.getStringDescriptor()).signatureFields; sigFields = newnode.wrapper.getMethodWrapper("<init>", invsuper.getStringDescriptor()).signatureFields;
@ -182,8 +182,8 @@ public class NewExprent extends Exprent {
else { else {
if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 && if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 &&
!constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance !constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance
sigFields = new ArrayList<VarVersionPaar>(Collections.nCopies(constructor.getLstParameters().size(), (VarVersionPaar)null)); sigFields = new ArrayList<VarVersionPair>(Collections.nCopies(constructor.getLstParameters().size(), (VarVersionPair)null));
sigFields.set(0, new VarVersionPaar(-1, 0)); sigFields.set(0, new VarVersionPair(-1, 0));
} }
} }
} }
@ -280,7 +280,7 @@ public class NewExprent extends Exprent {
ClassNode newnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(constructor.getClassname()); ClassNode newnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(constructor.getClassname());
List<VarVersionPaar> sigFields = null; List<VarVersionPair> sigFields = null;
if (newnode != null) { // own class if (newnode != null) { // own class
if (newnode.wrapper != null) { if (newnode.wrapper != null) {
sigFields = newnode.wrapper.getMethodWrapper("<init>", constructor.getStringDescriptor()).signatureFields; sigFields = newnode.wrapper.getMethodWrapper("<init>", constructor.getStringDescriptor()).signatureFields;
@ -288,8 +288,8 @@ public class NewExprent extends Exprent {
else { else {
if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 && if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 &&
!constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance !constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance
sigFields = new ArrayList<VarVersionPaar>(Collections.nCopies(lstParameters.size(), (VarVersionPaar)null)); sigFields = new ArrayList<VarVersionPair>(Collections.nCopies(lstParameters.size(), (VarVersionPair)null));
sigFields.set(0, new VarVersionPaar(-1, 0)); sigFields.set(0, new VarVersionPair(-1, 0));
} }
} }
} }
@ -399,7 +399,7 @@ public class NewExprent extends Exprent {
VarExprent varEnclosing = (VarExprent)enclosing; VarExprent varEnclosing = (VarExprent)enclosing;
StructClass current_class = ((ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_NODE)).classStruct; 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)) { if (!current_class.qualifiedName.equals(this_classname)) {
isQualifiedNew = true; isQualifiedNew = true;

@ -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.ExprProcessor;
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; 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.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.struct.gen.VarType;
import org.jetbrains.java.decompiler.util.InterpreterUtil; import org.jetbrains.java.decompiler.util.InterpreterUtil;
@ -89,11 +89,11 @@ public class VarExprent extends Exprent {
else { else {
String name = null; String name = null;
if (processor != null) { if (processor != null) {
name = processor.getVarName(new VarVersionPaar(index, version)); name = processor.getVarName(new VarVersionPair(index, version));
} }
if (definition) { 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("final ");
} }
buffer.append(ExprProcessor.getCastTypeName(getVarType())).append(" "); buffer.append(ExprProcessor.getCastTypeName(getVarType())).append(" ");
@ -126,7 +126,7 @@ public class VarExprent extends Exprent {
public VarType getVarType() { public VarType getVarType() {
VarType vt = null; VarType vt = null;
if (processor != 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)) { if (vt == null || (varType != null && varType.type != CodeConstants.TYPE_UNKNOWN)) {

@ -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.CatchStatement;
import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; 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.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.StructMethod;
import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor;
import org.jetbrains.java.decompiler.util.FastSparseSetFactory; import org.jetbrains.java.decompiler.util.FastSparseSetFactory;
@ -54,12 +54,12 @@ public class SSAConstructorSparseEx {
private HashMap<String, SFormsFastMapDirect> extraVarVersions = new HashMap<String, SFormsFastMapDirect>(); private HashMap<String, SFormsFastMapDirect> extraVarVersions = new HashMap<String, SFormsFastMapDirect>();
// (var, version), version // (var, version), version
private HashMap<VarVersionPaar, FastSparseSet<Integer>> phi = new HashMap<VarVersionPaar, FastSparseSet<Integer>>(); private HashMap<VarVersionPair, FastSparseSet<Integer>> phi = new HashMap<VarVersionPair, FastSparseSet<Integer>>();
// var, version // var, version
private HashMap<Integer, Integer> lastversion = new HashMap<Integer, Integer>(); private HashMap<Integer, Integer> lastversion = new HashMap<Integer, Integer>();
private List<VarVersionPaar> startVars = new ArrayList<VarVersionPaar>(); private List<VarVersionPair> startVars = new ArrayList<VarVersionPair>();
// set factory // set factory
private FastSparseSetFactory<Integer> factory; private FastSparseSetFactory<Integer> factory;
@ -265,7 +265,7 @@ public class SSAConstructorSparseEx {
else if (cardinality == 2) { // size > 1 else if (cardinality == 2) { // size > 1
Integer current_vers = vardest.getVersion(); 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)) { if (current_vers != 0 && phi.containsKey(currpaar)) {
setCurrentVar(varmap, varindex, current_vers); setCurrentVar(varmap, varindex, current_vers);
// update phi node // update phi node
@ -279,7 +279,7 @@ public class SSAConstructorSparseEx {
setCurrentVar(varmap, varindex, nextver); setCurrentVar(varmap, varindex, nextver);
// create new phi node // 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 } // 0 means uninitialized variable, which is impossible
} }
@ -477,7 +477,7 @@ public class SSAConstructorSparseEx {
setCurrentVar(map, varindex, version); setCurrentVar(map, varindex, version);
extraVarVersions.put(dgraph.nodes.getWithKey(flatthelper.getMapDestinationNodes().get(stat.getStats().get(i).id)[0]).id, map); 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<Integer> set = factory.spawnEmptySet(); FastSparseSet<Integer> set = factory.spawnEmptySet();
set.add(version); set.add(version);
map.put(varindex, set); map.put(varindex, set);
startVars.add(new VarVersionPaar(varindex, version)); startVars.add(new VarVersionPair(varindex, version));
if (thisvar) { if (thisvar) {
if (i == 0) { if (i == 0) {
@ -519,11 +519,11 @@ public class SSAConstructorSparseEx {
return map; return map;
} }
public HashMap<VarVersionPaar, FastSparseSet<Integer>> getPhi() { public HashMap<VarVersionPair, FastSparseSet<Integer>> getPhi() {
return phi; return phi;
} }
public List<VarVersionPaar> getStartVars() { public List<VarVersionPair> getStartVars() {
return startVars; return startVars;
} }
} }

@ -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.stats.*;
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionEdge; 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.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.modules.decompiler.vars.VarVersionsGraph;
import org.jetbrains.java.decompiler.struct.StructMethod; import org.jetbrains.java.decompiler.struct.StructMethod;
import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor;
@ -56,20 +56,20 @@ public class SSAUConstructorSparseEx {
//private HashMap<String, HashMap<Integer, FastSet<Integer>>> extraVarVersions = new HashMap<String, HashMap<Integer, FastSet<Integer>>>(); //private HashMap<String, HashMap<Integer, FastSet<Integer>>> extraVarVersions = new HashMap<String, HashMap<Integer, FastSet<Integer>>>();
// (var, version), version // (var, version), version
private HashMap<VarVersionPaar, HashSet<Integer>> phi = new HashMap<VarVersionPaar, HashSet<Integer>>(); private HashMap<VarVersionPair, HashSet<Integer>> phi = new HashMap<VarVersionPair, HashSet<Integer>>();
// var, version // var, version
private HashMap<Integer, Integer> lastversion = new HashMap<Integer, Integer>(); private HashMap<Integer, Integer> lastversion = new HashMap<Integer, Integer>();
// version, protected ranges (catch, finally) // version, protected ranges (catch, finally)
private HashMap<VarVersionPaar, Integer> mapVersionFirstRange = new HashMap<VarVersionPaar, Integer>(); private HashMap<VarVersionPair, Integer> mapVersionFirstRange = new HashMap<VarVersionPair, Integer>();
// version, version // version, version
private HashMap<VarVersionPaar, VarVersionPaar> phantomppnodes = new HashMap<VarVersionPaar, VarVersionPaar>(); // ++ and -- private HashMap<VarVersionPair, VarVersionPair> phantomppnodes = new HashMap<VarVersionPair, VarVersionPair>(); // ++ and --
// node.id, version, version // node.id, version, version
private HashMap<String, HashMap<VarVersionPaar, VarVersionPaar>> phantomexitnodes = private HashMap<String, HashMap<VarVersionPair, VarVersionPair>> phantomexitnodes =
new HashMap<String, HashMap<VarVersionPaar, VarVersionPaar>>(); // finally exits new HashMap<String, HashMap<VarVersionPair, VarVersionPair>>(); // finally exits
// versions memory dependencies // versions memory dependencies
private VarVersionsGraph ssuversions = new VarVersionsGraph(); private VarVersionsGraph ssuversions = new VarVersionsGraph();
@ -264,7 +264,7 @@ public class SSAUConstructorSparseEx {
mapFieldVars.put(expr.id, index); mapFieldVars.put(expr.id, index);
// ssu graph // ssu graph
ssuversions.createNode(new VarVersionPaar(index, 1)); ssuversions.createNode(new VarVersionPair(index, 1));
} }
setCurrentVar(varmap, index, 1); setCurrentVar(varmap, index, 1);
@ -306,13 +306,13 @@ public class SSAUConstructorSparseEx {
varassign.setVersion(nextver); varassign.setVersion(nextver);
// ssu graph // ssu graph
ssuversions.createNode(new VarVersionPaar(varindex, nextver)); ssuversions.createNode(new VarVersionPair(varindex, nextver));
setCurrentVar(varmap, varindex, nextver); setCurrentVar(varmap, varindex, nextver);
} }
else { else {
if (calcLiveVars) { if (calcLiveVars) {
varMapToGraph(new VarVersionPaar(varindex.intValue(), varassign.getVersion()), varmap); varMapToGraph(new VarVersionPair(varindex.intValue(), varassign.getVersion()), varmap);
} }
setCurrentVar(varmap, varindex, varassign.getVersion()); setCurrentVar(varmap, varindex, varassign.getVersion());
} }
@ -329,14 +329,14 @@ public class SSAUConstructorSparseEx {
if (func.getLstOperands().get(0).type == Exprent.EXPRENT_VAR) { if (func.getLstOperands().get(0).type == Exprent.EXPRENT_VAR) {
VarExprent var = (VarExprent)func.getLstOperands().get(0); VarExprent var = (VarExprent)func.getLstOperands().get(0);
Integer varindex = var.getIndex(); Integer varindex = var.getIndex();
VarVersionPaar varpaar = new VarVersionPaar(varindex.intValue(), var.getVersion()); VarVersionPair varpaar = new VarVersionPair(varindex.intValue(), var.getVersion());
// ssu graph // ssu graph
VarVersionPaar phantomver = phantomppnodes.get(varpaar); VarVersionPair phantomver = phantomppnodes.get(varpaar);
if (phantomver == null) { if (phantomver == null) {
// get next version // get next version
Integer nextver = getNextFreeVersion(varindex, null); Integer nextver = getNextFreeVersion(varindex, null);
phantomver = new VarVersionPaar(varindex, nextver); phantomver = new VarVersionPair(varindex, nextver);
//ssuversions.createOrGetNode(phantomver); //ssuversions.createOrGetNode(phantomver);
ssuversions.createNode(phantomver); ssuversions.createNode(phantomver);
@ -375,7 +375,7 @@ public class SSAUConstructorSparseEx {
if (cardinality == 1) { // size == 1 if (cardinality == 1) { // size == 1
if (current_vers.intValue() != 0) { if (current_vers.intValue() != 0) {
if (calcLiveVars) { if (calcLiveVars) {
varMapToGraph(new VarVersionPaar(varindex, current_vers), varmap); varMapToGraph(new VarVersionPair(varindex, current_vers), varmap);
} }
setCurrentVar(varmap, varindex, current_vers); setCurrentVar(varmap, varindex, current_vers);
} }
@ -389,8 +389,8 @@ public class SSAUConstructorSparseEx {
// ssu graph // ssu graph
Integer lastver = vers.iterator().next(); Integer lastver = vers.iterator().next();
VarVersionNode prenode = ssuversions.nodes.getWithKey(new VarVersionPaar(varindex, lastver)); VarVersionNode prenode = ssuversions.nodes.getWithKey(new VarVersionPair(varindex, lastver));
VarVersionNode usenode = ssuversions.createNode(new VarVersionPaar(varindex, usever)); VarVersionNode usenode = ssuversions.createNode(new VarVersionPair(varindex, usever));
VarVersionEdge edge = new VarVersionEdge(VarVersionEdge.EDGE_GENERAL, prenode, usenode); VarVersionEdge edge = new VarVersionEdge(VarVersionEdge.EDGE_GENERAL, prenode, usenode);
prenode.addSuccessor(edge); prenode.addSuccessor(edge);
usenode.addPredecessor(edge); usenode.addPredecessor(edge);
@ -400,7 +400,7 @@ public class SSAUConstructorSparseEx {
if (current_vers.intValue() != 0) { if (current_vers.intValue() != 0) {
if (calcLiveVars) { if (calcLiveVars) {
varMapToGraph(new VarVersionPaar(varindex, current_vers), varmap); varMapToGraph(new VarVersionPair(varindex, current_vers), varmap);
} }
setCurrentVar(varmap, varindex, current_vers); setCurrentVar(varmap, varindex, current_vers);
} }
@ -411,19 +411,19 @@ public class SSAUConstructorSparseEx {
vardest.setVersion(usever); vardest.setVersion(usever);
// ssu node // ssu node
ssuversions.createNode(new VarVersionPaar(varindex, usever)); ssuversions.createNode(new VarVersionPair(varindex, usever));
setCurrentVar(varmap, varindex, usever); setCurrentVar(varmap, varindex, usever);
current_vers = 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 } // vers.size() == 0 means uninitialized variable, which is impossible
} }
} }
private void createOrUpdatePhiNode(VarVersionPaar phivar, FastSparseSet<Integer> vers, Statement stat) { private void createOrUpdatePhiNode(VarVersionPair phivar, FastSparseSet<Integer> vers, Statement stat) {
FastSparseSet<Integer> versCopy = vers.getCopy(); FastSparseSet<Integer> versCopy = vers.getCopy();
HashSet<Integer> phiVers = new HashSet<Integer>(); HashSet<Integer> phiVers = new HashSet<Integer>();
@ -455,18 +455,18 @@ public class SSAUConstructorSparseEx {
} }
List<VarVersionNode> colnodes = new ArrayList<VarVersionNode>(); List<VarVersionNode> colnodes = new ArrayList<VarVersionNode>();
List<VarVersionPaar> colpaars = new ArrayList<VarVersionPaar>(); List<VarVersionPair> colpaars = new ArrayList<VarVersionPair>();
for (Integer ver : versCopy) { 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); Integer tempver = getNextFreeVersion(phivar.var, stat);
VarVersionNode tempnode = new VarVersionNode(phivar.var, tempver.intValue()); VarVersionNode tempnode = new VarVersionNode(phivar.var, tempver.intValue());
colnodes.add(tempnode); 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); VarVersionEdge edge = new VarVersionEdge(VarVersionEdge.EDGE_GENERAL, prenode, tempnode);
@ -487,9 +487,9 @@ public class SSAUConstructorSparseEx {
phi.put(phivar, phiVers); phi.put(phivar, phiVers);
} }
private void varMapToGraph(VarVersionPaar varpaar, SFormsFastMapDirect varmap) { private void varMapToGraph(VarVersionPair varpaar, SFormsFastMapDirect varmap) {
VBStyleCollection<VarVersionNode, VarVersionPaar> nodes = ssuversions.nodes; VBStyleCollection<VarVersionNode, VarVersionPair> nodes = ssuversions.nodes;
VarVersionNode node = nodes.getWithKey(varpaar); VarVersionNode node = nodes.getWithKey(varpaar);
@ -512,7 +512,7 @@ public class SSAUConstructorSparseEx {
if (stat != null) { // null iff phantom version if (stat != null) { // null iff phantom version
Integer firstRangeId = getFirstProtectedRange(stat); Integer firstRangeId = getFirstProtectedRange(stat);
if (firstRangeId != null) { 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?? if (!mapTrueSource.isEmpty() && !mapNew.isEmpty()) { // FIXME: what for??
// replace phi versions with corresponding phantom ones // replace phi versions with corresponding phantom ones
HashMap<VarVersionPaar, VarVersionPaar> mapPhantom = phantomexitnodes.get(predid); HashMap<VarVersionPair, VarVersionPair> mapPhantom = phantomexitnodes.get(predid);
if (mapPhantom == null) { if (mapPhantom == null) {
mapPhantom = new HashMap<VarVersionPaar, VarVersionPaar>(); mapPhantom = new HashMap<VarVersionPair, VarVersionPair>();
} }
SFormsFastMapDirect mapExitVar = mapNew.getCopy(); SFormsFastMapDirect mapExitVar = mapNew.getCopy();
@ -645,17 +645,17 @@ public class SSAUConstructorSparseEx {
for (Integer version : ent.getValue()) { for (Integer version : ent.getValue()) {
Integer varindex = ent.getKey(); Integer varindex = ent.getKey();
VarVersionPaar exitvar = new VarVersionPaar(varindex, version); VarVersionPair exitvar = new VarVersionPair(varindex, version);
FastSparseSet<Integer> newSet = mapNew.get(varindex); FastSparseSet<Integer> newSet = mapNew.get(varindex);
// remove the actual exit version // remove the actual exit version
newSet.remove(version); newSet.remove(version);
// get or create phantom version // get or create phantom version
VarVersionPaar phantomvar = mapPhantom.get(exitvar); VarVersionPair phantomvar = mapPhantom.get(exitvar);
if (phantomvar == null) { if (phantomvar == null) {
Integer newversion = getNextFreeVersion(exitvar.var, 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 exitnode = ssuversions.nodes.getWithKey(exitvar);
VarVersionNode phantomnode = ssuversions.createNode(phantomvar); VarVersionNode phantomnode = ssuversions.createNode(phantomvar);
@ -745,8 +745,8 @@ public class SSAUConstructorSparseEx {
setCurrentVar(map, varindex, version); setCurrentVar(map, varindex, version);
extraVarVersions.put(dgraph.nodes.getWithKey(flatthelper.getMapDestinationNodes().get(stat.getStats().get(i).id)[0]).id, map); extraVarVersions.put(dgraph.nodes.getWithKey(flatthelper.getMapDestinationNodes().get(stat.getStats().get(i).id)[0]).id, map);
//ssuversions.createOrGetNode(new VarVersionPaar(varindex, version)); //ssuversions.createOrGetNode(new VarVersionPair(varindex, version));
ssuversions.createNode(new VarVersionPaar(varindex, version)); ssuversions.createNode(new VarVersionPair(varindex, version));
} }
} }
@ -770,7 +770,7 @@ public class SSAUConstructorSparseEx {
FastSparseSet<Integer> set = factory.spawnEmptySet(); FastSparseSet<Integer> set = factory.spawnEmptySet();
set.add(version); set.add(version);
map.put(varindex, set); map.put(varindex, set);
ssuversions.createNode(new VarVersionPaar(varindex, version)); ssuversions.createNode(new VarVersionPair(varindex, version));
if (thisvar) { if (thisvar) {
if (i == 0) { if (i == 0) {
@ -815,7 +815,7 @@ public class SSAUConstructorSparseEx {
return null; return null;
} }
public HashMap<VarVersionPaar, HashSet<Integer>> getPhi() { public HashMap<VarVersionPair, HashSet<Integer>> getPhi() {
return phi; return phi;
} }
@ -823,7 +823,7 @@ public class SSAUConstructorSparseEx {
return ssuversions; return ssuversions;
} }
public SFormsFastMapDirect getLiveVarVersionsMap(VarVersionPaar varpaar) { public SFormsFastMapDirect getLiveVarVersionsMap(VarVersionPair varpaar) {
VarVersionNode node = ssuversions.nodes.getWithKey(varpaar); VarVersionNode node = ssuversions.nodes.getWithKey(varpaar);
@ -834,7 +834,7 @@ public class SSAUConstructorSparseEx {
return null; return null;
} }
public HashMap<VarVersionPaar, Integer> getMapVersionFirstRange() { public HashMap<VarVersionPair, Integer> getMapVersionFirstRange() {
return mapVersionFirstRange; return mapVersionFirstRange;
} }

@ -68,7 +68,7 @@ public class VarDefinitionHelper {
int varindex = 0; int varindex = 0;
for (int i = 0; i < paramcount; i++) { for (int i = 0; i < paramcount; i++) {
implDefVars.add(varindex); implDefVars.add(varindex);
varproc.setVarName(new VarVersionPaar(varindex, 0), vc.getFreeName(varindex)); varproc.setVarName(new VarVersionPair(varindex, 0), vc.getFreeName(varindex));
if (thisvar) { if (thisvar) {
if (i == 0) { if (i == 0) {
@ -86,8 +86,8 @@ public class VarDefinitionHelper {
if (thisvar) { if (thisvar) {
StructClass current_class = (StructClass)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS); StructClass current_class = (StructClass)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS);
varproc.getThisVars().put(new VarVersionPaar(0, 0), current_class.qualifiedName); varproc.getThisVars().put(new VarVersionPair(0, 0), current_class.qualifiedName);
varproc.setVarName(new VarVersionPaar(0, 0), "this"); varproc.setVarName(new VarVersionPair(0, 0), "this");
vc.addName("this"); vc.addName("this");
} }
@ -109,7 +109,7 @@ public class VarDefinitionHelper {
if (lstVars != null) { if (lstVars != null) {
for (VarExprent var : lstVars) { for (VarExprent var : lstVars) {
implDefVars.add(var.getIndex()); 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); var.setDefinition(true);
} }
} }
@ -134,7 +134,7 @@ public class VarDefinitionHelper {
continue; continue;
} }
varproc.setVarName(new VarVersionPaar(index.intValue(), 0), vc.getFreeName(index)); varproc.setVarName(new VarVersionPair(index.intValue(), 0), vc.getFreeName(index));
// special case for // special case for
if (stat.type == Statement.TYPE_DO) { if (stat.type == Statement.TYPE_DO) {
@ -196,7 +196,7 @@ public class VarDefinitionHelper {
} }
if (!defset) { 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); var.setDefinition(true);
lst.add(addindex, var); lst.add(addindex, var);

@ -27,10 +27,10 @@ import java.util.Map.Entry;
public class VarProcessor { public class VarProcessor {
private Map<VarVersionPaar, String> mapVarNames = new HashMap<VarVersionPaar, String>(); private Map<VarVersionPair, String> mapVarNames = new HashMap<VarVersionPair, String>();
private VarVersionsProcessor varVersions; private VarVersionsProcessor varVersions;
private Map<VarVersionPaar, String> thisVars = new HashMap<VarVersionPaar, String>(); private Map<VarVersionPair, String> thisVars = new HashMap<VarVersionPair, String>();
private Set<VarVersionPaar> externalVars = new HashSet<VarVersionPaar>(); private Set<VarVersionPair> externalVars = new HashSet<VarVersionPair>();
public void setVarVersions(RootStatement root) { public void setVarVersions(RootStatement root) {
varVersions = new VarVersionsProcessor(); varVersions = new VarVersionsProcessor();
@ -38,7 +38,7 @@ public class VarProcessor {
} }
public void setVarDefinitions(Statement root) { public void setVarDefinitions(Statement root) {
mapVarNames = new HashMap<VarVersionPaar, String>(); mapVarNames = new HashMap<VarVersionPair, String>();
StructMethod mt = (StructMethod)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD); StructMethod mt = (StructMethod)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD);
new VarDefinitionHelper(root, mt, this).setVarDefinitions(); new VarDefinitionHelper(root, mt, this).setVarDefinitions();
@ -51,17 +51,17 @@ public class VarProcessor {
Map<Integer, Integer> mapOriginalVarIndices = varVersions.getMapOriginalVarIndices(); Map<Integer, Integer> mapOriginalVarIndices = varVersions.getMapOriginalVarIndices();
List<VarVersionPaar> listVars = new ArrayList<VarVersionPaar>(mapVarNames.keySet()); List<VarVersionPair> listVars = new ArrayList<VarVersionPair>(mapVarNames.keySet());
Collections.sort(listVars, new Comparator<VarVersionPaar>() { Collections.sort(listVars, new Comparator<VarVersionPair>() {
@Override @Override
public int compare(VarVersionPaar o1, VarVersionPaar o2) { public int compare(VarVersionPair o1, VarVersionPair o2) {
return o1.var - o2.var; return o1.var - o2.var;
} }
}); });
Map<String, Integer> mapNames = new HashMap<String, Integer>(); Map<String, Integer> mapNames = new HashMap<String, Integer>();
for (VarVersionPaar pair : listVars) { for (VarVersionPair pair : listVars) {
String name = mapVarNames.get(pair); String name = mapVarNames.get(pair);
Integer index = mapOriginalVarIndices.get(pair.var); Integer index = mapOriginalVarIndices.get(pair.var);
@ -81,41 +81,41 @@ public class VarProcessor {
} }
public void refreshVarNames(VarNamesCollector vc) { public void refreshVarNames(VarNamesCollector vc) {
Map<VarVersionPaar, String> tempVarNames = new HashMap<VarVersionPaar, String>(mapVarNames); Map<VarVersionPair, String> tempVarNames = new HashMap<VarVersionPair, String>(mapVarNames);
for (Entry<VarVersionPaar, String> ent : tempVarNames.entrySet()) { for (Entry<VarVersionPair, String> ent : tempVarNames.entrySet()) {
mapVarNames.put(ent.getKey(), vc.getFreeName(ent.getValue())); 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); 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); varVersions.setVarType(pair, type);
} }
public String getVarName(VarVersionPaar pair) { public String getVarName(VarVersionPair pair) {
return mapVarNames == null ? null : mapVarNames.get(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); mapVarNames.put(pair, name);
} }
public int getVarFinal(VarVersionPaar pair) { public int getVarFinal(VarVersionPair pair) {
return varVersions == null ? VarTypeProcessor.VAR_FINAL : varVersions.getVarFinal(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); varVersions.setVarFinal(pair, finalType);
} }
public Map<VarVersionPaar, String> getThisVars() { public Map<VarVersionPair, String> getThisVars() {
return thisVars; return thisVars;
} }
public Set<VarVersionPaar> getExternalVars() { public Set<VarVersionPair> getExternalVars() {
return externalVars; return externalVars;
} }
} }

@ -39,9 +39,9 @@ public class VarTypeProcessor {
public static final int VAR_EXPLICIT_FINAL = 2; public static final int VAR_EXPLICIT_FINAL = 2;
public static final int VAR_FINAL = 3; public static final int VAR_FINAL = 3;
private Map<VarVersionPaar, VarType> mapExprentMinTypes = new HashMap<VarVersionPaar, VarType>(); private Map<VarVersionPair, VarType> mapExprentMinTypes = new HashMap<VarVersionPair, VarType>();
private Map<VarVersionPaar, VarType> mapExprentMaxTypes = new HashMap<VarVersionPaar, VarType>(); private Map<VarVersionPair, VarType> mapExprentMaxTypes = new HashMap<VarVersionPair, VarType>();
private Map<VarVersionPaar, Integer> mapFinalVars = new HashMap<VarVersionPaar, Integer>(); private Map<VarVersionPair, Integer> mapFinalVars = new HashMap<VarVersionPair, Integer>();
private void setInitVars(RootStatement root) { private void setInitVars(RootStatement root) {
StructMethod mt = (StructMethod)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD); StructMethod mt = (StructMethod)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD);
@ -53,14 +53,14 @@ public class VarTypeProcessor {
if (thisVar) { if (thisVar) {
StructClass cl = (StructClass)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS); StructClass cl = (StructClass)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS);
VarType clType = new VarType(CodeConstants.TYPE_OBJECT, 0, cl.qualifiedName); VarType clType = new VarType(CodeConstants.TYPE_OBJECT, 0, cl.qualifiedName);
mapExprentMinTypes.put(new VarVersionPaar(0, 1), clType); mapExprentMinTypes.put(new VarVersionPair(0, 1), clType);
mapExprentMaxTypes.put(new VarVersionPaar(0, 1), clType); mapExprentMaxTypes.put(new VarVersionPair(0, 1), clType);
} }
int varIndex = 0; int varIndex = 0;
for (int i = 0; i < md.params.length; i++) { for (int i = 0; i < md.params.length; i++) {
mapExprentMinTypes.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 VarVersionPaar(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; varIndex += md.params[i].stackSize;
} }
@ -81,8 +81,8 @@ public class VarTypeProcessor {
if (lstVars != null) { if (lstVars != null) {
for (VarExprent var : lstVars) { for (VarExprent var : lstVars) {
mapExprentMinTypes.put(new VarVersionPaar(var.getIndex(), 1), var.getVarType()); mapExprentMinTypes.put(new VarVersionPair(var.getIndex(), 1), var.getVarType());
mapExprentMaxTypes.put(new VarVersionPaar(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) { if (exprent.type == Exprent.EXPRENT_CONST) {
ConstExprent constExpr = (ConstExprent)exprent; ConstExprent constExpr = (ConstExprent)exprent;
if (constExpr.getConstType().typeFamily <= CodeConstants.TYPE_FAMILY_INTEGER) { // boolean or integer 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)) { if (!mapExprentMinTypes.containsKey(pair)) {
mapExprentMinTypes.put(pair, constExpr.getConstType()); mapExprentMinTypes.put(pair, constExpr.getConstType());
} }
@ -184,13 +184,13 @@ public class VarTypeProcessor {
} }
} }
case Exprent.EXPRENT_VAR: case Exprent.EXPRENT_VAR:
VarVersionPaar pair = null; VarVersionPair pair = null;
if (exprent.type == Exprent.EXPRENT_CONST) { 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) { else if (exprent.type == Exprent.EXPRENT_VAR) {
//noinspection ConstantConditions //noinspection ConstantConditions
pair = new VarVersionPaar((VarExprent)exprent); pair = new VarVersionPair((VarExprent)exprent);
} }
if (minMax == 0) { // min if (minMax == 0) { // min
@ -255,23 +255,23 @@ public class VarTypeProcessor {
return res; return res;
} }
public Map<VarVersionPaar, VarType> getMapExprentMaxTypes() { public Map<VarVersionPair, VarType> getMapExprentMaxTypes() {
return mapExprentMaxTypes; return mapExprentMaxTypes;
} }
public Map<VarVersionPaar, VarType> getMapExprentMinTypes() { public Map<VarVersionPair, VarType> getMapExprentMinTypes() {
return mapExprentMinTypes; return mapExprentMinTypes;
} }
public Map<VarVersionPaar, Integer> getMapFinalVars() { public Map<VarVersionPair, Integer> getMapFinalVars() {
return mapFinalVars; return mapFinalVars;
} }
public void setVarType(VarVersionPaar pair, VarType type) { public void setVarType(VarVersionPair pair, VarType type) {
mapExprentMinTypes.put(pair, type); mapExprentMinTypes.put(pair, type);
} }
public VarType getVarType(VarVersionPaar pair) { public VarType getVarType(VarVersionPair pair) {
return mapExprentMinTypes.get(pair); return mapExprentMinTypes.get(pair);
} }
} }

@ -45,8 +45,8 @@ public class VarVersionNode implements IGraphNode {
this.version = version; this.version = version;
} }
public VarVersionPaar getVarPaar() { public VarVersionPair getVarPaar() {
return new VarVersionPaar(var, version); return new VarVersionPair(var, version);
} }
public List<IGraphNode> getPredecessors() { public List<IGraphNode> getPredecessors() {

@ -17,24 +17,24 @@ package org.jetbrains.java.decompiler.modules.decompiler.vars;
import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent;
public class VarVersionPaar { public class VarVersionPair {
public int var; public final int var;
public int version; public final int version;
private int hashCode = -1; private int hashCode = -1;
public VarVersionPaar(int var, int version) { public VarVersionPair(int var, int version) {
this.var = var; this.var = var;
this.version = version; this.version = version;
} }
public VarVersionPaar(Integer var, Integer version) { public VarVersionPair(Integer var, Integer version) {
this.var = var.intValue(); this.var = var.intValue();
this.version = version.intValue(); this.version = version.intValue();
} }
public VarVersionPaar(VarExprent var) { public VarVersionPair(VarExprent var) {
this.var = var.getIndex(); this.var = var.getIndex();
this.version = var.getVersion(); this.version = var.getVersion();
} }
@ -42,9 +42,9 @@ public class VarVersionPaar {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == this) return true; 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; return var == paar.var && version == paar.version;
} }

@ -27,17 +27,17 @@ public class VarVersionsGraph {
public int counter = 0; public int counter = 0;
public VBStyleCollection<VarVersionNode, VarVersionPaar> nodes = new VBStyleCollection<VarVersionNode, VarVersionPaar>(); public VBStyleCollection<VarVersionNode, VarVersionPair> nodes = new VBStyleCollection<VarVersionNode, VarVersionPair>();
private GenericDominatorEngine engine; private GenericDominatorEngine engine;
public VarVersionNode createNode(VarVersionPaar ver) { public VarVersionNode createNode(VarVersionPair ver) {
VarVersionNode node; VarVersionNode node;
nodes.addWithKey(node = new VarVersionNode(ver.var, ver.version), ver); nodes.addWithKey(node = new VarVersionNode(ver.var, ver.version), ver);
return node; return node;
} }
public void addNodes(Collection<VarVersionNode> colnodes, Collection<VarVersionPaar> colpaars) { public void addNodes(Collection<VarVersionNode> colnodes, Collection<VarVersionPair> colpaars) {
nodes.addAllWithKey(colnodes, colpaars); nodes.addAllWithKey(colnodes, colpaars);
} }

@ -62,17 +62,17 @@ public class VarVersionsProcessor {
private static void mergePhiVersions(SSAConstructorSparseEx ssa, DirectGraph graph) { private static void mergePhiVersions(SSAConstructorSparseEx ssa, DirectGraph graph) {
// collect phi versions // collect phi versions
List<Set<VarVersionPaar>> lst = new ArrayList<Set<VarVersionPaar>>(); List<Set<VarVersionPair>> lst = new ArrayList<Set<VarVersionPair>>();
for (Entry<VarVersionPaar, FastSparseSet<Integer>> ent : ssa.getPhi().entrySet()) { for (Entry<VarVersionPair, FastSparseSet<Integer>> ent : ssa.getPhi().entrySet()) {
Set<VarVersionPaar> set = new HashSet<VarVersionPaar>(); Set<VarVersionPair> set = new HashSet<VarVersionPair>();
set.add(ent.getKey()); set.add(ent.getKey());
for (Integer version : ent.getValue()) { 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--) { for (int i = lst.size() - 1; i >= 0; i--) {
Set<VarVersionPaar> tset = lst.get(i); Set<VarVersionPair> tset = lst.get(i);
Set<VarVersionPaar> intersection = new HashSet<VarVersionPaar>(set); Set<VarVersionPair> intersection = new HashSet<VarVersionPair>(set);
intersection.retainAll(tset); intersection.retainAll(tset);
if (!intersection.isEmpty()) { if (!intersection.isEmpty()) {
@ -84,24 +84,24 @@ public class VarVersionsProcessor {
lst.add(set); lst.add(set);
} }
Map<VarVersionPaar, Integer> phiVersions = new HashMap<VarVersionPaar, Integer>(); Map<VarVersionPair, Integer> phiVersions = new HashMap<VarVersionPair, Integer>();
for (Set<VarVersionPaar> set : lst) { for (Set<VarVersionPair> set : lst) {
int min = Integer.MAX_VALUE; int min = Integer.MAX_VALUE;
for (VarVersionPaar paar : set) { for (VarVersionPair paar : set) {
if (paar.version < min) { if (paar.version < min) {
min = paar.version; min = paar.version;
} }
} }
for (VarVersionPaar paar : set) { for (VarVersionPair paar : set) {
phiVersions.put(new VarVersionPaar(paar.var, paar.version), min); phiVersions.put(new VarVersionPair(paar.var, paar.version), min);
} }
} }
updateVersions(graph, phiVersions); updateVersions(graph, phiVersions);
} }
private static void updateVersions(DirectGraph graph, final Map<VarVersionPaar, Integer> versions) { private static void updateVersions(DirectGraph graph, final Map<VarVersionPair, Integer> versions) {
graph.iterateExprents(new DirectGraph.ExprentIterator() { graph.iterateExprents(new DirectGraph.ExprentIterator() {
@Override @Override
public int processExprent(Exprent exprent) { public int processExprent(Exprent exprent) {
@ -111,7 +111,7 @@ public class VarVersionsProcessor {
for (Exprent expr : lst) { for (Exprent expr : lst) {
if (expr.type == Exprent.EXPRENT_VAR) { if (expr.type == Exprent.EXPRENT_VAR) {
VarExprent var = (VarExprent)expr; VarExprent var = (VarExprent)expr;
Integer version = versions.get(new VarVersionPaar(var)); Integer version = versions.get(new VarVersionPair(var));
if (version != null) { if (version != null) {
var.setVersion(version); var.setVersion(version);
} }
@ -124,11 +124,11 @@ public class VarVersionsProcessor {
} }
private static void eliminateNonJavaTypes(VarTypeProcessor typeProcessor) { private static void eliminateNonJavaTypes(VarTypeProcessor typeProcessor) {
Map<VarVersionPaar, VarType> mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); Map<VarVersionPair, VarType> mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes();
Map<VarVersionPaar, VarType> mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); Map<VarVersionPair, VarType> mapExprentMinTypes = typeProcessor.getMapExprentMinTypes();
Set<VarVersionPaar> set = new HashSet<VarVersionPaar>(mapExprentMinTypes.keySet()); Set<VarVersionPair> set = new HashSet<VarVersionPair>(mapExprentMinTypes.keySet());
for (VarVersionPaar paar : set) { for (VarVersionPair paar : set) {
VarType type = mapExprentMinTypes.get(paar); VarType type = mapExprentMinTypes.get(paar);
VarType maxType = mapExprentMaxTypes.get(paar); VarType maxType = mapExprentMaxTypes.get(paar);
@ -150,12 +150,12 @@ public class VarVersionsProcessor {
} }
private static void simpleMerge(VarTypeProcessor typeProcessor, DirectGraph graph, StructMethod mt) { private static void simpleMerge(VarTypeProcessor typeProcessor, DirectGraph graph, StructMethod mt) {
Map<VarVersionPaar, VarType> mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); Map<VarVersionPair, VarType> mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes();
Map<VarVersionPaar, VarType> mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); Map<VarVersionPair, VarType> mapExprentMinTypes = typeProcessor.getMapExprentMinTypes();
Map<Integer, Set<Integer>> mapVarVersions = new HashMap<Integer, Set<Integer>>(); Map<Integer, Set<Integer>> mapVarVersions = new HashMap<Integer, Set<Integer>>();
for (VarVersionPaar pair : mapExprentMinTypes.keySet()) { for (VarVersionPair pair : mapExprentMinTypes.keySet()) {
if (pair.version >= 0) { // don't merge constants if (pair.version >= 0) { // don't merge constants
Set<Integer> set = mapVarVersions.get(pair.var); Set<Integer> set = mapVarVersions.get(pair.var);
if (set == null) { if (set == null) {
@ -168,7 +168,7 @@ public class VarVersionsProcessor {
boolean is_method_static = mt.hasModifier(CodeConstants.ACC_STATIC); boolean is_method_static = mt.hasModifier(CodeConstants.ACC_STATIC);
Map<VarVersionPaar, Integer> mapMergedVersions = new HashMap<VarVersionPaar, Integer>(); Map<VarVersionPair, Integer> mapMergedVersions = new HashMap<VarVersionPair, Integer>();
for (Entry<Integer, Set<Integer>> ent : mapVarVersions.entrySet()) { for (Entry<Integer, Set<Integer>> ent : mapVarVersions.entrySet()) {
@ -177,7 +177,7 @@ public class VarVersionsProcessor {
Collections.sort(lstVersions); Collections.sort(lstVersions);
for (int i = 0; i < lstVersions.size(); i++) { 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); VarType firstType = mapExprentMinTypes.get(firstPair);
if (firstPair.var == 0 && firstPair.version == 1 && !is_method_static) { 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++) { 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); VarType secondType = mapExprentMinTypes.get(secondPair);
if (firstType.equals(secondType) || if (firstType.equals(secondType) ||
@ -225,23 +225,23 @@ public class VarVersionsProcessor {
} }
private void setNewVarIndices(VarTypeProcessor typeProcessor, DirectGraph graph) { private void setNewVarIndices(VarTypeProcessor typeProcessor, DirectGraph graph) {
final Map<VarVersionPaar, VarType> mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); final Map<VarVersionPair, VarType> mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes();
Map<VarVersionPaar, VarType> mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); Map<VarVersionPair, VarType> mapExprentMinTypes = typeProcessor.getMapExprentMinTypes();
Map<VarVersionPaar, Integer> mapFinalVars = typeProcessor.getMapFinalVars(); Map<VarVersionPair, Integer> mapFinalVars = typeProcessor.getMapFinalVars();
CounterContainer counters = DecompilerContext.getCounterContainer(); CounterContainer counters = DecompilerContext.getCounterContainer();
final Map<VarVersionPaar, Integer> mapVarPaar = new HashMap<VarVersionPaar, Integer>(); final Map<VarVersionPair, Integer> mapVarPaar = new HashMap<VarVersionPair, Integer>();
Map<Integer, Integer> mapOriginalVarIndices = new HashMap<Integer, Integer>(); Map<Integer, Integer> mapOriginalVarIndices = new HashMap<Integer, Integer>();
// map var-version pairs on new var indexes // map var-version pairs on new var indexes
Set<VarVersionPaar> set = new HashSet<VarVersionPaar>(mapExprentMinTypes.keySet()); Set<VarVersionPair> set = new HashSet<VarVersionPair>(mapExprentMinTypes.keySet());
for (VarVersionPaar pair : set) { for (VarVersionPair pair : set) {
if (pair.version >= 0) { if (pair.version >= 0) {
int newIndex = pair.version == 1 ? pair.var : counters.getCounterAndIncrement(CounterContainer.VAR_COUNTER); 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)); mapExprentMinTypes.put(newVar, mapExprentMinTypes.get(pair));
mapExprentMaxTypes.put(newVar, mapExprentMaxTypes.get(pair)); mapExprentMaxTypes.put(newVar, mapExprentMaxTypes.get(pair));
@ -265,14 +265,14 @@ public class VarVersionsProcessor {
for (Exprent expr : lst) { for (Exprent expr : lst) {
if (expr.type == Exprent.EXPRENT_VAR) { if (expr.type == Exprent.EXPRENT_VAR) {
VarExprent newVar = (VarExprent)expr; VarExprent newVar = (VarExprent)expr;
Integer newVarIndex = mapVarPaar.get(new VarVersionPaar(newVar)); Integer newVarIndex = mapVarPaar.get(new VarVersionPair(newVar));
if (newVarIndex != null) { if (newVarIndex != null) {
newVar.setIndex(newVarIndex); newVar.setIndex(newVarIndex);
newVar.setVersion(0); newVar.setVersion(0);
} }
} }
else if (expr.type == Exprent.EXPRENT_CONST) { 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)) { if (maxType != null && maxType.equals(VarType.VARTYPE_CHAR)) {
((ConstExprent)expr).setConstType(maxType); ((ConstExprent)expr).setConstType(maxType);
} }
@ -286,15 +286,15 @@ public class VarVersionsProcessor {
this.mapOriginalVarIndices = mapOriginalVarIndices; this.mapOriginalVarIndices = mapOriginalVarIndices;
} }
public VarType getVarType(VarVersionPaar pair) { public VarType getVarType(VarVersionPair pair) {
return typeProcessor == null ? null : typeProcessor.getVarType(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); typeProcessor.setVarType(pair, type);
} }
public int getVarFinal(VarVersionPaar pair) { public int getVarFinal(VarVersionPair pair) {
int ret = VarTypeProcessor.VAR_FINAL; int ret = VarTypeProcessor.VAR_FINAL;
if (typeProcessor != null) { if (typeProcessor != null) {
Integer fin = typeProcessor.getMapFinalVars().get(pair); Integer fin = typeProcessor.getMapFinalVars().get(pair);
@ -304,7 +304,7 @@ public class VarVersionsProcessor {
return ret; return ret;
} }
public void setVarFinal(VarVersionPaar pair, int finalType) { public void setVarFinal(VarVersionPair pair, int finalType) {
typeProcessor.getMapFinalVars().put(pair, finalType); typeProcessor.getMapFinalVars().put(pair, finalType);
} }

Loading…
Cancel
Save