com.yworks.yshrink.model.MethodDescriptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yguard Show documentation
Show all versions of yguard Show documentation
The open-source Java obfuscation tool working with Ant and Gradle by yWorks - the diagramming experts
package com.yworks.yshrink.model;
import com.yworks.yshrink.util.Util;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.AbstractMap;
/**
* @author Michael Schroeder, yWorks GmbH http://www.yworks.com
*/
public class MethodDescriptor extends AbstractDescriptor {
private String name;
private String desc;
private List invocations; // call: [type,methodName,methodDesc]
private List fieldRefs; // fieldRef: [owner,name]
private List> typeInstructions;
private String[] exceptions;
private List localVars;
protected MethodDescriptor( final String name, final int access, final String desc, final String[] exceptions, File sourceJar ) {
super( access, sourceJar );
this.name = name;
this.desc = desc;
invocations = new ArrayList<>();
fieldRefs = new ArrayList<>();
typeInstructions = new ArrayList<>();
localVars = new ArrayList<>();
this.exceptions = exceptions;
}
public String getName() {
return name;
}
public String getDesc() {
return desc;
}
public Type[] getArgumentTypes() {
return Type.getArgumentTypes( desc );
}
public String getArgumentsString() {
StringBuilder buf = new StringBuilder();
Type[] argumentTypes = getArgumentTypes();
for ( Type type : argumentTypes ) {
buf.append( type.getDescriptor() );
}
return buf.toString();
}
public Type getReturnType() {
return Type.getReturnType( desc );
}
public List getInvocations() {
return invocations;
}
public void addInvocation( final int opcode, final String type, final String name, final String desc ) {
invocations.add( InvocationFactory.getInstance().getInvocation( opcode, type, name, desc ) );
//invocations.add( new Invocation( opcode, type, name, desc ) );
}
public List getFieldRefs() {
return fieldRefs;
}
public void addFieldRef( final String type, final String name ) {
fieldRefs.add( new String[]{ type, name } );
}
public void addTypeInstruction( final int opcode, final String desc ) {
typeInstructions.add( new AbstractMap.SimpleEntry