-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change type update collection to produce deterministic results
- Loading branch information
Showing
3 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdateEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 + '}'; | ||
} | ||
} |
23 changes: 15 additions & 8 deletions
23
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdateInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |