if (s.getValue().getName().equalsIgnoreCase("client")) {
System.out.println("found the client");
BCMethod js5caller = null;
int index = 0;
// these are reserved for when we find it
for (BCMethod m : s.getValue().getDeclaredMethods()) {
Code theCode = m.getCode(false); // get the code
for (int j = 0; j < theCode.getInstructions().length; j++) {
Instruction i = theCode.getInstructions()[j];
if (i instanceof ConstantInstruction) { // search
// through the
// instructions
// for a contant
// pool caller
ConstantInstruction ldc = (ConstantInstruction) i;
if (ldc.getType().equals(String.class)) // if its
// for a
// string...
if (ldc.getStringValue().equals("js5connect")) { // if
// the
// value
// of
// the
// string
// its
// calling
// is
// "js5connect"
System.out.println("found it in method "
+ m.getName());
js5caller = m;
index = j;
}
}
}
}
Instruction[] instructions = js5caller.getCode(false)
.getInstructions();
for (int i = index; i < instructions.length; i++) { //go foreward to the next method call
if (instructions[i] instanceof MethodInstruction) {
index = i;
break;
}
}
for (int i = index; i < instructions.length; i++) { //get the next putfield
if (instructions[i] instanceof PutFieldInstruction) {
index = i;
break;
}
}
PutFieldInstruction loginIndexCaller = (PutFieldInstruction) instructions[index]; //extract the name from it.
System.out.println("the login index is "
+ loginIndexCaller.getFieldDeclarerName() + "."
+ loginIndexCaller.getFieldName());
}