From 4624371bf94c047c0fa488daac8686ec7a39b1f8 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 20:30:52 -0500 Subject: [PATCH] cache: remove script interpreter It is unfinished and probably not something I want to complete soon --- .../cache/script/interpreter/Frame.java | 98 ---------------- .../GenericInstructionHandler.java | 80 ------------- .../interpreter/InstructionContext.java | 101 ---------------- .../interpreter/InstructionHandler.java | 30 ----- .../interpreter/InstructionHandlers.java | 78 ------------ .../cache/script/interpreter/Interpreter.java | 111 ------------------ .../script/interpreter/ScriptInstruction.java | 68 ----------- .../cache/script/interpreter/Stack.java | 57 --------- .../script/interpreter/StackContext.java | 62 ---------- .../script/interpreter/VariableContext.java | 30 ----- .../cache/script/interpreter/Variables.java | 42 ------- .../script/interpreter/instructions/If.java | 51 -------- .../interpreter/instructions/If_ICmpEQ.java | 30 ----- .../interpreter/instructions/If_ICmpGE.java | 30 ----- .../interpreter/instructions/If_ICmpGT.java | 30 ----- .../interpreter/instructions/If_ICmpLE.java | 30 ----- .../interpreter/instructions/If_ICmpLT.java | 30 ----- .../interpreter/instructions/If_ICmpNE.java | 30 ----- .../interpreter/instructions/Invoke.java | 50 -------- .../script/interpreter/instructions/Jump.java | 40 ------- .../interpreter/instructions/LoadInt.java | 46 -------- .../interpreter/instructions/Return.java | 41 ------- .../instructions/StringAppend.java | 56 --------- .../interpreter/instructions/Switch.java | 62 ---------- .../script/interpreter/InterpreterTest.java | 49 -------- .../cache/script/interpreter/397.rs2asm | 54 --------- 26 files changed, 1386 deletions(-) delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/Frame.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/GenericInstructionHandler.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/InstructionContext.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandler.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandlers.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/Interpreter.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/ScriptInstruction.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/Stack.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/StackContext.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/VariableContext.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/Variables.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpEQ.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGE.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGT.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLE.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLT.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpNE.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Invoke.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Jump.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/LoadInt.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Return.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/StringAppend.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Switch.java delete mode 100644 cache/src/test/java/net/runelite/cache/script/interpreter/InterpreterTest.java delete mode 100644 cache/src/test/resources/net/runelite/cache/script/interpreter/397.rs2asm diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/Frame.java b/cache/src/main/java/net/runelite/cache/script/interpreter/Frame.java deleted file mode 100644 index 62d2b2253b..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/Frame.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import net.runelite.cache.definitions.ScriptDefinition; - -public class Frame -{ - private final Interpreter interpreter; - private final ScriptDefinition script; - private final Stack intStack; - private final Stack stringStack; - private final Variables intVariables; - private final Variables stringVariables; - - private boolean running = true; - int pc; - - public Frame(Interpreter interpreter, ScriptDefinition script) - { - this.interpreter = interpreter; - this.script = script; - this.intStack = new Stack(); - this.stringStack = new Stack(); - this.intVariables = new Variables(script.getLocalIntCount()); - this.stringVariables = new Variables(script.getLocalStringCount()); - } - - public Frame(Interpreter interpreter, Frame other) - { - this.interpreter = interpreter; - this.script = other.script; - this.intStack = new Stack(other.intStack); - this.stringStack = new Stack(other.stringStack); - this.intVariables = new Variables(other.intVariables); - this.stringVariables = new Variables(other.stringVariables); - this.pc = other.pc; - } - - public Stack getIntStack() - { - return intStack; - } - - public Stack getStringStack() - { - return stringStack; - } - - public ScriptDefinition getScript() - { - return script; - } - - public Frame dup() - { - Frame frame = new Frame(interpreter, this); - interpreter.addFrame(this); - return frame; - } - - public boolean isRunning() - { - return running; - } - - public void stop() - { - running = false; - } - - public void jump(int offset) - { - pc += offset + 1; - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/GenericInstructionHandler.java b/cache/src/main/java/net/runelite/cache/script/interpreter/GenericInstructionHandler.java deleted file mode 100644 index ff93744fcb..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/GenericInstructionHandler.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import net.runelite.cache.script.Instruction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GenericInstructionHandler extends InstructionHandler -{ - private static final Logger logger = LoggerFactory.getLogger(GenericInstructionHandler.class); - - @Override - public void execute(Frame frame, InstructionContext ctx) - { - Instruction i = ctx.getScriptInstruction().getInstruction(); - Stack istack = frame.getIntStack(); - Stack sstack = frame.getStringStack(); - - int ipops = i.getIntStackPops(); - for (int j = 0; j < ipops; ++j) - { - StackContext value = istack.pop(); - ctx.popsInt(value); - value.poppedBy(ctx); - } - - int spops = i.getStringStackPops(); - for (int j = 0; j < spops; ++j) - { - StackContext value = sstack.pop(); - ctx.popsString(value); - value.poppedBy(ctx); - } - - int ipushes = i.getIntStackPushes(); - for (int j = 0; j < ipushes; ++j) - { - StackContext sctx = new StackContext(ctx, null); - istack.push(sctx); - ctx.pushesInt(sctx); - } - - int spushes = i.getStringStackPushes(); - for (int j = 0; j < spushes; ++j) - { - StackContext sctx = new StackContext(ctx, null); - sstack.push(sctx); - ctx.pushesString(sctx); - } - - if (ipushes > 0 || spushes > 0) - { - logger.debug("Executed instruction {} with {}/{} pushes!", i, ipushes, spushes); - } - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionContext.java b/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionContext.java deleted file mode 100644 index 9387346a67..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionContext.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.ArrayList; -import java.util.List; - -public class InstructionContext -{ - private final ScriptInstruction scriptInstruction; - - private final List ipops = new ArrayList<>(); - private final List spops = new ArrayList<>(); - private final List ipushes = new ArrayList<>(); - private final List spushes = new ArrayList<>(); - - public InstructionContext(ScriptInstruction scriptInstruction) - { - this.scriptInstruction = scriptInstruction; - } - - public ScriptInstruction getScriptInstruction() - { - return scriptInstruction; - } - - public void popsInt(StackContext... ctx) - { - for (StackContext s : ctx) - { - ipops.add(s); - } - } - - public void popsString(StackContext... ctx) - { - for (StackContext s : ctx) - { - spops.add(s); - } - } - - public void pushesInt(StackContext... ctx) - { - for (StackContext s : ctx) - { - ipushes.add(s); - } - } - - public void pushesString(StackContext... ctx) - { - for (StackContext s : ctx) - { - spushes.add(s); - } - - } - - public List getIpops() - { - return ipops; - } - - public List getSpops() - { - return spops; - } - - public List getIpushes() - { - return ipushes; - } - - public List getSpushes() - { - return spushes; - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandler.java b/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandler.java deleted file mode 100644 index 82f468d1b8..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -public abstract class InstructionHandler -{ - public abstract void execute(Frame frame, InstructionContext ctx); -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandlers.java b/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandlers.java deleted file mode 100644 index 0aca6ff803..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandlers.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.HashMap; -import java.util.Map; -import net.runelite.cache.script.Opcodes; -import net.runelite.cache.script.interpreter.instructions.If_ICmpEQ; -import net.runelite.cache.script.interpreter.instructions.If_ICmpGE; -import net.runelite.cache.script.interpreter.instructions.If_ICmpGT; -import net.runelite.cache.script.interpreter.instructions.If_ICmpLE; -import net.runelite.cache.script.interpreter.instructions.If_ICmpLT; -import net.runelite.cache.script.interpreter.instructions.If_ICmpNE; -import net.runelite.cache.script.interpreter.instructions.Invoke; -import net.runelite.cache.script.interpreter.instructions.Jump; -import net.runelite.cache.script.interpreter.instructions.LoadInt; -import net.runelite.cache.script.interpreter.instructions.Return; -import net.runelite.cache.script.interpreter.instructions.StringAppend; -import net.runelite.cache.script.interpreter.instructions.Switch; - -public class InstructionHandlers -{ - private static final Map handlers = new HashMap<>(); - - static - { - init(); - } - - private static void init() - { - add(Opcodes.LOAD_INT, new LoadInt()); - add(Opcodes.JUMP, new Jump()); - add(Opcodes.IF_ICMPNE, new If_ICmpNE()); - add(Opcodes.IF_ICMPEQ, new If_ICmpEQ()); - add(Opcodes.IF_ICMPLT, new If_ICmpLT()); - add(Opcodes.IF_ICMPGT, new If_ICmpGT()); - add(Opcodes.IF_ICMPLE, new If_ICmpLE()); - add(Opcodes.IF_ICMPGE, new If_ICmpGE()); - add(Opcodes.INVOKE, new Invoke()); - add(Opcodes.RETURN, new Return()); - add(Opcodes.SWITCH, new Switch()); - add(Opcodes.STRING_APPEND, new StringAppend()); - } - - private static void add(int opcode, InstructionHandler handler) - { - assert handlers.containsKey(opcode) == false; - handlers.put(opcode, handler); - } - - public static InstructionHandler find(int opcode) - { - return handlers.get(opcode); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/Interpreter.java b/cache/src/main/java/net/runelite/cache/script/interpreter/Interpreter.java deleted file mode 100644 index 6e923f4db4..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/Interpreter.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.ArrayDeque; -import java.util.Queue; -import net.runelite.cache.definitions.ScriptDefinition; -import net.runelite.cache.script.Instruction; -import net.runelite.cache.script.Instructions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Interpreter -{ - private static final Logger logger = LoggerFactory.getLogger(Interpreter.class); - - private final Queue frames = new ArrayDeque<>(); - private final GenericInstructionHandler genericInstructionHandler = new GenericInstructionHandler(); - - public void run(ScriptDefinition script) - { - Instructions.init(); - - Frame frame = new Frame(this, script); - frames.add(frame); - - int count = 0; - - while (!frames.isEmpty()) - { - frame = frames.remove(); - run(frame); - ++count; - } - - logger.info("Processed {} frames", count); - } - - private void run(Frame frame) - { - ScriptDefinition script = frame.getScript(); - - int[] instructions = script.getInstructions(); - int[] iops = script.getIntOperands(); - String[] sops = script.getStringOperands(); - - while (frame.isRunning()) - { - if (frame.pc >= instructions.length) - { - throw new RuntimeException("PC went past end of instructions - maybe missing return"); - } - - int opcode = instructions[frame.pc]; - int iop = iops[frame.pc]; - String sop = sops[frame.pc]; - - Instruction i = Instructions.find(opcode); - if (i == null) - { - throw new RuntimeException("Unknown instruction " + opcode + " in script at pc " + frame.pc); - } - - ScriptInstruction scriptInstruction = new ScriptInstruction(frame.pc, i, iop, sop); - InstructionContext ctx = new InstructionContext(scriptInstruction); - - InstructionHandler handler = InstructionHandlers.find(opcode); - if (handler == null) - { - handler = genericInstructionHandler; - } - - int old = frame.pc; - - handler.execute(frame, ctx); - - if (old == frame.pc) - { - // not a jump - ++frame.pc; - } - } - } - - public void addFrame(Frame frame) - { - frames.add(frame); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/ScriptInstruction.java b/cache/src/main/java/net/runelite/cache/script/interpreter/ScriptInstruction.java deleted file mode 100644 index d59ddc2640..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/ScriptInstruction.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import net.runelite.cache.script.Instruction; - -/** - * an instruction in a script - * - * @author Adam - */ -public class ScriptInstruction -{ - private final int pc; - private final Instruction instruction; - private final int iop; - private final String sop; - - public ScriptInstruction(int pc, Instruction instruction, int iop, String sop) - { - this.pc = pc; - this.instruction = instruction; - this.iop = iop; - this.sop = sop; - } - - public int getPc() - { - return pc; - } - - public Instruction getInstruction() - { - return instruction; - } - - public int getIop() - { - return iop; - } - - public String getSop() - { - return sop; - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/Stack.java b/cache/src/main/java/net/runelite/cache/script/interpreter/Stack.java deleted file mode 100644 index 49fd0010e4..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/Stack.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.ArrayList; -import java.util.List; - -public class Stack -{ - private final List stack = new ArrayList<>(); - - public Stack() - { - } - - public Stack(Stack other) - { - stack.addAll(other.stack); - } - - public void push(StackContext ctx) - { - stack.add(ctx); - } - - public StackContext pop() - { - if (stack.isEmpty()) - { - throw new RuntimeException("stack underflow"); - } - - return stack.remove(stack.size() - 1); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/StackContext.java b/cache/src/main/java/net/runelite/cache/script/interpreter/StackContext.java deleted file mode 100644 index 63349240ae..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/StackContext.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.ArrayList; -import java.util.List; - -public class StackContext -{ - private final InstructionContext pushed; - private final List popped = new ArrayList<>(); - private final Object value; - - public StackContext(InstructionContext pushed, Object value) - { - assert value == null || value instanceof String || value instanceof Integer; - this.pushed = pushed; - this.value = value; - } - - public void poppedBy(InstructionContext ctx) - { - popped.add(ctx); - } - - public InstructionContext getPushed() - { - return pushed; - } - - public List getPopped() - { - return popped; - } - - public Object getValue() - { - return value; - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/VariableContext.java b/cache/src/main/java/net/runelite/cache/script/interpreter/VariableContext.java deleted file mode 100644 index 44c05fb14e..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/VariableContext.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -public class VariableContext -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/Variables.java b/cache/src/main/java/net/runelite/cache/script/interpreter/Variables.java deleted file mode 100644 index 4bb38ed436..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/Variables.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.Arrays; - -public class Variables -{ - private final VariableContext[] variables; - - public Variables(int count) - { - variables = new VariableContext[count]; - } - - public Variables(Variables other) - { - variables = Arrays.copyOf(other.variables, other.variables.length); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If.java deleted file mode 100644 index b949fb95ef..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.Stack; -import net.runelite.cache.script.interpreter.StackContext; - -public abstract class If extends InstructionHandler -{ - @Override - public final void execute(Frame frame, InstructionContext ctx) - { - Stack intStack = frame.getIntStack(); - int iop = ctx.getScriptInstruction().getIop(); - - StackContext sctx1 = intStack.pop(); - StackContext sctx2 = intStack.pop(); - - ctx.popsInt(sctx1, sctx2); - sctx1.poppedBy(ctx); - sctx2.poppedBy(ctx); - - Frame dup = frame.dup(); - dup.jump(iop); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpEQ.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpEQ.java deleted file mode 100644 index ca6fc4a731..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpEQ.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpEQ extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGE.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGE.java deleted file mode 100644 index 9f0ae98e3c..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGE.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpGE extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGT.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGT.java deleted file mode 100644 index d3e0fcbe61..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGT.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpGT extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLE.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLE.java deleted file mode 100644 index 0e2b87e4d1..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLE.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpLE extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLT.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLT.java deleted file mode 100644 index 29d63ab4a0..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLT.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpLT extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpNE.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpNE.java deleted file mode 100644 index e155845379..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpNE.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpNE extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Invoke.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Invoke.java deleted file mode 100644 index e32665ee8a..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Invoke.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.ScriptInstruction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Invoke extends InstructionHandler -{ - private static final Logger logger = LoggerFactory.getLogger(Invoke.class); - - @Override - public void execute(Frame frame, InstructionContext ctx) - { - ScriptInstruction scriptInstruction = ctx.getScriptInstruction(); - - int scriptToInvoke = scriptInstruction.getIop(); - - // copy new script's intStackCount/stringStackCount to the new LVT, and pop from caller's stack - - logger.warn("Invoke not implemented yet"); - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Jump.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Jump.java deleted file mode 100644 index e88d8febd7..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Jump.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; - -public class Jump extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - int iop = ctx.getScriptInstruction().getIop(); - frame.jump(iop); - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/LoadInt.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/LoadInt.java deleted file mode 100644 index 7122bdb523..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/LoadInt.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.Stack; -import net.runelite.cache.script.interpreter.StackContext; - -public class LoadInt extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - Stack intStack = frame.getIntStack(); - int iop = ctx.getScriptInstruction().getIop(); - - StackContext sctx = new StackContext(ctx, iop); - ctx.pushesInt(sctx); - - intStack.push(sctx); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Return.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Return.java deleted file mode 100644 index a123c4e40f..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Return.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; - -public class Return extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - frame.stop(); - - // restore lvt from calling script. return value is on the stack. - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/StringAppend.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/StringAppend.java deleted file mode 100644 index 1cdc88a4f8..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/StringAppend.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.ScriptInstruction; -import net.runelite.cache.script.interpreter.Stack; -import net.runelite.cache.script.interpreter.StackContext; - -public class StringAppend extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - Stack stringStack = frame.getStringStack(); - ScriptInstruction scriptInstruction = ctx.getScriptInstruction(); - int number = scriptInstruction.getIop(); - - for (int i = 0; i < number; ++i) - { - StackContext sctx = stringStack.pop(); - ctx.popsString(sctx); - sctx.poppedBy(ctx); - } - - // push appended string - StackContext sctx = new StackContext(ctx, null); - stringStack.push(sctx); - ctx.pushesString(sctx); - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Switch.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Switch.java deleted file mode 100644 index 519c91a4ee..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Switch.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import java.util.Map; -import net.runelite.cache.definitions.ScriptDefinition; -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.ScriptInstruction; -import net.runelite.cache.script.interpreter.Stack; -import net.runelite.cache.script.interpreter.StackContext; - -public class Switch extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - Stack intStack = frame.getIntStack(); - ScriptInstruction scriptInstruction = ctx.getScriptInstruction(); - ScriptDefinition script = frame.getScript(); - int switchTableIndex = scriptInstruction.getIop(); - - // value -> pc - Map switchTable = script.getSwitches()[switchTableIndex]; - - // pop value off stack - StackContext sctx = intStack.pop(); - ctx.popsInt(sctx); - sctx.poppedBy(ctx); - - // jump to targets - for (int target : switchTable.values()) - { - Frame dup = frame.dup(); - dup.jump(target); - } - } - -} diff --git a/cache/src/test/java/net/runelite/cache/script/interpreter/InterpreterTest.java b/cache/src/test/java/net/runelite/cache/script/interpreter/InterpreterTest.java deleted file mode 100644 index 61012a70f2..0000000000 --- a/cache/src/test/java/net/runelite/cache/script/interpreter/InterpreterTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.io.IOException; -import java.io.InputStream; -import net.runelite.cache.definitions.ScriptDefinition; -import net.runelite.cache.script.assembler.Assembler; -import org.junit.Assert; -import org.junit.Test; - -public class InterpreterTest -{ - @Test - public void testRun() throws IOException - { - InputStream in = InterpreterTest.class.getResourceAsStream("397.rs2asm"); - Assert.assertNotNull(in); - - Assembler assembler = new Assembler(); - ScriptDefinition script = assembler.assemble(in); - - Interpreter interpreter = new Interpreter(); - interpreter.run(script); - } - -} diff --git a/cache/src/test/resources/net/runelite/cache/script/interpreter/397.rs2asm b/cache/src/test/resources/net/runelite/cache/script/interpreter/397.rs2asm deleted file mode 100644 index c71842b4f3..0000000000 --- a/cache/src/test/resources/net/runelite/cache/script/interpreter/397.rs2asm +++ /dev/null @@ -1,54 +0,0 @@ -.int_stack_count 3 -.string_stack_count 0 -.int_var_count 3 -.string_var_count 0 - iload 0 - load_int 1 - if_icmpne LABEL4 - jump LABEL5 -LABEL4: - return -LABEL5: - load_int 2871 - load_int 1 - load_int 0 - 3200 - iload 1 - load_int 1 - if_icmpeq LABEL13 - jump LABEL20 -LABEL13: - get_varbit 3985 - iload 2 - iadd - load_int 4 - modulo - set_varbit 3985 - jump LABEL41 -LABEL20: - iload 1 - load_int 2 - if_icmpeq LABEL24 - jump LABEL31 -LABEL24: - get_varbit 3986 - iload 2 - iadd - load_int 4 - modulo - set_varbit 3986 - jump LABEL41 -LABEL31: - iload 1 - load_int 3 - if_icmpeq LABEL35 - jump LABEL41 -LABEL35: - get_varbit 3987 - iload 2 - iadd - load_int 4 - modulo - set_varbit 3987 -LABEL41: - return