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