use of net.runelite.asm.Method in project runelite by runelite.
the class AnnotationMapper method run.
private int run(ClassFile from, ClassFile to) {
int count = 0;
if (hasCopyableAnnotation(from.getAnnotations())) {
if (to != null) {
count += copyAnnotations(from.getAnnotations(), to.getAnnotations());
} else {
logger.warn("Class {} has copyable annotations but there is no mapped class", from);
}
}
for (Field f : from.getFields()) {
if (!hasCopyableAnnotation(f.getAnnotations()))
continue;
Field other = (Field) mapping.get(f);
if (other == null) {
logger.warn("Unable to map annotated field {} named {}", f, DeobAnnotations.getExportedName(f.getAnnotations()));
continue;
}
count += copyAnnotations(f.getAnnotations(), other.getAnnotations());
}
for (Method m : from.getMethods()) {
if (!hasCopyableAnnotation(m.getAnnotations()))
continue;
Method other = (Method) mapping.get(m);
if (other == null) {
logger.warn("Unable to map annotated method {} named {}", m, DeobAnnotations.getExportedName(m.getAnnotations()));
continue;
}
count += copyAnnotations(m.getAnnotations(), other.getAnnotations());
}
return count;
}
use of net.runelite.asm.Method in project runelite by runelite.
the class ExecutionMapper method run.
public ParallelExecutorMapping run() {
ParallelExecutorMapping highest = null;
boolean multiple = false;
for (Method m : methods2) {
ParallelExecutorMapping mapping = MappingExecutorUtil.map(method1, m);
if (highest == null || mapping.same > highest.same) {
highest = mapping;
multiple = false;
} else if (mapping.same == highest.same) {
multiple = true;
}
}
if (multiple)
return null;
return highest;
}
use of net.runelite.asm.Method in project runelite by runelite.
the class Mapper method mapUnexecutedMethods.
/**
* execute and map already mapped methods that have not yet been "executed",
* and apply their mappings
* @param mapping
* @return
*/
private boolean mapUnexecutedMethods(ParallelExecutorMapping mapping) {
// map has already been reduced
boolean mapped = false;
for (Object o : mapping.getMap().keySet()) {
Mapping m = mapping.getMappings(o).iterator().next();
if (m.wasExecuted || !(m.getFrom() instanceof Method)) {
continue;
}
Method m1 = (Method) m.getFrom(), m2 = (Method) m.getObject();
if (m1.getCode() == null || m2.getCode() == null) {
continue;
}
// m was picked up as an invoke instruction when mapping
// something else, but wasn't executed itself
logger.debug("Wasn't executed {}", m);
ParallelExecutorMapping ma = MappingExecutorUtil.map(m1, m2);
m.wasExecuted = true;
mapped = true;
mapping.merge(ma);
}
return mapped;
}
use of net.runelite.asm.Method in project runelite by runelite.
the class Mapper method mapMethods.
private ParallelExecutorMapping mapMethods() {
MethodSignatureMapper msm = new MethodSignatureMapper();
msm.map(source, target);
List<ParallelExecutorMapping> pmes = new ArrayList<>();
for (Method m : msm.getMap().keySet()) {
Collection<Method> methods = msm.getMap().get(m);
ExecutionMapper em = new ExecutionMapper(m, methods);
ParallelExecutorMapping mapping = em.run();
if (mapping == null) {
continue;
}
mapping.map(null, mapping.m1, mapping.m2).wasExecuted = true;
logger.debug("map methods mapped {} -> {}", mapping.m1, mapping.m2);
pmes.add(mapping);
}
ParallelExecutorMapping finalm = new ParallelExecutorMapping(source, target);
for (ParallelExecutorMapping pme : pmes) {
finalm.merge(pme);
}
return finalm;
}
use of net.runelite.asm.Method in project runelite by runelite.
the class UpdateMappingsTest method check.
private void check(ClassGroup group1, ClassGroup group2) {
for (ClassFile cf : group1.getClasses()) {
ClassFile other = group2.findClass(cf.getName());
String implname = DeobAnnotations.getImplements(cf);
String otherimplname = DeobAnnotations.getImplements(other);
Assert.assertEquals(implname, otherimplname);
for (Field f : cf.getFields()) {
Field otherf = other.findField(f.getName(), f.getType());
assert otherf != null : "unable to find " + f;
String name = DeobAnnotations.getExportedName(f.getAnnotations());
String otherName = DeobAnnotations.getExportedName(otherf.getAnnotations());
Assert.assertEquals(name + " <-> " + otherName, name, otherName);
}
for (Method m : cf.getMethods()) {
Method otherm = other.findMethod(m.getName(), m.getDescriptor());
assert otherm != null : "unable to find " + m;
String name = DeobAnnotations.getExportedName(m.getAnnotations());
String otherName = DeobAnnotations.getExportedName(otherm.getAnnotations());
Assert.assertEquals(name + " <-> " + otherName, name, otherName);
}
}
}
Aggregations