Search in sources :

Example 1 with VariableContext

use of net.runelite.asm.execution.VariableContext in project runelite by runelite.

the class DLoad method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    Variables variables = frame.getVariables();
    VariableContext vctx = variables.get(index);
    assert vctx.getType().equals(Type.DOUBLE);
    ins.read(vctx);
    StackContext ctx = new StackContext(ins, vctx);
    stack.push(ctx);
    ins.push(ctx);
    return ins;
}
Also used : Variables(net.runelite.asm.execution.Variables) InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) VariableContext(net.runelite.asm.execution.VariableContext) Stack(net.runelite.asm.execution.Stack)

Example 2 with VariableContext

use of net.runelite.asm.execution.VariableContext in project runelite by runelite.

the class DStore method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    Variables variables = frame.getVariables();
    StackContext value = stack.pop();
    ins.pop(value);
    variables.set(index, new VariableContext(ins, value));
    return ins;
}
Also used : Variables(net.runelite.asm.execution.Variables) InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) VariableContext(net.runelite.asm.execution.VariableContext) Stack(net.runelite.asm.execution.Stack)

Example 3 with VariableContext

use of net.runelite.asm.execution.VariableContext in project runelite by runelite.

the class ALoad method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    Variables var = frame.getVariables();
    VariableContext vctx = var.get(index);
    ins.read(vctx);
    StackContext ctx = new StackContext(ins, vctx);
    stack.push(ctx);
    ins.push(ctx);
    return ins;
}
Also used : Variables(net.runelite.asm.execution.Variables) InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) VariableContext(net.runelite.asm.execution.VariableContext) Stack(net.runelite.asm.execution.Stack)

Example 4 with VariableContext

use of net.runelite.asm.execution.VariableContext in project runelite by runelite.

the class AStore method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    Variables variables = frame.getVariables();
    StackContext object = stack.pop();
    ins.pop(object);
    variables.set(index, new VariableContext(ins, object));
    return ins;
}
Also used : Variables(net.runelite.asm.execution.Variables) InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) VariableContext(net.runelite.asm.execution.VariableContext) Stack(net.runelite.asm.execution.Stack)

Example 5 with VariableContext

use of net.runelite.asm.execution.VariableContext in project runelite by runelite.

the class MappingExecutorUtil method resolve.

public static InstructionContext resolve(InstructionContext ctx, // pushed from ctx
StackContext from) {
    if (ctx.getInstruction() instanceof SetFieldInstruction) {
        StackContext s = ctx.getPops().get(0);
        return resolve(s.getPushed(), s);
    }
    if (ctx.getInstruction() instanceof ConversionInstruction) {
        // assume it pops one and pushes one
        StackContext s = ctx.getPops().get(0);
        return resolve(s.getPushed(), s);
    }
    if (ctx.getInstruction() instanceof DupInstruction) {
        DupInstruction d = (DupInstruction) ctx.getInstruction();
        StackContext s = d.getOriginal(from);
        return resolve(s.getPushed(), s);
    }
    if (ctx.getInstruction() instanceof ArrayLoad) {
        // might be multidimensional array
        // the array
        StackContext s = ctx.getPops().get(1);
        return resolve(s.getPushed(), s);
    }
    if (ctx.getInstruction() instanceof LVTInstruction) {
        LVTInstruction lvt = (LVTInstruction) ctx.getInstruction();
        Variables variables = ctx.getVariables();
        if (lvt.store()) {
            // is this right?
            StackContext s = ctx.getPops().get(0);
            return resolve(s.getPushed(), s);
        } else {
            // variable being loaded
            VariableContext vctx = variables.get(lvt.getVariableIndex());
            assert vctx != null;
            InstructionContext storedCtx = vctx.getInstructionWhichStored();
            if (storedCtx == null)
                // initial parameter
                return ctx;
            if (vctx.isIsParameter()) {
                // this storedCtx is the invoke instruction which called this method.
                assert storedCtx.getInstruction() instanceof InvokeInstruction;
                // In PME non static functions are never stepped into/aren't inline obfuscated
                assert storedCtx.getInstruction() instanceof InvokeStatic;
                // Figure out parameter index from variable index.
                // signature of current method
                Signature sig = ctx.getFrame().getMethod().getDescriptor();
                int paramIndex = 0;
                for (int lvtIndex = 0; /* static */
                paramIndex < sig.size(); lvtIndex += sig.getTypeOfArg(paramIndex++).getSize()) if (lvtIndex == lvt.getVariableIndex())
                    break;
                assert paramIndex < sig.size();
                // Get stack context that was popped by the invoke
                // pops[0] is the first thing popped, which is the last parameter.
                StackContext sctx = storedCtx.getPops().get(sig.size() - 1 - paramIndex);
                return resolve(sctx.getPushed(), sctx);
            }
            return resolve(storedCtx, null);
        }
    }
    if (ctx.getInstruction() instanceof InvokeStatic) {
        if (from.returnSource != null) {
            return resolve(from.returnSource.getPushed(), from.returnSource);
        }
    }
    return ctx;
}
Also used : ArrayLoad(net.runelite.asm.attributes.code.instruction.types.ArrayLoad) InstructionContext(net.runelite.asm.execution.InstructionContext) SetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction) ConversionInstruction(net.runelite.asm.attributes.code.instruction.types.ConversionInstruction) DupInstruction(net.runelite.asm.attributes.code.instruction.types.DupInstruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) VariableContext(net.runelite.asm.execution.VariableContext) Variables(net.runelite.asm.execution.Variables) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) StackContext(net.runelite.asm.execution.StackContext) Signature(net.runelite.asm.signature.Signature) InvokeStatic(net.runelite.asm.attributes.code.instructions.InvokeStatic)

Aggregations

InstructionContext (net.runelite.asm.execution.InstructionContext)14 VariableContext (net.runelite.asm.execution.VariableContext)14 Variables (net.runelite.asm.execution.Variables)14 StackContext (net.runelite.asm.execution.StackContext)13 Stack (net.runelite.asm.execution.Stack)11 DupInstruction (net.runelite.asm.attributes.code.instruction.types.DupInstruction)2 LVTInstruction (net.runelite.asm.attributes.code.instruction.types.LVTInstruction)2 Value (net.runelite.asm.execution.Value)2 Instruction (net.runelite.asm.attributes.code.Instruction)1 Instructions (net.runelite.asm.attributes.code.Instructions)1 ArrayLoad (net.runelite.asm.attributes.code.instruction.types.ArrayLoad)1 ConversionInstruction (net.runelite.asm.attributes.code.instruction.types.ConversionInstruction)1 GetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)1 InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)1 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)1 SetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction)1 BiPush (net.runelite.asm.attributes.code.instructions.BiPush)1 IAdd (net.runelite.asm.attributes.code.instructions.IAdd)1 IInc (net.runelite.asm.attributes.code.instructions.IInc)1 ISub (net.runelite.asm.attributes.code.instructions.ISub)1