I'm using the ASM library and trying to figure out how it gets its numbering and how to determine whether or not the last parameter is used..
What I did so far was:
Collection<ClassNode> classes = readJar("...");
for (ClassNode c : classes) {
for (MethodNode m : c) {
Type[] types = Type.getArgumentTypes(m.desc);
if (types.length > 0) {
for (int i = 0; i < method.instructions.size(); ++i) {
if (method.instructions.get(i) instanceof VarInsnNode) {
VarInsnNode v = ((VarInsnNode) method.instructions.get(i));
if (v.var == types.length) { //last parameter is used..
System.out.println(v.var);
}
}
}
}
}
}
However, some methods the parameters are named as follows:
static int j(int var0, int var1) {
return var1 < 0 ? something() : somethingElse();
}
and some are:
void bk(bg var1, int var2, int var3) {
this.r = var1;
this.s = var2;
this.t = var3;
}
What I want to know, is why some of them start with 0 and some start with 1. I know this because I decompiled the jar file using fernflower. This makes my function fail. My function works for function "bk" but fails for function "j" because "j" parameters start at 0.
This means that for some functions, the last parameter is equivalent to types.length - 1 and some are types.length.
Is there anyway I can figure out number of the last parameter (VarInsnNode)?