private static Collection<Renderable> generateConstructor(
SmaliMethod smaliMethod, SmaliBlock rootBlock) {
List<Renderable> entities = new ArrayList<Renderable>();
SmaliClass smaliClass = smaliMethod.getSmaliClass();
List<Instruction> instructions = rootBlock.instructions;
Instruction instruction = instructions.get(0); //TODO: fix for super(CONST, ...)
List<SmaliCodeEntity> args = instruction.getArguments();
if("invoke-direct".equals(instruction.getOpcodeData().getName())) {
//maybe this() or super() call
MethodRef methodRef = (MethodRef) args.get(args.size() - 1);
if(methodRef.isConstructor()) {
//this is this() or super() call
MethodCall methodCall = new MethodCall(MethodCall.CALL_DIRECT,
methodRef.getClassName(),
methodRef.getName());
Renderable entity = methodCall;
methodCall.setConstructorCall(true);
if(smaliClass.getSuperClassName().equals(methodRef.getClassName()))
methodCall.setSuperCall(true);
else
methodCall.setThisCall(true);
RegisterGroup regGroup = (RegisterGroup) args.get(0);
boolean skipElement = true;
for(SmaliCodeEntity regEntity : regGroup.getArguments()) {
if(skipElement) {
skipElement = false;
continue;
}
Variable var = new Variable();
var.setName(((Register)regEntity).getName());
methodCall.getParams().add(var);
}
if(smaliClass.getSuperClassName().equals("Ljava/lang/Object;"))
entity = new Comment(methodCall.render());
entities.add(entity);
}
}