summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java')
-rw-r--r--src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java b/src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java
deleted file mode 100644
index d63572e..0000000
--- a/src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java
+++ /dev/null
@@ -1,67 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 * <p>
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.bytecode;
13
14import cuchaz.enigma.mapping.*;
15import javassist.CtBehavior;
16import javassist.CtClass;
17import javassist.bytecode.CodeAttribute;
18import javassist.bytecode.LocalVariableAttribute;
19
20import java.util.ArrayList;
21import java.util.List;
22
23public class MethodParameterWriter {
24
25 private Translator translator;
26
27 public MethodParameterWriter(Translator translator) {
28 this.translator = translator;
29 }
30
31 public void writeMethodArguments(CtClass c) {
32
33 // Procyon will read method arguments from the "MethodParameters" attribute, so write those
34 for (CtBehavior behavior : c.getDeclaredBehaviors()) {
35
36 // if there's a local variable table here, don't write a MethodParameters attribute
37 // let the local variable writer deal with it instead
38 // procyon starts doing really weird things if we give it both attributes
39 CodeAttribute codeAttribute = behavior.getMethodInfo().getCodeAttribute();
40 if (codeAttribute != null && codeAttribute.getAttribute(LocalVariableAttribute.tag) != null) {
41 continue;
42 }
43
44 BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(behavior);
45
46 // get the number of arguments
47 Signature signature = behaviorEntry.getSignature();
48 if (signature == null) {
49 // static initializers have no signatures, or arguments
50 continue;
51 }
52 int numParams = signature.getArgumentTypes().size();
53 if (numParams <= 0) {
54 continue;
55 }
56
57 // get the list of argument names
58 List<String> names = new ArrayList<>(numParams);
59 for (int i = 0; i < numParams; i++) {
60 names.add(this.translator.translate(new ArgumentEntry(behaviorEntry, i, "")));
61 }
62
63 // save the mappings to the class
64 MethodParametersAttribute.updateClass(behavior.getMethodInfo(), names);
65 }
66 }
67}