use of net.runelite.asm.ClassFile in project runelite by runelite.
the class ModArith method guess.
private void guess() {
for (ClassFile cf : group.getClasses()) {
for (Field f : cf.getFields()) {
FieldInfo fieldInfo = getFieldInfo(f);
// all constants in instructions associated with the field
Collection<AssociatedConstant> col = fieldInfo.constants;
if (col.isEmpty()) {
continue;
}
Type type = f.getType();
assert type.equals(Type.INT) || type.equals(Type.LONG);
Class typeOfField = type.equals(Type.INT) ? Integer.class : Long.class;
// filter collect constants of the correct type
Collection<AssociatedConstant> col2 = col.stream().filter(i -> i.value.getClass() == typeOfField).collect(Collectors.toList());
// filer out ones that have another field in the expression
List<Number> noOther = col2.stream().filter(i -> !i.other && !i.constant).map(i -> i.value).distinct().collect(Collectors.toList());
List<Number> other = col2.stream().filter(i -> i.other || i.constant).map(i -> i.value).collect(Collectors.toList());
other.addAll(noOther);
other = ImmutableSet.copyOf(other).asList();
// guess with constants not associated with other fields
Pair p = this.guess(f, noOther);
if (p == null) {
// fall back to all constants
p = this.guess(f, other);
}
// check that this guess doesn't increase constants
if (p != null && !fieldInfo.guessDecreasesConstants(p)) {
continue;
}
if (p != null) {
pairs.add(p);
}
}
}
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class AnnotationIntegrityChecker method checkAnnotationCounts.
private void checkAnnotationCounts() {
for (ClassFile cf : two.getClasses()) {
for (Field f : cf.getFields()) {
int num = this.getNumberOfExports(f.getAnnotations());
if (num > 1) {
logger.warn("Field {} has more than 1 export", f);
++errors;
}
}
for (Method m : cf.getMethods()) {
int num = this.getNumberOfExports(m.getAnnotations());
if (num > 1) {
logger.warn("Method {} has more than 1 export", m);
++errors;
}
}
}
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class AnnotationIntegrityChecker method run.
public void run() {
for (ClassFile cf : one.getClasses()) {
ClassFile other = (ClassFile) mapping.get(cf);
List<Field> exf1 = getExportedFields(cf);
List<Method> exm1 = getExportedMethods(cf);
for (Field f1 : exf1) {
boolean isImported = isImported(cf, f1.getName(), f1.isStatic());
Field f2;
if (other == null) {
if (!f1.isStatic() && isImported) {
++errors;
logger.error("No other class for {} which contains imported field {}", cf, f1);
}
continue;
}
if (f1.isStatic()) {
f2 = findExportedFieldStatic(two, DeobAnnotations.getExportedName(f1.getAnnotations()));
} else {
f2 = findExportedField(other, DeobAnnotations.getExportedName(f1.getAnnotations()));
}
if (f2 == null) {
if (isImported) {
logger.error("Missing IMPORTED field on {} named {}", other, DeobAnnotations.getExportedName(f1.getAnnotations()));
++errors;
} else {
logger.warn("Missing exported field on {} named {}", other, DeobAnnotations.getExportedName(f1.getAnnotations()));
++warnings;
}
}
}
for (Method m1 : exm1) {
boolean isImported = isImported(cf, m1.getName(), m1.isStatic());
Method m2;
if (other == null) {
if (!m1.isStatic() && isImported) {
++errors;
logger.error("No other class for {} which contains imported method {}", cf, m1);
}
continue;
}
if (m1.isStatic()) {
m2 = findExportedMethodStatic(two, DeobAnnotations.getExportedName(m1.getAnnotations()));
} else {
m2 = findExportedMethod(other, DeobAnnotations.getExportedName(m1.getAnnotations()));
}
if (m2 == null) {
if (isImported) {
logger.error("Missing IMPORTED method on {} named {} ({})", other, DeobAnnotations.getExportedName(m1.getAnnotations()), m1);
++errors;
} else {
logger.warn("Missing exported method on {} named {} ({})", other, DeobAnnotations.getExportedName(m1.getAnnotations()), m1);
++warnings;
}
}
}
}
checkAnnotationCounts();
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class AnnotationMapper method run.
public void run() {
int count = 0;
for (ClassFile c : source.getClasses()) {
ClassFile other = (ClassFile) mapping.get(c);
count += run(c, other);
}
logger.info("Copied {} annotations", count);
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class ConstructorMapper method mapConstructors.
/**
* Map constructors based on the class mappings of the given mapping
*/
public void mapConstructors() {
for (ClassFile cf : source.getClasses()) {
ClassFile other = (ClassFile) mapping.get(cf);
if (other == null) {
continue;
}
for (Method m : cf.getMethods()) {
if (!m.getName().equals("<init>")) {
continue;
}
Signature otherSig = toOtherSignature(m.getDescriptor());
if (otherSig == null) {
continue;
}
logger.debug("Converted signature {} -> {}", m.getDescriptor(), otherSig);
Method m2 = other.findMethod(m.getName(), otherSig);
if (m2 == null) {
logger.warn("Unable to find other constructor for {}, looking for signature {} on class {}", m, otherSig, other);
continue;
}
ParallelExecutorMapping p = MappingExecutorUtil.map(m, m2);
p.map(null, m, m2);
mapping.merge(p);
}
}
}
Aggregations