Attempt to map non static methods using PME too
This commit is contained in:
@@ -1,44 +1,42 @@
|
||||
package net.runelite.deob.deobfuscators.rename;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.runelite.deob.ClassFile;
|
||||
import net.runelite.deob.Method;
|
||||
import net.runelite.deob.Methods;
|
||||
import net.runelite.deob.signature.Signature;
|
||||
|
||||
public class MethodSignatureMapper
|
||||
{
|
||||
private Map<Method, Method> map = new HashMap<>();
|
||||
|
||||
private long count(Methods methods, Signature sig)
|
||||
{
|
||||
return methods.getMethods().stream().filter(m -> m.getDescriptor().equals(sig)).count();
|
||||
}
|
||||
|
||||
private Method get(Methods methods, Signature sig)
|
||||
{
|
||||
Optional<Method> o = methods.getMethods().stream().filter(m -> m.getDescriptor().equals(sig)).findFirst();
|
||||
return o.isPresent() ? o.get() : null;
|
||||
}
|
||||
private Multimap<Method, Method> map = ArrayListMultimap.create();
|
||||
|
||||
public void map(ClassFile c1, ClassFile c2)
|
||||
{
|
||||
for (Method m : c1.getMethods().getMethods())
|
||||
{
|
||||
if (m.isStatic() || count(c1.getMethods(), m.getDescriptor()) > 1)
|
||||
if (m.isStatic() || m.getCode() == null)
|
||||
continue;
|
||||
|
||||
Method other = get(c2.getMethods(), m.getDescriptor());
|
||||
if (other == null)
|
||||
continue;
|
||||
boolean isConstructor = m.getName().equals("<init>");
|
||||
|
||||
map.put(m, other);
|
||||
for (Method m2 : c2.getMethods().getMethods())
|
||||
{
|
||||
if (m2.getCode() == null)
|
||||
continue;
|
||||
|
||||
if (!m.getDescriptor().equals(m2.getDescriptor()))
|
||||
continue;
|
||||
|
||||
boolean isConstructor2 = m2.getName().equals("<init>");
|
||||
|
||||
if (isConstructor != isConstructor2)
|
||||
continue;
|
||||
|
||||
map.put(m, m2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Method, Method> getMap()
|
||||
public Multimap<Method, Method> getMap()
|
||||
{
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user