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 static AbstractInsnNode nextReal(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() == -1);
while ((insn = insn.getNext()) != null && insn.getOpcode() == -1) {
/* empty */
}
return 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;
}
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;
}
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;
}

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

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

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

@ -105,7 +105,7 @@ public final class CounterTransformer extends Transformer {
var putstatic = (FieldInsnNode) match.get(3);
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);
}
});

Loading…
Cancel
Save