diff options
Diffstat (limited to 'src/cuchaz/enigma/bytecode/MethodParameterWriter.java')
| -rw-r--r-- | src/cuchaz/enigma/bytecode/MethodParameterWriter.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java index a8d3983..adea7ea 100644 --- a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java +++ b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java | |||
| @@ -15,9 +15,13 @@ import java.util.List; | |||
| 15 | 15 | ||
| 16 | import javassist.CtBehavior; | 16 | import javassist.CtBehavior; |
| 17 | import javassist.CtClass; | 17 | import javassist.CtClass; |
| 18 | import javassist.CtConstructor; | ||
| 19 | import javassist.CtMethod; | ||
| 18 | import javassist.bytecode.Descriptor; | 20 | import javassist.bytecode.Descriptor; |
| 19 | import cuchaz.enigma.mapping.ArgumentEntry; | 21 | import cuchaz.enigma.mapping.ArgumentEntry; |
| 22 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 20 | import cuchaz.enigma.mapping.ClassEntry; | 23 | import cuchaz.enigma.mapping.ClassEntry; |
| 24 | import cuchaz.enigma.mapping.ConstructorEntry; | ||
| 21 | import cuchaz.enigma.mapping.MethodEntry; | 25 | import cuchaz.enigma.mapping.MethodEntry; |
| 22 | import cuchaz.enigma.mapping.Translator; | 26 | import cuchaz.enigma.mapping.Translator; |
| 23 | 27 | ||
| @@ -42,12 +46,26 @@ public class MethodParameterWriter | |||
| 42 | continue; | 46 | continue; |
| 43 | } | 47 | } |
| 44 | 48 | ||
| 49 | // get the behavior entry | ||
| 50 | BehaviorEntry behaviorEntry; | ||
| 51 | if( behavior instanceof CtMethod ) | ||
| 52 | { | ||
| 53 | behaviorEntry = new MethodEntry( classEntry, behavior.getMethodInfo().getName(), behavior.getSignature() ); | ||
| 54 | } | ||
| 55 | else if( behavior instanceof CtConstructor ) | ||
| 56 | { | ||
| 57 | behaviorEntry = new ConstructorEntry( classEntry, behavior.getSignature() ); | ||
| 58 | } | ||
| 59 | else | ||
| 60 | { | ||
| 61 | throw new Error( "Unsupported behavior type: " + behavior.getClass().getName() ); | ||
| 62 | } | ||
| 63 | |||
| 45 | // get the list of parameter names | 64 | // 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 ); | 65 | List<String> names = new ArrayList<String>( numParams ); |
| 48 | for( int i=0; i<numParams; i++ ) | 66 | for( int i=0; i<numParams; i++ ) |
| 49 | { | 67 | { |
| 50 | names.add( m_translator.translate( new ArgumentEntry( methodEntry, i, "" ) ) ); | 68 | names.add( m_translator.translate( new ArgumentEntry( behaviorEntry, i, "" ) ) ); |
| 51 | } | 69 | } |
| 52 | 70 | ||
| 53 | // save the mappings to the class | 71 | // save the mappings to the class |