39 lines
1.0 KiB
Java
39 lines
1.0 KiB
Java
package ex11;
|
|
|
|
import ch.usi.dag.disl.staticcontext.InvocationStaticContext;
|
|
import org.objectweb.asm.signature.SignatureReader;
|
|
import org.objectweb.asm.signature.SignatureVisitor;
|
|
|
|
public class ArgumentLengthStaticContext extends InvocationStaticContext {
|
|
|
|
public String getInternalNameWithDescriptor() {
|
|
return getInternalName() + getDescriptor();
|
|
}
|
|
|
|
public int getArgumentLength() {
|
|
final String descriptor = getDescriptor();
|
|
final ArgumentLengthVisitor av = new ArgumentLengthVisitor();
|
|
final SignatureReader sv = new SignatureReader(descriptor);
|
|
sv.accept(av);
|
|
return av.getLength();
|
|
}
|
|
|
|
private static class ArgumentLengthVisitor extends SignatureVisitor {
|
|
private int length = 0;
|
|
|
|
public ArgumentLengthVisitor() {
|
|
super(589824);
|
|
}
|
|
|
|
@Override
|
|
public SignatureVisitor visitParameterType() {
|
|
length++;
|
|
return this;
|
|
}
|
|
|
|
public int getLength() {
|
|
return length;
|
|
}
|
|
}
|
|
}
|