diff options
| author | 2017-05-16 00:24:29 +0200 | |
|---|---|---|
| committer | 2017-05-16 00:24:29 +0200 | |
| commit | b280104d2f926ab74772cef2bf1602663cefa312 (patch) | |
| tree | d130c86a30ec5df37b3a9c4bab576e971ae2e664 /src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java | |
| parent | Add offset for Enum constructor arguments (Fix #58) (diff) | |
| download | enigma-fork-b280104d2f926ab74772cef2bf1602663cefa312.tar.gz enigma-fork-b280104d2f926ab74772cef2bf1602663cefa312.tar.xz enigma-fork-b280104d2f926ab74772cef2bf1602663cefa312.zip | |
Remove the converter + some reorganization
Diffstat (limited to 'src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/bytecode/MethodParameterWriter.java | 67 |
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 | |||
| 12 | package cuchaz.enigma.bytecode; | ||
| 13 | |||
| 14 | import cuchaz.enigma.mapping.*; | ||
| 15 | import javassist.CtBehavior; | ||
| 16 | import javassist.CtClass; | ||
| 17 | import javassist.bytecode.CodeAttribute; | ||
| 18 | import javassist.bytecode.LocalVariableAttribute; | ||
| 19 | |||
| 20 | import java.util.ArrayList; | ||
| 21 | import java.util.List; | ||
| 22 | |||
| 23 | public 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 | } | ||