/*
* Internal methods
*/
private Object generateCmdFromRules(ArrayList<Rule> rules) {
Instruction command = null;
boolean cmdDetermined = false;
for(Rule innerRule : rules) {
if(innerRule instanceof Rule_padding ||
innerRule instanceof Rule_optPadding ||
innerRule instanceof Rule_listSeparator)
continue;
if(innerRule instanceof Rule_codeLabel) {
Label innerLabel = EntityFactory.createLabel(innerRule.rules.get(1).spelling);
command.addArgument(innerLabel);
} else if(innerRule instanceof Terminal_StringValue) {
if(!cmdDetermined) {
cmdDetermined = true;
command = EntityFactory.createInstruction(innerRule.spelling, null);
}
} else if(innerRule instanceof Rule_codeRegisterV ||
innerRule instanceof Rule_codeRegisterVDst ||
innerRule instanceof Rule_codeRegisterP ||
innerRule instanceof Rule_codeRegister ||
innerRule instanceof Rule_codeRegisterV64 ||
innerRule instanceof Rule_codeRegisterV64Dst ||
innerRule instanceof Rule_codeRegisterP64 ||
innerRule instanceof Rule_codeRegister64 ||
innerRule instanceof Rule_codeRegisterRet ||
innerRule instanceof Rule_codeRegisterRet64 ||
innerRule instanceof Rule_codeRegisterGroup ||
innerRule instanceof Rule_smaliClassRef ||
innerRule instanceof Rule_smaliFieldRef ||
innerRule instanceof Rule_smaliMethodRef) {
command.getArguments().add((SmaliCodeEntity)innerRule.accept(this));
} else if(innerRule instanceof Rule_intValue ||
innerRule instanceof Rule_strValue) {
Value innerValue = new Value();
innerValue.setName(innerRule.spelling);
command.getArguments().add(innerValue);
} else if(innerRule instanceof Rule_todoStubLine) {
System.err.println("Warning: " + command.getName() + " is not fully supported");
}
}
return command;
}