public class MenuOption extends Search{
public SearchResult run(RSClient data, HashMap<String, ClassGen> classes) {
RSClass nodeClass = data.getProperClass("Node");
for(Entry<String, ClassGen> c : classes.entrySet()){
ClassGen cg = new ClassGen(c.getValue().getJavaClass());
ConstantPoolGen cpg = cg.getConstantPool();
if(c.getValue().getSuperclassName().equals(nodeClass.className) && c.getValue().isFinal()){
for(Method m : c.getValue().getMethods()){
MethodSearcher mS = new MethodSearcher(m, cg, cpg);
if(m.getName().equals("<init>") && mS.getArgCount() == 10 &&
mS.getTypeCount("int") == 5 && mS.getTypeCount("java.lang.String")==2){
MethodGen mg = new MethodGen(m, cg.getClassName(), cpg);
RSClass menu = data.addClass("Menu", c.getValue().getClassName());
int found = 0;
InstructionSearcher iS = new InstructionSearcher(mg.getInstructionList(), cpg);
Instruction i;
FieldInstruction option;
FieldInstruction action;
while(iS.next() != null){
i = iS.current();
if(i instanceof ALOAD){
if(((ALOAD)i).getIndex() == 2){
option = iS.nextFieldInstruction();
menu.addField("Option", option.getFieldName(cpg));
found++;
if(found==2)
return SearchResult.Success;
}
if(((ALOAD)i).getIndex() == 1){
option = iS.nextFieldInstruction();
menu.addField("Action", option.getFieldName(cpg));
found++;
if(found==2)
return SearchResult.Success;
}
}