fix: change type update collection to produce deterministic results
This commit is contained in:
@@ -18,7 +18,6 @@ import jadx.core.dex.instructions.args.InsnArg;
|
||||
import jadx.core.dex.instructions.args.PrimitiveType;
|
||||
import jadx.core.dex.instructions.args.RegisterArg;
|
||||
import jadx.core.dex.instructions.args.SSAVar;
|
||||
import jadx.core.dex.instructions.args.Typed;
|
||||
import jadx.core.dex.nodes.InsnNode;
|
||||
import jadx.core.dex.nodes.RootNode;
|
||||
import jadx.core.utils.exceptions.JadxOverflowException;
|
||||
@@ -57,11 +56,11 @@ public final class TypeUpdate {
|
||||
if (result == REJECT) {
|
||||
return result;
|
||||
}
|
||||
Map<InsnArg, ArgType> updates = updateInfo.getUpdates();
|
||||
List<TypeUpdateEntry> updates = updateInfo.getUpdates();
|
||||
if (updates.isEmpty()) {
|
||||
return SAME;
|
||||
}
|
||||
updates.forEach(Typed::setType);
|
||||
updates.forEach(TypeUpdateEntry::apply);
|
||||
return CHANGED;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package jadx.core.dex.visitors.typeinference;
|
||||
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.core.dex.instructions.args.InsnArg;
|
||||
|
||||
public final class TypeUpdateEntry {
|
||||
private final InsnArg arg;
|
||||
private final ArgType type;
|
||||
|
||||
public TypeUpdateEntry(InsnArg arg, ArgType type) {
|
||||
this.arg = arg;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
arg.setType(type);
|
||||
}
|
||||
|
||||
public InsnArg getArg() {
|
||||
return arg;
|
||||
}
|
||||
|
||||
public ArgType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TypeUpdateEntry{" + arg + " -> " + type + '}';
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,35 @@
|
||||
package jadx.core.dex.visitors.typeinference;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.core.dex.instructions.args.InsnArg;
|
||||
|
||||
public class TypeUpdateInfo {
|
||||
|
||||
private final Map<InsnArg, ArgType> updates = new IdentityHashMap<>();
|
||||
private final List<TypeUpdateEntry> updates = new ArrayList<>();
|
||||
|
||||
public void requestUpdate(InsnArg arg, ArgType changeType) {
|
||||
updates.put(arg, changeType);
|
||||
updates.add(new TypeUpdateEntry(arg, changeType));
|
||||
}
|
||||
|
||||
public boolean isProcessed(InsnArg arg) {
|
||||
return updates.containsKey(arg);
|
||||
if (updates.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (TypeUpdateEntry entry : updates) {
|
||||
if (entry.getArg() == arg) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void rollbackUpdate(InsnArg arg) {
|
||||
updates.remove(arg);
|
||||
updates.removeIf(updateEntry -> updateEntry.getArg() == arg);
|
||||
}
|
||||
|
||||
public Map<InsnArg, ArgType> getUpdates() {
|
||||
public List<TypeUpdateEntry> getUpdates() {
|
||||
return updates;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user