test_class.declarator: logger = LoggerFactory.getLogger(DisassemblerTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(DisassemblerTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.declarator: folder = StoreLocation.getTemporaryFolder()
test_class.modifier: @Rule
  	public
test_class.original_string: @Rule
  	public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
test_class.type: TemporaryFolder
test_class.var_name: folder
test_class.file: cache/src/test/java/net/runelite/cache/script/disassembler/DisassemblerTest.java
test_class.identifier: DisassemblerTest
test_case.body: @Test
  	public void test() throws IOException
  	{
  		File outDir = folder.newFolder();
  		int count = 0;
  
  		try (Store store = new Store(StoreLocation.LOCATION))
  		{
  			store.load();
  
  			Storage storage = store.getStorage();
  			Index index = store.getIndex(IndexType.CLIENTSCRIPT);
  			ScriptLoader loader = new ScriptLoader();
  
  			for (Archive archive : index.getArchives())
  			{
  				byte[] contents = archive.decompress(storage.loadArchive(archive));
  
  				if (contents == null)
  				{
  					continue;
  				}
  
  				ScriptDefinition script = loader.load(archive.getArchiveId(), contents);
  
  				File outFile = new File(outDir, archive.getArchiveId() + ".rs2asm");
  
  				Disassembler disassembler = new Disassembler();
  				String out = disassembler.disassemble(script);
  
  				Files.write(out.getBytes(StandardCharsets.UTF_8), outFile);
  
  				++count;
  			}
  		}
  
  		logger.info("Dumped {} scripts to {}", count, outDir);
  	}
test_case.class_method_signature: DisassemblerTest.test()
test_case.full_signature: @Test public void test()
test_case.identifier: test
test_case.invocations: newFolder load getStorage getIndex getArchives decompress loadArchive load getArchiveId getArchiveId disassemble write getBytes info
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test()
focal_class.declarator: logger = LoggerFactory.getLogger(Disassembler.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(Disassembler.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: ESCAPER = Escapers.builder()
  		.addEscape('"', "\\\"")
  		.addEscape('\\', "\\\\")
  		.build()
focal_class.modifier: private static final
focal_class.original_string: private static final Escaper ESCAPER = Escapers.builder()
  		.addEscape('"', "\\\"")
  		.addEscape('\\', "\\\\")
  		.build();
focal_class.type: Escaper
focal_class.var_name: ESCAPER
focal_class.declarator: instructions = new Instructions()
focal_class.modifier: private final
focal_class.original_string: private final Instructions instructions = new Instructions();
focal_class.type: Instructions
focal_class.var_name: instructions
focal_class.file: cache/src/main/java/net/runelite/cache/script/disassembler/Disassembler.java
focal_class.identifier: Disassembler
focal_class.class_method_signature: Disassembler.Disassembler()
focal_class.full_signature: public  Disassembler()
focal_class.identifier: Disassembler
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  Disassembler()
focal_class.class_method_signature: Disassembler.isJump(int opcode)
focal_class.full_signature: private boolean isJump(int opcode)
focal_class.identifier: isJump
focal_class.modifiers: private
focal_class.parameters: (int opcode)
focal_class.return: boolean
focal_class.signature: boolean isJump(int opcode)
focal_class.class_method_signature: Disassembler.needLabel(ScriptDefinition script)
focal_class.full_signature: private boolean[] needLabel(ScriptDefinition script)
focal_class.identifier: needLabel
focal_class.modifiers: private
focal_class.parameters: (ScriptDefinition script)
focal_class.return: boolean[]
focal_class.signature: boolean[] needLabel(ScriptDefinition script)
focal_class.class_method_signature: Disassembler.disassemble(ScriptDefinition script)
focal_class.full_signature: public String disassemble(ScriptDefinition script)
focal_class.identifier: disassemble
focal_class.modifiers: public
focal_class.parameters: (ScriptDefinition script)
focal_class.return: String
focal_class.signature: String disassemble(ScriptDefinition script)
focal_class.class_method_signature: Disassembler.shouldWriteIntOperand(int opcode, int operand)
focal_class.full_signature: private boolean shouldWriteIntOperand(int opcode, int operand)
focal_class.identifier: shouldWriteIntOperand
focal_class.modifiers: private
focal_class.parameters: (int opcode, int operand)
focal_class.return: boolean
focal_class.signature: boolean shouldWriteIntOperand(int opcode, int operand)
focal_class.class_method_signature: Disassembler.writerHeader(StringBuilder writer, ScriptDefinition script)
focal_class.full_signature: private void writerHeader(StringBuilder writer, ScriptDefinition script)
focal_class.identifier: writerHeader
focal_class.modifiers: private
focal_class.parameters: (StringBuilder writer, ScriptDefinition script)
focal_class.return: void
focal_class.signature: void writerHeader(StringBuilder writer, ScriptDefinition script)
focal_method.body: public String disassemble(ScriptDefinition script) throws IOException
  	{
  		int[] instructions = script.getInstructions();
  		int[] iops = script.getIntOperands();
  		String[] sops = script.getStringOperands();
  		Map<Integer, Integer>[] switches = script.getSwitches();
  
  		assert iops.length == instructions.length;
  		assert sops.length == instructions.length;
  
  		boolean[] jumps = needLabel(script);
  
  		StringBuilder writer = new StringBuilder();
  		writerHeader(writer, script);
  
  		for (int i = 0; i < instructions.length; ++i)
  		{
  			int opcode = instructions[i];
  			int iop = iops[i];
  			String sop = sops[i];
  
  			Instruction ins = this.instructions.find(opcode);
  			if (ins == null)
  			{
  				logger.warn("Unknown instruction {} in script {}", opcode, script.getId());
  			}
  
  			if (jumps[i])
  			{
  				// something jumps here
  				writer.append("LABEL").append(i).append(":\n");
  			}
  
  			String name;
  			if (ins != null && ins.getName() != null)
  			{
  				name = ins.getName();
  			}
  			else
  			{
  				name = String.format("%03d", opcode);
  			}
  
  			writer.append(String.format("   %-22s", name));
  
  			if (shouldWriteIntOperand(opcode, iop))
  			{
  				if (isJump(opcode))
  				{
  					writer.append(" LABEL").append(i + iop + 1);
  				}
  				else
  				{
  					writer.append(" ").append(iop);
  				}
  			}
  
  			if (sop != null)
  			{
  				writer.append(" \"").append(ESCAPER.escape(sop)).append("\"");
  			}
  
  			if (opcode == Opcodes.SWITCH)
  			{
  				Map<Integer, Integer> switchMap = switches[iop];
  
  				for (Entry<Integer, Integer> entry : switchMap.entrySet())
  				{
  					int value = entry.getKey();
  					int jump = entry.getValue();
  
  					writer.append("\n");
  					writer.append("      ").append(value).append(": LABEL").append(i + jump + 1);
  				}
  			}
  
  			writer.append("\n");
  		}
  
  		return writer.toString();
  	}
focal_method.class_method_signature: Disassembler.disassemble(ScriptDefinition script)
focal_method.full_signature: public String disassemble(ScriptDefinition script)
focal_method.identifier: disassemble
focal_method.invocations: getInstructions getIntOperands getStringOperands getSwitches needLabel writerHeader find warn getId append append append getName getName format append format shouldWriteIntOperand isJump append append append append append append append escape entrySet getKey getValue append append append append append append toString
focal_method.modifiers: public
focal_method.parameters: (ScriptDefinition script)
focal_method.return: String
focal_method.signature: String disassemble(ScriptDefinition script)