Format code

master
Graham 5 years ago
parent 36995c46ef
commit 48f8c68500
  1. 16
      asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.java
  2. 16
      asm/src/main/java/dev/openrs2/asm/Library.java
  3. 40
      decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.java
  4. 34
      deob/src/main/java/dev/openrs2/deob/classpath/TypedRemapper.java
  5. 2
      deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java

@ -4,22 +4,30 @@ import org.objectweb.asm.tree.AbstractInsnNode;
public final class InsnNodeUtils { public final class InsnNodeUtils {
public static AbstractInsnNode nextReal(AbstractInsnNode insn) { public static AbstractInsnNode nextReal(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() == -1); while ((insn = insn.getNext()) != null && insn.getOpcode() == -1) {
/* empty */
}
return insn; return insn;
} }
public static AbstractInsnNode previousReal(AbstractInsnNode insn) { public static AbstractInsnNode previousReal(AbstractInsnNode insn) {
while ((insn = insn.getPrevious()) != null && insn.getOpcode() == -1); while ((insn = insn.getPrevious()) != null && insn.getOpcode() == -1) {
/* empty */
}
return insn; return insn;
} }
public static AbstractInsnNode nextVirtual(AbstractInsnNode insn) { public static AbstractInsnNode nextVirtual(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() != -1); while ((insn = insn.getNext()) != null && insn.getOpcode() != -1) {
/* empty */
}
return insn; return insn;
} }
public static AbstractInsnNode previousVirtual(AbstractInsnNode insn) { public static AbstractInsnNode previousVirtual(AbstractInsnNode insn) {
while ((insn = insn.getPrevious()) != null && insn.getOpcode() != -1); while ((insn = insn.getPrevious()) != null && insn.getOpcode() != -1) {
/* empty */
}
return insn; return insn;
} }

@ -63,10 +63,12 @@ public final class Library implements Iterable<ClassNode> {
var temp = Files.createTempFile(TEMP_PREFIX, JAR_SUFFIX); var temp = Files.createTempFile(TEMP_PREFIX, JAR_SUFFIX);
try { try {
try (var header = new ByteArrayInputStream(GZIP_HEADER); try (
var data = Files.newInputStream(path); var header = new ByteArrayInputStream(GZIP_HEADER);
var in = new GZIPInputStream(new SequenceInputStream(header, data)); var data = Files.newInputStream(path);
var out = new JarOutputStream(Files.newOutputStream(temp))) { var in = new GZIPInputStream(new SequenceInputStream(header, data));
var out = new JarOutputStream(Files.newOutputStream(temp))
) {
Pack200.newUnpacker().unpack(in, out); Pack200.newUnpacker().unpack(in, out);
return readJar(temp); return readJar(temp);
} }
@ -138,8 +140,10 @@ public final class Library implements Iterable<ClassNode> {
try { try {
writeJar(temp, remapper); writeJar(temp, remapper);
try (var in = new JarInputStream(Files.newInputStream(temp)); try (
var out = new GZIPOutputStream(new SkipOutputStream(Files.newOutputStream(path), 2))) { var in = new JarInputStream(Files.newInputStream(temp));
var out = new GZIPOutputStream(new SkipOutputStream(Files.newOutputStream(path), 2))
) {
Pack200.newPacker().pack(in, out); Pack200.newPacker().pack(in, out);
} }
} finally { } finally {

@ -21,32 +21,32 @@ public final class Slf4jFernflowerLogger extends IFernflowerLogger {
@Override @Override
public void writeMessage(String message, Severity severity) { public void writeMessage(String message, Severity severity) {
switch (severity) { switch (severity) {
case TRACE: case TRACE:
logger.trace(message); logger.trace(message);
case INFO: case INFO:
logger.info(message); logger.info(message);
case WARN: case WARN:
logger.warn(message); logger.warn(message);
case ERROR: case ERROR:
logger.error(message); logger.error(message);
default: default:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }
@Override @Override
public void writeMessage(String message, Severity severity, Throwable t) { public void writeMessage(String message, Severity severity, Throwable t) {
switch (severity) { switch (severity) {
case TRACE: case TRACE:
logger.trace(message, t); logger.trace(message, t);
case INFO: case INFO:
logger.info(message, t); logger.info(message, t);
case WARN: case WARN:
logger.warn(message, t); logger.warn(message, t);
case ERROR: case ERROR:
logger.error(message, t); logger.error(message, t);
default: default:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }
} }

@ -258,23 +258,23 @@ public final class TypedRemapper extends Remapper {
} }
switch (type.getSort()) { switch (type.getSort()) {
case Type.BOOLEAN: case Type.BOOLEAN:
case Type.BYTE: case Type.BYTE:
case Type.CHAR: case Type.CHAR:
case Type.SHORT: case Type.SHORT:
case Type.INT: case Type.INT:
case Type.LONG: case Type.LONG:
case Type.FLOAT: case Type.FLOAT:
case Type.DOUBLE: case Type.DOUBLE:
prefix = type.getClassName() + prefix; prefix = type.getClassName() + prefix;
break; break;
case Type.OBJECT: case Type.OBJECT:
var className = classMapping.getOrDefault(type.getInternalName(), type.getInternalName()); var className = classMapping.getOrDefault(type.getInternalName(), type.getInternalName());
className = className.substring(className.lastIndexOf('/') + 1); className = className.substring(className.lastIndexOf('/') + 1);
prefix = className + prefix; prefix = className + prefix;
break; break;
default: default:
throw new IllegalArgumentException("Unknown field type " + type); throw new IllegalArgumentException("Unknown field type " + type);
} }
prefix = StringUtils.indefiniteArticle(prefix) + StringUtils.capitalize(prefix); prefix = StringUtils.indefiniteArticle(prefix) + StringUtils.capitalize(prefix);

@ -105,7 +105,7 @@ public final class CounterTransformer extends Transformer {
var putstatic = (FieldInsnNode) match.get(3); var putstatic = (FieldInsnNode) match.get(3);
if (getstatic.owner.equals(putstatic.owner) && getstatic.name.equals(putstatic.name) && getstatic.desc.equals(putstatic.desc) && if (getstatic.owner.equals(putstatic.owner) && getstatic.name.equals(putstatic.name) && getstatic.desc.equals(putstatic.desc) &&
counters.contains(new MemberRef(putstatic.owner, putstatic.name, putstatic.desc))) { counters.contains(new MemberRef(putstatic.owner, putstatic.name, putstatic.desc))) {
match.forEach(method.instructions::remove); match.forEach(method.instructions::remove);
} }
}); });

Loading…
Cancel
Save