2013-03-08 00:25:48 +00:00
|
|
|
/*
|
|
|
|
* Forge Mod Loader
|
|
|
|
* Copyright (c) 2012-2013 cpw.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the GNU Lesser Public License v2.1
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
2013-11-10 16:49:06 +00:00
|
|
|
*
|
2013-03-08 00:25:48 +00:00
|
|
|
* Contributors:
|
|
|
|
* cpw - implementation
|
|
|
|
*/
|
|
|
|
|
2014-09-23 05:01:24 +00:00
|
|
|
package net.minecraftforge.fml.common.asm.transformers.deobf;
|
2013-01-27 22:09:00 +00:00
|
|
|
|
|
|
|
import org.objectweb.asm.ClassVisitor;
|
2014-06-24 19:37:39 +00:00
|
|
|
import org.objectweb.asm.MethodVisitor;
|
|
|
|
import org.objectweb.asm.Opcodes;
|
|
|
|
import org.objectweb.asm.commons.Remapper;
|
2013-01-27 22:09:00 +00:00
|
|
|
import org.objectweb.asm.commons.RemappingClassAdapter;
|
2014-06-24 19:37:39 +00:00
|
|
|
import org.objectweb.asm.commons.RemappingMethodAdapter;
|
2013-01-27 22:09:00 +00:00
|
|
|
|
|
|
|
public class FMLRemappingAdapter extends RemappingClassAdapter {
|
|
|
|
public FMLRemappingAdapter(ClassVisitor cv)
|
|
|
|
{
|
|
|
|
super(cv, FMLDeobfuscatingRemapper.INSTANCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
|
|
|
|
{
|
2013-01-28 03:42:36 +00:00
|
|
|
if (interfaces == null)
|
|
|
|
{
|
|
|
|
interfaces = new String[0];
|
|
|
|
}
|
|
|
|
FMLDeobfuscatingRemapper.INSTANCE.mergeSuperMaps(name, superName, interfaces);
|
2013-01-27 22:09:00 +00:00
|
|
|
super.visit(version, access, name, signature, superName, interfaces);
|
|
|
|
}
|
2014-06-24 19:37:39 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected MethodVisitor createRemappingMethodAdapter(int access, String newDesc, MethodVisitor mv)
|
|
|
|
{
|
|
|
|
return new StaticFixingMethodVisitor(access, newDesc, mv, remapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static class StaticFixingMethodVisitor extends RemappingMethodAdapter
|
|
|
|
{
|
|
|
|
|
|
|
|
public StaticFixingMethodVisitor(int access, String desc, MethodVisitor mv, Remapper remapper)
|
|
|
|
{
|
|
|
|
super(access, desc, mv, remapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void visitFieldInsn(int opcode, String originalType, String originalName, String desc)
|
|
|
|
{
|
|
|
|
// This method solves the problem of a static field reference changing type. In all probability it is a
|
|
|
|
// compatible change, however we need to fix up the desc to point at the new type
|
|
|
|
String type = remapper.mapType(originalType);
|
|
|
|
String fieldName = remapper.mapFieldName(originalType, originalName, desc);
|
|
|
|
String newDesc = remapper.mapDesc(desc);
|
|
|
|
if (opcode == Opcodes.GETSTATIC && type.startsWith("net/minecraft/") && newDesc.startsWith("Lnet/minecraft/"))
|
|
|
|
{
|
|
|
|
String replDesc = FMLDeobfuscatingRemapper.INSTANCE.getStaticFieldType(originalType, originalName, type, fieldName);
|
|
|
|
if (replDesc != null)
|
|
|
|
{
|
|
|
|
newDesc = remapper.mapDesc(replDesc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// super.super
|
|
|
|
if (mv != null) {
|
|
|
|
mv.visitFieldInsn(opcode, type, fieldName, newDesc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-27 22:09:00 +00:00
|
|
|
}
|