Search in sources :

Example 16 with GetFieldInstruction

use of net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction in project runelite by runelite.

the class InvokeInterface method map.

@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) {
    InvokeInterface otherIv = (InvokeInterface) other.getInstruction();
    List<net.runelite.asm.Method> myMethods = this.getMethods(), otherMethods = otherIv.getMethods();
    assert myMethods.size() == otherMethods.size();
    for (int i = 0; i < myMethods.size(); ++i) {
        net.runelite.asm.Method m1 = myMethods.get(i), otherMethod = null;
        ClassFile c1 = m1.getClassFile();
        if (myMethods.size() == 1) {
            otherMethod = otherMethods.get(0);
        } else {
            for (int j = 0; j < myMethods.size(); ++j) {
                net.runelite.asm.Method m2 = otherMethods.get(j);
                ClassFile c2 = m2.getClassFile();
                if (MappingExecutorUtil.isMaybeEqual(c1, c2)) {
                    if (otherMethod != null) {
                        otherMethod = null;
                        break;
                    }
                    otherMethod = m2;
                }
            }
        }
        if (otherMethod != null) {
            mapping.map(this, m1, otherMethod);
        }
    }
    for (int i = 0; i < ctx.getPops().size(); ++i) {
        StackContext s1 = ctx.getPops().get(i), s2 = other.getPops().get(i);
        InstructionContext base1 = MappingExecutorUtil.resolve(s1.getPushed(), s1);
        InstructionContext base2 = MappingExecutorUtil.resolve(s2.getPushed(), s2);
        if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) {
            GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), gf2 = (GetFieldInstruction) base2.getInstruction();
            Field f1 = gf1.getMyField(), f2 = gf2.getMyField();
            if (f1 != null && f2 != null) {
                mapping.map(this, f1, f2);
            }
        }
    }
    /* map field that was invoked on */
    StackContext object1 = ctx.getPops().get(method.getType().size()), object2 = other.getPops().get(otherIv.method.getType().size());
    InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
    InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
    if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) {
        GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), gf2 = (GetFieldInstruction) base2.getInstruction();
        Field f1 = gf1.getMyField(), f2 = gf2.getMyField();
        if (f1 != null && f2 != null) {
            mapping.map(this, f1, f2);
        }
    }
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) ClassFile(net.runelite.asm.ClassFile) Method(net.runelite.asm.pool.Method) Field(net.runelite.asm.Field) StackContext(net.runelite.asm.execution.StackContext) GetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)

Example 17 with GetFieldInstruction

use of net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction in project runelite by runelite.

the class InvokeSpecial method map.

@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) {
    InvokeSpecial otherIv = (InvokeSpecial) other.getInstruction();
    List<net.runelite.asm.Method> myMethods = this.getMethods(), otherMethods = otherIv.getMethods();
    assert myMethods.size() == otherMethods.size();
    for (int i = 0; i < myMethods.size(); ++i) {
        mapping.map(this, myMethods.get(i), otherMethods.get(i));
    }
    for (int i = 0; i < ctx.getPops().size(); ++i) {
        StackContext s1 = ctx.getPops().get(i), s2 = other.getPops().get(i);
        InstructionContext base1 = MappingExecutorUtil.resolve(s1.getPushed(), s1);
        InstructionContext base2 = MappingExecutorUtil.resolve(s2.getPushed(), s2);
        if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) {
            GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), gf2 = (GetFieldInstruction) base2.getInstruction();
            Field f1 = gf1.getMyField(), f2 = gf2.getMyField();
            if (f1 != null && f2 != null) {
                mapping.map(this, f1, f2);
            }
        }
    }
    /* map field that was invoked on */
    StackContext object1 = ctx.getPops().get(method.getType().size()), object2 = other.getPops().get(otherIv.method.getType().size());
    InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
    InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
    if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) {
        GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), gf2 = (GetFieldInstruction) base2.getInstruction();
        Field f1 = gf1.getMyField(), f2 = gf2.getMyField();
        if (f1 != null && f2 != null) {
            mapping.map(this, f1, f2);
        }
    }
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) Field(net.runelite.asm.Field) StackContext(net.runelite.asm.execution.StackContext) Method(net.runelite.asm.pool.Method) GetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)

Aggregations

GetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)17 Field (net.runelite.asm.Field)13 InstructionContext (net.runelite.asm.execution.InstructionContext)13 StackContext (net.runelite.asm.execution.StackContext)11 ClassFile (net.runelite.asm.ClassFile)5 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)5 LDC (net.runelite.asm.attributes.code.instructions.LDC)5 Method (net.runelite.asm.pool.Method)5 Instruction (net.runelite.asm.attributes.code.Instruction)4 SetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction)4 Method (net.runelite.asm.Method)3 Instructions (net.runelite.asm.attributes.code.Instructions)3 FieldInstruction (net.runelite.asm.attributes.code.instruction.types.FieldInstruction)3 InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ClassGroup (net.runelite.asm.ClassGroup)2 Type (net.runelite.asm.Type)2 Code (net.runelite.asm.attributes.Code)2