cache: some work on the interpreter

This commit is contained in:
Adam
2017-03-07 17:34:34 -05:00
parent 76dcf79e1c
commit 937d27a1e6
21 changed files with 1126 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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);
}
}

View File

@@ -0,0 +1,50 @@
033
load_int 1
if_icmpne LABEL4
jump LABEL5
LABEL4:
return
LABEL5:
load_int 2871
load_int 1
load_int 0
3200
033 1
load_int 1
if_icmpeq LABEL13
jump LABEL20
LABEL13:
025 3985
033 2
iadd
load_int 4
modulo
027 3985
jump LABEL41
LABEL20:
033 1
load_int 2
if_icmpeq LABEL24
jump LABEL31
LABEL24:
025 3986
033 2
iadd
load_int 4
modulo
027 3986
jump LABEL41
LABEL31:
033 1
load_int 3
if_icmpeq LABEL35
jump LABEL41
LABEL35:
025 3987
033 2
iadd
load_int 4
modulo
027 3987
LABEL41:
return