summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/bytecode/MethodParameterWriter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/bytecode/MethodParameterWriter.java')
-rw-r--r--src/cuchaz/enigma/bytecode/MethodParameterWriter.java26
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 ******************************************************************************/
11package cuchaz.enigma.bytecode; 11package cuchaz.enigma.bytecode;
12 12
13import java.util.ArrayList;
14import java.util.List;
15
13import javassist.CtBehavior; 16import javassist.CtBehavior;
14import javassist.CtClass; 17import javassist.CtClass;
15import javassist.bytecode.AttributeInfo; 18import javassist.bytecode.Descriptor;
19import cuchaz.enigma.mapping.ArgumentEntry;
20import cuchaz.enigma.mapping.ClassEntry;
21import cuchaz.enigma.mapping.MethodEntry;
16import cuchaz.enigma.mapping.Translator; 22import cuchaz.enigma.mapping.Translator;
17 23
18public class MethodParameterWriter 24public 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}