Well this seems to work a little better. This is totally made up.

This commit is contained in:
Adam
2016-03-18 23:09:34 -04:00
parent 5a0c8ee21d
commit 3d1ae24d73
3 changed files with 160 additions and 15 deletions

View File

@@ -180,6 +180,7 @@ public class Mapper
PacketHandler highestHandler = null;
ParallelExecutorMapping highest = null;
int maxContradictions = 0;
for (int j = 0; j < mappings.packetHandler2.size(); ++j)
{
@@ -193,13 +194,36 @@ public class Mapper
if (mapping.getMap().isEmpty())
continue;
if (mapping.hasAnyMultiples())
continue;
int p = pem.contradicts(mapping);
if (if1.getPacketId() == 9 && (if2.getPacketId() == 25 || if2.getPacketId() == 187))
{
int i444 =6;
pem.contradicts(mapping);
}
//if (highest == null || p < maxContradictions)
if (highest == null || mapping.getMap().size() > highest.getMap().size())
{
highest = mapping;
highestHandler = if2;
if (p == 0 && mapping.crashed == false)
//if (p == 0)
//if (!pem.contradicts(mapping))
{
highest = mapping;
highestHandler = if2;
maxContradictions = p;
}
}
}
if (highest == null)
{
continue;
//int i44 = 5;
}
System.out.println(if1 + " <-> " + highestHandler + " <-> " + highest.getMap().size() + " " + highest.crashed);
all.merge(highest);
}

View File

@@ -0,0 +1,39 @@
package net.runelite.deob.deobfuscators.rename;
public class Mapping
{
private Object object;
private int count;
public Mapping(Object object)
{
this.object = object;
}
@Override
public String toString()
{
return "Mapping{" + "object=" + object + ", count=" + count + '}';
}
public Object getObject()
{
return object;
}
public int getCount()
{
return count;
}
public void inc()
{
++count;
}
public void merge(Mapping other)
{
assert object == other.object;
count += other.count;
}
}

View File

@@ -1,9 +1,12 @@
package net.runelite.deob.deobfuscators.rename;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.runelite.deob.ClassGroup;
import net.runelite.deob.Field;
import net.runelite.deob.Method;
@@ -12,7 +15,8 @@ import net.runelite.deob.attributes.code.instructions.If;
public class ParallelExecutorMapping
{
private ClassGroup group, group2;
private Map<Object, Object> map = new HashMap<>();
private Multimap<Object, Mapping> map = HashMultimap.create();
//private Map<Object, Object> map = new HashMap<>();
//private List<Object> order = new ArrayList<>();
public Method m1, m2;
public boolean crashed;
@@ -25,39 +29,91 @@ public class ParallelExecutorMapping
this.group2 = group2;
assert group != group2;
}
@Override
public String toString()
{
return "ParallelExecutorMapping{size = " + map.size() + ", crashed = " + crashed + "}";
}
private Mapping getMapping(Object from, Object to)
{
for (Mapping m : map.get(from))
if (m.getObject() == to)
return m;
Mapping m = new Mapping(to);
map.put(from, m);
return m;
}
private Object highest(Object from)
{
Mapping highest = null;
for (Mapping m : map.get(from))
if (highest == null || m.getCount() > highest.getCount())
highest = m;
return highest != null ? highest.getObject() : null;
}
public void merge(ParallelExecutorMapping other)
{
assert this != other;
map.putAll(other.map); // is this right?
for (Entry<Object, Mapping> e : other.map.entries())
{
Object o = e.getKey();
Mapping v = e.getValue();
Mapping m = this.getMapping(o, v.getObject());
m.merge(v);
}
}
// public void mergeButNotOverride(ParallelExecutorMapping other)
// {
// assert this != other;
// for (Object o : other.map.keySet())
// if (map.containsKey(o) == false)
// map.put(o, other.map.get(o));
// }
public void map(Object one, Object two)
{
//assert !map.containsKey(one) || map.get(one) == two;
if (map.containsKey(one))
return;
if (one instanceof Field)
{
Field f= (Field) one;
if (f.getName().equals("field849"))
{
int i = 5;
}
}
Mapping m = getMapping(one, two);
belongs(one, group);
belongs(two, group2);
map.put(one, two);
//order.add(one);
m.inc();
}
public Object get(Object o)
{
return map.get(o);
return highest(o);
//return map.get(o);
}
public Map<Object, Object> getMap()
{
return map;
Map<Object, Object> m = new HashMap<>();
for (Object o : map.keySet())
{
m.put(o, highest(o));
}
return m;
}
//public List<Object> getOrder() { return order; }
private void belongs(Object o, ClassGroup to)
{
if (o instanceof Field)
@@ -89,4 +145,30 @@ public class ParallelExecutorMapping
return p;
return null;
}
public int contradicts(ParallelExecutorMapping other)
{
int count = 0;
for (Entry<Object, Mapping> e : other.map.entries())
{
Object key = e.getKey();
Mapping value = e.getValue();
Object highest = highest(key);
if (highest != null && highest != value.getObject())
++count;
}
return count;
}
public boolean hasAnyMultiples()
{
for (Object o : map.keySet())
if (map.get(o).size() > 1)
return true;
return false;
}
}