Search in sources :

Example 61 with InstructionContext

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

the class LSub method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext two = stack.pop();
    StackContext one = stack.pop();
    ins.pop(two, one);
    Value result = Value.UNKNOWN;
    if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull()) {
        long l2 = (long) two.getValue().getValue(), l1 = (long) one.getValue().getValue();
        result = new Value(l1 - l2);
    }
    StackContext ctx = new StackContext(ins, Type.LONG, result);
    stack.push(ctx);
    ins.push(ctx);
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Value(net.runelite.asm.execution.Value) Stack(net.runelite.asm.execution.Stack)

Example 62 with InstructionContext

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

the class InstanceOf method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext obj = stack.pop();
    ins.pop(obj);
    StackContext ctx = new StackContext(ins, Type.INT, Value.UNKNOWN);
    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 63 with InstructionContext

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

the class InvokeSpecial 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);
    }
    if (myMethod != null) {
        ins.invoke(myMethod);
        assert myMethod.getCode() != null;
        // add possible method call to execution
        Execution execution = frame.getExecution();
        execution.invoke(ins, myMethod);
        frame.getExecution().order(frame, myMethod);
    }
    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 64 with InstructionContext

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

the class InvokeStatic method map.

@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) {
    List<net.runelite.asm.Method> myMethods = this.getMethods(), otherMethods = ((InvokeStatic) other.getInstruction()).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);
            }
        }
    }
}
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)

Example 65 with InstructionContext

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

the class GetField method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext object = stack.pop();
    ins.pop(object);
    StackContext ctx = new StackContext(ins, field.getType(), Value.UNKNOWN);
    stack.push(ctx);
    ins.push(ctx);
    if (myField != null) {
        frame.getExecution().order(frame, myField);
    }
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Aggregations

InstructionContext (net.runelite.asm.execution.InstructionContext)179 StackContext (net.runelite.asm.execution.StackContext)153 Stack (net.runelite.asm.execution.Stack)120 Value (net.runelite.asm.execution.Value)48 Field (net.runelite.asm.Field)18 Instruction (net.runelite.asm.attributes.code.Instruction)18 Variables (net.runelite.asm.execution.Variables)16 GetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)15 VariableContext (net.runelite.asm.execution.VariableContext)14 Instructions (net.runelite.asm.attributes.code.Instructions)12 Frame (net.runelite.asm.execution.Frame)12 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)11 Execution (net.runelite.asm.execution.Execution)11 LVTInstruction (net.runelite.asm.attributes.code.instruction.types.LVTInstruction)9 InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)8 IMul (net.runelite.asm.attributes.code.instructions.IMul)7 ClassFile (net.runelite.asm.ClassFile)6 Method (net.runelite.asm.Method)6 Label (net.runelite.asm.attributes.code.Label)6 DupInstruction (net.runelite.asm.attributes.code.instruction.types.DupInstruction)6