Search in sources :

Example 6 with Field

use of net.runelite.asm.Field in project runelite by runelite.

the class ParallelExecutorMapping method sanityCheck.

private void sanityCheck(Object one, Object two) {
    if (one instanceof Field && two instanceof Field) {
        Field f1 = (Field) one;
        Field f2 = (Field) two;
        assert f1.isStatic() == f2.isStatic() : "field map with static mismatch!";
    }
}
Also used : Field(net.runelite.asm.Field)

Example 7 with Field

use of net.runelite.asm.Field in project runelite by runelite.

the class ParallelExecutorMapping method mapClass.

private void mapClass(StaticInitializerIndexer staticIndexer1, StaticInitializerIndexer staticIndexer2, Object one, Object two) {
    ClassFile cf1, cf2;
    if (one instanceof Field || two instanceof Field) {
        assert one instanceof Field;
        assert two instanceof Field;
        Field f1 = (Field) one;
        Field f2 = (Field) two;
        assert f1.isStatic() == f2.isStatic();
        if (staticIndexer1.isStatic(f1) && staticIndexer2.isStatic(f2)) {
            logger.debug("Mapping class of {} -> {} due to static initializer", f1, f2);
        } else if (f1.isStatic() || f2.isStatic()) {
            return;
        }
        cf1 = f1.getClassFile();
        cf2 = f2.getClassFile();
    } else if (one instanceof Method || two instanceof Method) {
        assert one instanceof Method;
        assert two instanceof Method;
        Method m1 = (Method) one;
        Method m2 = (Method) two;
        assert m1.isStatic() == m1.isStatic();
        if (m1.isStatic() || m2.isStatic()) {
            return;
        }
        cf1 = m1.getClassFile();
        cf2 = m2.getClassFile();
    } else {
        assert false;
        return;
    }
    belongs(cf1, group);
    belongs(cf2, group2);
    Mapping m = getMapping(cf1, cf2);
    m.inc();
}
Also used : Field(net.runelite.asm.Field) ClassFile(net.runelite.asm.ClassFile) Method(net.runelite.asm.Method)

Example 8 with Field

use of net.runelite.asm.Field in project runelite by runelite.

the class AnnotationCopier method copy.

public void copy() {
    for (ClassFile cf1 : group1.getClasses()) {
        ClassFile cf2 = group2.findClass(cf1.getName());
        assert cf2 != null;
        copy(cf1.getAnnotations(), cf2.getAnnotations());
        for (Field f : cf1.getFields()) {
            Field f2 = cf2.findField(f.getName(), f.getType());
            assert f2 != null || f.getAnnotations() == null;
            if (f2 == null)
                continue;
            copy(f.getAnnotations(), f2.getAnnotations());
        }
        for (Method m : cf1.getMethods()) {
            Method m2 = cf2.findMethod(m.getName(), m.getDescriptor());
            assert m2 != null || m.getAnnotations() == null;
            if (m2 == null)
                continue;
            copy(m.getAnnotations(), m2.getAnnotations());
        }
    }
}
Also used : Field(net.runelite.asm.Field) ClassFile(net.runelite.asm.ClassFile) Method(net.runelite.asm.Method)

Example 9 with Field

use of net.runelite.asm.Field in project runelite by runelite.

the class RenameUniqueTest method checkRenamed.

private void checkRenamed() {
    for (ClassFile cf : group.getClasses()) {
        Assert.assertTrue(cf.getName().startsWith("class") || cf.getName().equals("client"));
        for (Field f : cf.getFields()) {
            // synthetic fields arent obfuscated
            if (f.isSynthetic())
                continue;
            Assert.assertTrue(f.getName().startsWith("field"));
        }
        for (Method m : cf.getMethods()) {
            Assert.assertTrue(m.getName().length() > 2);
            checkCode(m.getCode());
        }
    }
}
Also used : Field(net.runelite.asm.Field) ClassFile(net.runelite.asm.ClassFile) Method(net.runelite.asm.Method)

Example 10 with Field

use of net.runelite.asm.Field 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;
}
Also used : Field(net.runelite.asm.Field) Method(net.runelite.asm.Method)

Aggregations

Field (net.runelite.asm.Field)65 ClassFile (net.runelite.asm.ClassFile)39 Method (net.runelite.asm.Method)33 Instruction (net.runelite.asm.attributes.code.Instruction)19 InstructionContext (net.runelite.asm.execution.InstructionContext)19 GetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)17 Instructions (net.runelite.asm.attributes.code.Instructions)16 StackContext (net.runelite.asm.execution.StackContext)16 Type (net.runelite.asm.Type)15 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)12 LDC (net.runelite.asm.attributes.code.instructions.LDC)11 Code (net.runelite.asm.attributes.Code)10 SetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction)10 Signature (net.runelite.asm.signature.Signature)9 ClassGroup (net.runelite.asm.ClassGroup)8 FieldInstruction (net.runelite.asm.attributes.code.instruction.types.FieldInstruction)8 PutField (net.runelite.asm.attributes.code.instructions.PutField)8 Test (org.junit.Test)8 List (java.util.List)7 Annotation (net.runelite.asm.attributes.annotation.Annotation)7