diff options
Diffstat (limited to 'src/cuchaz/enigma/bytecode/MethodParameterWriter.java')
| -rw-r--r-- | src/cuchaz/enigma/bytecode/MethodParameterWriter.java | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java index adea7ea..5a11cd8 100644 --- a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java +++ b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java | |||
| @@ -25,51 +25,42 @@ import cuchaz.enigma.mapping.ConstructorEntry; | |||
| 25 | import cuchaz.enigma.mapping.MethodEntry; | 25 | import cuchaz.enigma.mapping.MethodEntry; |
| 26 | import cuchaz.enigma.mapping.Translator; | 26 | import cuchaz.enigma.mapping.Translator; |
| 27 | 27 | ||
| 28 | public class MethodParameterWriter | 28 | public class MethodParameterWriter { |
| 29 | { | 29 | |
| 30 | private Translator m_translator; | 30 | private Translator m_translator; |
| 31 | 31 | ||
| 32 | public MethodParameterWriter( Translator translator ) | 32 | public MethodParameterWriter(Translator translator) { |
| 33 | { | ||
| 34 | m_translator = translator; | 33 | m_translator = translator; |
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | public void writeMethodArguments( CtClass c ) | 36 | public void writeMethodArguments(CtClass c) { |
| 38 | { | 37 | |
| 39 | // Procyon will read method arguments from the "MethodParameters" attribute, so write those | 38 | // Procyon will read method arguments from the "MethodParameters" attribute, so write those |
| 40 | ClassEntry classEntry = new ClassEntry( Descriptor.toJvmName( c.getName() ) ); | 39 | ClassEntry classEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); |
| 41 | for( CtBehavior behavior : c.getDeclaredBehaviors() ) | 40 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { |
| 42 | { | 41 | int numParams = Descriptor.numOfParameters(behavior.getMethodInfo().getDescriptor()); |
| 43 | int numParams = Descriptor.numOfParameters( behavior.getMethodInfo().getDescriptor() ); | 42 | if (numParams <= 0) { |
| 44 | if( numParams <= 0 ) | ||
| 45 | { | ||
| 46 | continue; | 43 | continue; |
| 47 | } | 44 | } |
| 48 | 45 | ||
| 49 | // get the behavior entry | 46 | // get the behavior entry |
| 50 | BehaviorEntry behaviorEntry; | 47 | BehaviorEntry behaviorEntry; |
| 51 | if( behavior instanceof CtMethod ) | 48 | if (behavior instanceof CtMethod) { |
| 52 | { | 49 | behaviorEntry = new MethodEntry(classEntry, behavior.getMethodInfo().getName(), behavior.getSignature()); |
| 53 | behaviorEntry = new MethodEntry( classEntry, behavior.getMethodInfo().getName(), behavior.getSignature() ); | 50 | } else if (behavior instanceof CtConstructor) { |
| 54 | } | 51 | behaviorEntry = new ConstructorEntry(classEntry, behavior.getSignature()); |
| 55 | else if( behavior instanceof CtConstructor ) | 52 | } else { |
| 56 | { | 53 | throw new Error("Unsupported behavior type: " + behavior.getClass().getName()); |
| 57 | behaviorEntry = new ConstructorEntry( classEntry, behavior.getSignature() ); | ||
| 58 | } | ||
| 59 | else | ||
| 60 | { | ||
| 61 | throw new Error( "Unsupported behavior type: " + behavior.getClass().getName() ); | ||
| 62 | } | 54 | } |
| 63 | 55 | ||
| 64 | // get the list of parameter names | 56 | // get the list of parameter names |
| 65 | List<String> names = new ArrayList<String>( numParams ); | 57 | List<String> names = new ArrayList<String>(numParams); |
| 66 | for( int i=0; i<numParams; i++ ) | 58 | for (int i = 0; i < numParams; i++) { |
| 67 | { | 59 | names.add(m_translator.translate(new ArgumentEntry(behaviorEntry, i, ""))); |
| 68 | names.add( m_translator.translate( new ArgumentEntry( behaviorEntry, i, "" ) ) ); | ||
| 69 | } | 60 | } |
| 70 | 61 | ||
| 71 | // save the mappings to the class | 62 | // save the mappings to the class |
| 72 | MethodParametersAttribute.updateClass( behavior.getMethodInfo(), names ); | 63 | MethodParametersAttribute.updateClass(behavior.getMethodInfo(), names); |
| 73 | } | 64 | } |
| 74 | } | 65 | } |
| 75 | } | 66 | } |