update tiny-remapper

dev/0.11
Adrian Siekierka 2019-04-13 12:17:43 +02:00
parent 60ec4c1fdb
commit d779225508
3 changed files with 44 additions and 32 deletions

View File

@ -37,12 +37,13 @@ dependencies {
implementation ('net.fabricmc:stitch:0.1.2.47') {
exclude module: 'enigma'
}
implementation ('net.fabricmc:tiny-remapper:0.1.0.29') {
implementation ('net.fabricmc:tiny-remapper:0.1.0.32') {
transitive = false
}
implementation ('org.jetbrains:intellij-fernflower:1.0.0.7')
implementation ('net.fabricmc:tiny-mappings-parser:0.1.1.8')
implementation ('org.jetbrains:intellij-fernflower:1.0.0.8')
implementation ('net.fabricmc:sponge-mixin:0.7.11.17') {
implementation ('net.fabricmc:sponge-mixin:0.7.11.19') {
exclude module: 'launchwrapper'
exclude module: 'guava'
}

View File

@ -24,7 +24,7 @@
package net.fabricmc.loom.mixin;
import net.fabricmc.tinyremapper.TinyUtils;
import net.fabricmc.mappings.*;
import org.spongepowered.asm.obfuscation.mapping.common.MappingField;
import org.spongepowered.asm.obfuscation.mapping.common.MappingMethod;
import org.spongepowered.tools.obfuscation.mapping.common.MappingProvider;
@ -33,6 +33,7 @@ import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
@ -45,16 +46,6 @@ public class MixinMappingProviderTiny extends MappingProvider {
this.to = to;
}
private static String[] removeFirst(String[] src, int count) {
if (count >= src.length) {
return new String[0];
} else {
String[] out = new String[src.length - count];
System.arraycopy(src, count, out, 0, out.length);
return out;
}
}
@Override
public MappingMethod getMethodMapping(MappingMethod method) {
MappingMethod mapped = this.methodMap.get(method);
@ -119,22 +110,34 @@ public class MixinMappingProviderTiny extends MappingProvider {
} */
}
// TODO: Unify with tiny-remapper
@Override
public void read(File input) throws IOException {
BufferedReader reader = Files.newBufferedReader(input.toPath());
try (FileInputStream inputStream = new FileInputStream(input)) {
Mappings mappings = MappingsProvider.readTinyMappings(inputStream, false);
for (ClassEntry entry : mappings.getClassEntries()) {
classMap.put(entry.get(from), entry.get(to));
}
for (FieldEntry entry : mappings.getFieldEntries()) {
EntryTriple fromTriple = entry.get(from);
EntryTriple toTriple = entry.get(to);
TinyUtils.read(reader, from, to, classMap::put, (fieldFrom, fieldTo) -> {
fieldMap.put(
new MappingField(fieldFrom.owner, fieldFrom.name, fieldFrom.desc),
new MappingField(fieldTo.owner, fieldTo.name, fieldTo.desc)
new MappingField(fromTriple.getOwner(), fromTriple.getName(), fromTriple.getDesc()),
new MappingField(toTriple.getOwner(), toTriple.getName(), toTriple.getDesc())
);
}, (methodFrom, methodTo) -> {
}
for (MethodEntry entry : mappings.getMethodEntries()) {
EntryTriple fromTriple = entry.get(from);
EntryTriple toTriple = entry.get(to);
methodMap.put(
new MappingMethod(methodFrom.owner, methodFrom.name, methodFrom.desc),
new MappingMethod(methodTo.owner, methodTo.name, methodTo.desc)
new MappingMethod(fromTriple.getOwner(), fromTriple.getName(), fromTriple.getDesc()),
new MappingMethod(toTriple.getOwner(), toTriple.getName(), toTriple.getDesc())
);
});
}
}
}
}

View File

@ -24,6 +24,7 @@
package net.fabricmc.loom.task;
import net.fabricmc.fernflower.api.IFabricResultSaver;
import org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler;
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider;
@ -37,7 +38,7 @@ import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
public class LoomFernflowerDecompiler extends ConsoleDecompiler {
public class LoomFernflowerDecompiler extends ConsoleDecompiler implements IFabricResultSaver {
private final Map<String, int[]> differingMappings = new HashMap<>();
private final String jarName;
@ -83,12 +84,19 @@ public class LoomFernflowerDecompiler extends ConsoleDecompiler {
}
@Override
public void saveClassEntry(String s, String s1, String s2, String s3, String s4, int[] mapping) {
public void saveClassEntry(String path, String archiveName, String qualifiedName, String entryName, String content, int[] mapping) {
if (mapping != null) {
differingMappings.put(s2, mapping);
differingMappings.put(qualifiedName, mapping);
}
super.saveClassEntry(s, jarName, s2, s3, s4, mapping);
super.saveClassEntry(path, jarName, qualifiedName, entryName, content);
}
@Override
public void saveClassEntry(String path, String archiveName, String qualifiedName, String entryName, String content) {
System.err.println("WARNING: Called saveClassEntry without mapping! " + qualifiedName);
super.saveClassEntry(path, jarName, qualifiedName, entryName, content);
}
@Override