diff options
Diffstat (limited to 'src/cuchaz/enigma/bytecode/MethodParameterWriter.java')
| -rw-r--r-- | src/cuchaz/enigma/bytecode/MethodParameterWriter.java | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java index 5a11cd8..5d4ca1a 100644 --- a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java +++ b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java | |||
| @@ -15,14 +15,9 @@ 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; | ||
| 20 | import javassist.bytecode.Descriptor; | ||
| 21 | import cuchaz.enigma.mapping.ArgumentEntry; | 18 | import cuchaz.enigma.mapping.ArgumentEntry; |
| 22 | import cuchaz.enigma.mapping.BehaviorEntry; | 19 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 23 | import cuchaz.enigma.mapping.ClassEntry; | 20 | import cuchaz.enigma.mapping.BehaviorEntryFactory; |
| 24 | import cuchaz.enigma.mapping.ConstructorEntry; | ||
| 25 | import cuchaz.enigma.mapping.MethodEntry; | ||
| 26 | import cuchaz.enigma.mapping.Translator; | 21 | import cuchaz.enigma.mapping.Translator; |
| 27 | 22 | ||
| 28 | public class MethodParameterWriter { | 23 | public class MethodParameterWriter { |
| @@ -36,24 +31,16 @@ public class MethodParameterWriter { | |||
| 36 | public void writeMethodArguments(CtClass c) { | 31 | public void writeMethodArguments(CtClass c) { |
| 37 | 32 | ||
| 38 | // Procyon will read method arguments from the "MethodParameters" attribute, so write those | 33 | // Procyon will read method arguments from the "MethodParameters" attribute, so write those |
| 39 | ClassEntry classEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); | ||
| 40 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { | 34 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { |
| 41 | int numParams = Descriptor.numOfParameters(behavior.getMethodInfo().getDescriptor()); | 35 | BehaviorEntry behaviorEntry = BehaviorEntryFactory.create(behavior); |
| 36 | |||
| 37 | // get the number of arguments | ||
| 38 | int numParams = behaviorEntry.getSignature().getArgumentTypes().size(); | ||
| 42 | if (numParams <= 0) { | 39 | if (numParams <= 0) { |
| 43 | continue; | 40 | continue; |
| 44 | } | 41 | } |
| 45 | 42 | ||
| 46 | // get the behavior entry | 43 | // get the list of argument names |
| 47 | BehaviorEntry behaviorEntry; | ||
| 48 | if (behavior instanceof CtMethod) { | ||
| 49 | behaviorEntry = new MethodEntry(classEntry, behavior.getMethodInfo().getName(), behavior.getSignature()); | ||
| 50 | } else if (behavior instanceof CtConstructor) { | ||
| 51 | behaviorEntry = new ConstructorEntry(classEntry, behavior.getSignature()); | ||
| 52 | } else { | ||
| 53 | throw new Error("Unsupported behavior type: " + behavior.getClass().getName()); | ||
| 54 | } | ||
| 55 | |||
| 56 | // get the list of parameter names | ||
| 57 | List<String> names = new ArrayList<String>(numParams); | 44 | List<String> names = new ArrayList<String>(numParams); |
| 58 | for (int i = 0; i < numParams; i++) { | 45 | for (int i = 0; i < numParams; i++) { |
| 59 | names.add(m_translator.translate(new ArgumentEntry(behaviorEntry, i, ""))); | 46 | names.add(m_translator.translate(new ArgumentEntry(behaviorEntry, i, ""))); |