diff options
Diffstat (limited to 'src/cuchaz/enigma/bytecode/MethodParameterWriter.java')
| -rw-r--r-- | src/cuchaz/enigma/bytecode/MethodParameterWriter.java | 26 |
1 files changed, 24 insertions, 2 deletions
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 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.bytecode; | 11 | package cuchaz.enigma.bytecode; |
| 12 | 12 | ||
| 13 | import java.util.ArrayList; | ||
| 14 | import java.util.List; | ||
| 15 | |||
| 13 | import javassist.CtBehavior; | 16 | import javassist.CtBehavior; |
| 14 | import javassist.CtClass; | 17 | import javassist.CtClass; |
| 15 | import javassist.bytecode.AttributeInfo; | 18 | import javassist.bytecode.Descriptor; |
| 19 | import cuchaz.enigma.mapping.ArgumentEntry; | ||
| 20 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 21 | import cuchaz.enigma.mapping.MethodEntry; | ||
| 16 | import cuchaz.enigma.mapping.Translator; | 22 | import cuchaz.enigma.mapping.Translator; |
| 17 | 23 | ||
| 18 | public class MethodParameterWriter | 24 | public class MethodParameterWriter |
| @@ -27,9 +33,25 @@ public class MethodParameterWriter | |||
| 27 | public void writeMethodArguments( CtClass c ) | 33 | public void writeMethodArguments( CtClass c ) |
| 28 | { | 34 | { |
| 29 | // Procyon will read method arguments from the "MethodParameters" attribute, so write those | 35 | // Procyon will read method arguments from the "MethodParameters" attribute, so write those |
| 36 | ClassEntry classEntry = new ClassEntry( Descriptor.toJvmName( c.getName() ) ); | ||
| 30 | for( CtBehavior behavior : c.getDeclaredBehaviors() ) | 37 | for( CtBehavior behavior : c.getDeclaredBehaviors() ) |
| 31 | { | 38 | { |
| 32 | AttributeInfo attribute = behavior.getMethodInfo().getAttribute( "MethodParameter" ); | 39 | int numParams = Descriptor.numOfParameters( behavior.getMethodInfo().getDescriptor() ); |
| 40 | if( numParams <= 0 ) | ||
| 41 | { | ||
| 42 | continue; | ||
| 43 | } | ||
| 44 | |||
| 45 | // get the list of parameter names | ||
| 46 | MethodEntry methodEntry = new MethodEntry( classEntry, behavior.getMethodInfo().getName(), behavior.getSignature() ); | ||
| 47 | List<String> names = new ArrayList<String>( numParams ); | ||
| 48 | for( int i=0; i<numParams; i++ ) | ||
| 49 | { | ||
| 50 | names.add( m_translator.translate( new ArgumentEntry( methodEntry, i, "" ) ) ); | ||
| 51 | } | ||
| 52 | |||
| 53 | // save the mappings to the class | ||
| 54 | MethodParametersAttribute.updateClass( behavior.getMethodInfo(), names ); | ||
| 33 | } | 55 | } |
| 34 | } | 56 | } |
| 35 | } | 57 | } |