Search in sources :

Example 91 with Stack

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

the class AThrow method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    // get exception
    StackContext exception = stack.pop();
    ins.pop(exception);
    frame.stop();
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Example 92 with Stack

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

the class AALoad method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext index = stack.pop();
    StackContext array = stack.pop();
    ins.pop(index, array);
    Type subtype;
    if (array.getType().isArray()) {
        subtype = array.getType().getSubtype();
    } else {
        // This will happen from aaloading from a aconst_null
        subtype = array.getType();
    }
    StackContext ctx = new StackContext(ins, subtype, array.getValue().arrayGet(index.getValue()));
    stack.push(ctx);
    ins.push(ctx);
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) InstructionType(net.runelite.asm.attributes.code.InstructionType) Type(net.runelite.asm.Type) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Example 93 with Stack

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

the class ANewArray method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext count = stack.pop();
    ins.pop(count);
    StackContext ctx = new StackContext(ins, type, Value.newArray(count.getValue()));
    stack.push(ctx);
    ins.push(ctx);
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Example 94 with Stack

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

the class InvokeInterface method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    int count = method.getType().size();
    for (int i = 0; i < count; ++i) {
        StackContext arg = stack.pop();
        ins.pop(arg);
    }
    StackContext object = stack.pop();
    ins.pop(object);
    if (!method.getType().isVoid()) {
        StackContext ctx = new StackContext(ins, method.getType().getReturnValue(), Value.UNKNOWN);
        stack.push(ctx);
        ins.push(ctx);
    }
    for (net.runelite.asm.Method method : getMethods()) {
        ins.invoke(method);
        if (method.getCode() == null) {
            continue;
        }
        // add possible method call to execution
        Execution execution = frame.getExecution();
        execution.invoke(ins, method);
    }
    if (myMethods != null) {
        for (net.runelite.asm.Method method : myMethods) {
            frame.getExecution().order(frame, method);
        }
    }
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) Execution(net.runelite.asm.execution.Execution) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Example 95 with Stack

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

the class InvokeStatic method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    int count = method.getType().size();
    for (int i = 0; i < count; ++i) {
        StackContext arg = stack.pop();
        ins.pop(arg);
    }
    if (!method.getType().isVoid()) {
        StackContext ctx = new StackContext(ins, method.getType().getReturnValue(), Value.UNKNOWN);
        stack.push(ctx);
        ins.push(ctx);
    }
    if (myMethod != null) {
        ins.invoke(myMethod);
        assert myMethod.getCode() != null;
        Execution execution = frame.getExecution();
        if (execution.staticStep) {
            Frame staticFrame = stepInto(frame, ins);
            if (staticFrame != null) {
                // this invokestatic instruction hasn't been added to this frame yet.. so it
                // is not yet in the return frame
                staticFrame.returnTo.addInstructionContext(ins);
                staticFrame.returnTo.nextInstruction();
                // returnTo has already be duped from frame which is why executing remains
                // true and it is able to resume later
                frame.stop();
            }
        } else {
            // add possible method call to execution
            execution.invoke(ins, myMethod);
        }
        frame.getExecution().order(frame, myMethod);
    }
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) Frame(net.runelite.asm.execution.Frame) Execution(net.runelite.asm.execution.Execution) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Aggregations

InstructionContext (net.runelite.asm.execution.InstructionContext)120 Stack (net.runelite.asm.execution.Stack)120 StackContext (net.runelite.asm.execution.StackContext)119 Value (net.runelite.asm.execution.Value)47 Variables (net.runelite.asm.execution.Variables)13 VariableContext (net.runelite.asm.execution.VariableContext)11 Frame (net.runelite.asm.execution.Frame)8 Execution (net.runelite.asm.execution.Execution)4 Instructions (net.runelite.asm.attributes.code.Instructions)3 Test (org.junit.Test)3 Type (net.runelite.asm.Type)2 InstructionType (net.runelite.asm.attributes.code.InstructionType)2 Label (net.runelite.asm.attributes.code.Label)2 Instruction (net.runelite.asm.attributes.code.Instruction)1 ParallelExecutorMapping (net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping)1