From 76be350b3c54ea88cc1a95b5cf0d1db153f2edb3 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 3 Aug 2014 11:16:33 -0400 Subject: fixed bugs with saving mappings got argument renaming to work --- .../enigma/bytecode/MethodParameterWriter.java | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/cuchaz/enigma/bytecode/MethodParameterWriter.java') diff --git a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java index 1e5d1f0..a8d3983 100644 --- a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java +++ b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java @@ -10,9 +10,15 @@ ******************************************************************************/ package cuchaz.enigma.bytecode; +import java.util.ArrayList; +import java.util.List; + import javassist.CtBehavior; import javassist.CtClass; -import javassist.bytecode.AttributeInfo; +import javassist.bytecode.Descriptor; +import cuchaz.enigma.mapping.ArgumentEntry; +import cuchaz.enigma.mapping.ClassEntry; +import cuchaz.enigma.mapping.MethodEntry; import cuchaz.enigma.mapping.Translator; public class MethodParameterWriter @@ -27,9 +33,25 @@ public class MethodParameterWriter public void writeMethodArguments( CtClass c ) { // Procyon will read method arguments from the "MethodParameters" attribute, so write those + ClassEntry classEntry = new ClassEntry( Descriptor.toJvmName( c.getName() ) ); for( CtBehavior behavior : c.getDeclaredBehaviors() ) { - AttributeInfo attribute = behavior.getMethodInfo().getAttribute( "MethodParameter" ); + int numParams = Descriptor.numOfParameters( behavior.getMethodInfo().getDescriptor() ); + if( numParams <= 0 ) + { + continue; + } + + // get the list of parameter names + MethodEntry methodEntry = new MethodEntry( classEntry, behavior.getMethodInfo().getName(), behavior.getSignature() ); + List names = new ArrayList( numParams ); + for( int i=0; i