summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/bytecode/BytecodeTools.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/bytecode/BytecodeTools.java')
-rw-r--r--src/cuchaz/enigma/bytecode/BytecodeTools.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/bytecode/BytecodeTools.java b/src/cuchaz/enigma/bytecode/BytecodeTools.java
index 664350e..0de9bd6 100644
--- a/src/cuchaz/enigma/bytecode/BytecodeTools.java
+++ b/src/cuchaz/enigma/bytecode/BytecodeTools.java
@@ -15,6 +15,7 @@ import java.io.ByteArrayOutputStream;
15import java.io.DataInputStream; 15import java.io.DataInputStream;
16import java.io.DataOutputStream; 16import java.io.DataOutputStream;
17import java.io.IOException; 17import java.io.IOException;
18import java.util.List;
18import java.util.Map; 19import java.util.Map;
19import java.util.Set; 20import java.util.Set;
20 21
@@ -25,6 +26,7 @@ import javassist.bytecode.CodeAttribute;
25import javassist.bytecode.ConstPool; 26import javassist.bytecode.ConstPool;
26import javassist.bytecode.ExceptionTable; 27import javassist.bytecode.ExceptionTable;
27 28
29import com.beust.jcommander.internal.Lists;
28import com.google.common.collect.Maps; 30import com.google.common.collect.Maps;
29import com.google.common.collect.Sets; 31import com.google.common.collect.Sets;
30 32
@@ -266,4 +268,59 @@ public class BytecodeTools
266 ); 268 );
267 } 269 }
268 } 270 }
271
272 public static List<String> getParameterTypes( String signature )
273 {
274 List<String> types = Lists.newArrayList();
275 for( int i=0; i<signature.length(); )
276 {
277 char c = signature.charAt( i );
278
279 // handle parens
280 if( c == '(' )
281 {
282 i++;
283 c = signature.charAt( i );
284 }
285 if( c == ')' )
286 {
287 break;
288 }
289
290 // find a type
291 String type = null;
292
293 int arrayDim = 0;
294 while( c == '[' )
295 {
296 // advance to array type
297 arrayDim++;
298 i++;
299 c = signature.charAt( i );
300 }
301
302 if( c == 'L' )
303 {
304 // read class type
305 int pos = signature.indexOf( ';', i + 1 );
306 String className = signature.substring( i + 1, pos );
307 type = "L" + className + ";";
308 i = pos + 1;
309 }
310 else
311 {
312 // read primitive type
313 type = signature.substring( i, i + 1 );
314 i++;
315 }
316
317 // was it an array?
318 while( arrayDim-- > 0 )
319 {
320 type = "[" + type;
321 }
322 types.add( type );
323 }
324 return types;
325 }
269} 326}