diff options
| author | 2015-02-08 21:29:25 -0500 | |
|---|---|---|
| committer | 2015-02-08 21:29:25 -0500 | |
| commit | ed9b5cdfc648e86fd463bfa8d86b94c41671e14c (patch) | |
| tree | 2619bbc7e04dfa3b82f8dfd3b1d31f529766cd4b /src/cuchaz/enigma/bytecode/MethodParameterWriter.java | |
| download | enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.tar.gz enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.tar.xz enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.zip | |
switch all classes to new signature/type system
Diffstat (limited to '')
| -rw-r--r-- | src/cuchaz/enigma/bytecode/MethodParameterWriter.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/bytecode/MethodParameterWriter.java b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java new file mode 100644 index 0000000..5d4ca1a --- /dev/null +++ b/src/cuchaz/enigma/bytecode/MethodParameterWriter.java | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.bytecode; | ||
| 12 | |||
| 13 | import java.util.ArrayList; | ||
| 14 | import java.util.List; | ||
| 15 | |||
| 16 | import javassist.CtBehavior; | ||
| 17 | import javassist.CtClass; | ||
| 18 | import cuchaz.enigma.mapping.ArgumentEntry; | ||
| 19 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 20 | import cuchaz.enigma.mapping.BehaviorEntryFactory; | ||
| 21 | import cuchaz.enigma.mapping.Translator; | ||
| 22 | |||
| 23 | public class MethodParameterWriter { | ||
| 24 | |||
| 25 | private Translator m_translator; | ||
| 26 | |||
| 27 | public MethodParameterWriter(Translator translator) { | ||
| 28 | m_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 | BehaviorEntry behaviorEntry = BehaviorEntryFactory.create(behavior); | ||
| 36 | |||
| 37 | // get the number of arguments | ||
| 38 | int numParams = behaviorEntry.getSignature().getArgumentTypes().size(); | ||
| 39 | if (numParams <= 0) { | ||
| 40 | continue; | ||
| 41 | } | ||
| 42 | |||
| 43 | // get the list of argument names | ||
| 44 | List<String> names = new ArrayList<String>(numParams); | ||
| 45 | for (int i = 0; i < numParams; i++) { | ||
| 46 | names.add(m_translator.translate(new ArgumentEntry(behaviorEntry, i, ""))); | ||
| 47 | } | ||
| 48 | |||
| 49 | // save the mappings to the class | ||
| 50 | MethodParametersAttribute.updateClass(behavior.getMethodInfo(), names); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||