cache: add switch instruction
This commit is contained in:
@@ -30,17 +30,34 @@ import net.runelite.cache.script.disassembler.Disassembler;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class AssemblerTest
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(AssemblerTest.class);
|
||||
|
||||
@Parameter
|
||||
public String script;
|
||||
|
||||
@Parameters
|
||||
public static String[] scripts()
|
||||
{
|
||||
return new String[]
|
||||
{
|
||||
"395.rs2asm", "91.rs2asm"
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssemble() throws Exception
|
||||
{
|
||||
InputStream in = AssemblerTest.class.getResourceAsStream("395.rs2asm");
|
||||
InputStream in = AssemblerTest.class.getResourceAsStream(script);
|
||||
Assert.assertNotNull(in);
|
||||
|
||||
Assembler assembler = new Assembler();
|
||||
@@ -50,7 +67,7 @@ public class AssemblerTest
|
||||
Disassembler disassembler = new Disassembler();
|
||||
String out = disassembler.disassemble(script);
|
||||
|
||||
in = AssemblerTest.class.getResourceAsStream("395.rs2asm");
|
||||
in = AssemblerTest.class.getResourceAsStream(this.script);
|
||||
Assert.assertNotNull(in);
|
||||
|
||||
String original = new String(IOUtils.toByteArray(in));
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
.attr 4 8 15
|
||||
.attr 16 23 42
|
||||
033
|
||||
get_boostedskilllevels
|
||||
int_to_string
|
||||
|
||||
117
cache/src/test/resources/net/runelite/cache/script/assembler/91.rs2asm
vendored
Normal file
117
cache/src/test/resources/net/runelite/cache/script/assembler/91.rs2asm
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
033
|
||||
switch
|
||||
3: LABEL20
|
||||
5: LABEL54
|
||||
6: LABEL54
|
||||
7: LABEL3
|
||||
jump LABEL84
|
||||
LABEL3:
|
||||
033 1
|
||||
042 175
|
||||
if_icmplt LABEL7
|
||||
jump LABEL9
|
||||
LABEL7:
|
||||
load_int 0
|
||||
return
|
||||
LABEL9:
|
||||
035
|
||||
string_remove_html
|
||||
3623
|
||||
load_int 1
|
||||
if_icmpeq LABEL15
|
||||
jump LABEL17
|
||||
LABEL15:
|
||||
load_int 0
|
||||
return
|
||||
LABEL17:
|
||||
load_int 1
|
||||
return
|
||||
jump LABEL84
|
||||
LABEL20:
|
||||
033 1
|
||||
042 175
|
||||
if_icmplt LABEL24
|
||||
jump LABEL26
|
||||
LABEL24:
|
||||
load_int 0
|
||||
return
|
||||
LABEL26:
|
||||
035
|
||||
string_remove_html
|
||||
3623
|
||||
load_int 1
|
||||
if_icmpeq LABEL32
|
||||
jump LABEL34
|
||||
LABEL32:
|
||||
load_int 0
|
||||
return
|
||||
LABEL34:
|
||||
5005
|
||||
load_int 0
|
||||
if_icmpeq LABEL38
|
||||
jump LABEL40
|
||||
LABEL38:
|
||||
load_int 1
|
||||
return
|
||||
LABEL40:
|
||||
5005
|
||||
load_int 1
|
||||
if_icmpeq LABEL44
|
||||
jump LABEL51
|
||||
LABEL44:
|
||||
035
|
||||
3609
|
||||
load_int 1
|
||||
if_icmpeq LABEL49
|
||||
jump LABEL51
|
||||
LABEL49:
|
||||
load_int 1
|
||||
return
|
||||
LABEL51:
|
||||
load_int 0
|
||||
return
|
||||
jump LABEL84
|
||||
LABEL54:
|
||||
033 1
|
||||
042 175
|
||||
if_icmplt LABEL58
|
||||
jump LABEL60
|
||||
LABEL58:
|
||||
load_int 0
|
||||
return
|
||||
LABEL60:
|
||||
033
|
||||
load_int 5
|
||||
if_icmpeq LABEL64
|
||||
jump LABEL76
|
||||
LABEL64:
|
||||
025 1627
|
||||
load_int 0
|
||||
if_icmpeq LABEL68
|
||||
jump LABEL76
|
||||
LABEL68:
|
||||
get_gamecycle
|
||||
033 1
|
||||
isub
|
||||
load_int 500
|
||||
if_icmpge LABEL74
|
||||
jump LABEL76
|
||||
LABEL74:
|
||||
load_int 0
|
||||
return
|
||||
LABEL76:
|
||||
5005
|
||||
load_int 2
|
||||
if_icmpne LABEL80
|
||||
jump LABEL82
|
||||
LABEL80:
|
||||
load_int 1
|
||||
return
|
||||
LABEL82:
|
||||
load_int 0
|
||||
return
|
||||
LABEL84:
|
||||
load_int 0
|
||||
return
|
||||
load_int -1
|
||||
return
|
||||
Reference in New Issue
Block a user