Search in sources :

Example 16 with ClassFile

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

the class InvokeVirtual method lookupMethod.

private net.runelite.asm.Method lookupMethod() {
    ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
    ClassFile otherClass = group.findClass(method.getClazz().getName());
    if (otherClass == null) {
        // not our class
        return null;
    }
    net.runelite.asm.Method m = otherClass.findMethodDeep(method.getName(), method.getType());
    return m;
}
Also used : ClassFile(net.runelite.asm.ClassFile) ClassGroup(net.runelite.asm.ClassGroup)

Example 17 with ClassFile

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

the class InvokeSpecial method lookup.

@Override
public void lookup() {
    myMethod = null;
    ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
    ClassFile otherClass = group.findClass(method.getClazz().getName());
    if (otherClass == null) {
        // not our class
        return;
    }
    net.runelite.asm.Method other = otherClass.findMethod(method.getName(), method.getType());
    if (other == null) {
        return;
    }
    myMethod = other;
}
Also used : ClassFile(net.runelite.asm.ClassFile) ClassGroup(net.runelite.asm.ClassGroup)

Example 18 with ClassFile

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

the class InvokeStatic method lookupMethod.

private net.runelite.asm.Method lookupMethod() {
    ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
    ClassFile otherClass = group.findClass(method.getClazz().getName());
    if (otherClass == null) {
        // not our class
        return null;
    }
    net.runelite.asm.Method other = otherClass.findMethodDeepStatic(method.getName(), method.getType());
    if (other == null) {
        // when regenerating the pool after renaming the method this can be null.
        return null;
    }
    return other;
}
Also used : ClassFile(net.runelite.asm.ClassFile) ClassGroup(net.runelite.asm.ClassGroup)

Example 19 with ClassFile

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

the class UpdateMappingsTest method desc.

private static String desc(ClassGroup cg) {
    int methods = 0, fields = 0, classes = 0;
    for (ClassFile cf : cg.getClasses()) {
        ++classes;
        methods += cf.getMethods().size();
        fields += cf.getFields().size();
    }
    int total = methods + fields + classes;
    return "total: " + total + ", " + methods + " methods, " + fields + " fields, " + classes + " classes";
}
Also used : ClassFile(net.runelite.asm.ClassFile)

Example 20 with ClassFile

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

Aggregations

ClassFile (net.runelite.asm.ClassFile)103 Method (net.runelite.asm.Method)62 Field (net.runelite.asm.Field)39 ClassGroup (net.runelite.asm.ClassGroup)32 Code (net.runelite.asm.attributes.Code)21 Instruction (net.runelite.asm.attributes.code.Instruction)18 Test (org.junit.Test)18 Signature (net.runelite.asm.signature.Signature)17 Type (net.runelite.asm.Type)16 Instructions (net.runelite.asm.attributes.code.Instructions)16 ArrayList (java.util.ArrayList)14 List (java.util.List)13 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 IOException (java.io.IOException)9 InputStream (java.io.InputStream)9 Annotation (net.runelite.asm.attributes.annotation.Annotation)9 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)9 HashMap (java.util.HashMap)8 GetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)7