- Method refactored

This commit is contained in:
Enrico Schrödter 2016-04-25 14:58:52 +02:00
parent 8bad95f774
commit 8bda352bc9

View File

@ -613,45 +613,41 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
DHBWInstructionFactory _factory = cg.getInstructionFactory(); DHBWInstructionFactory _factory = cg.getInstructionFactory();
for(TypeinferenceResultSet t: typeInterferenceResults){ for(TypeinferenceResultSet t: typeInterferenceResults){
DHBWConstantPoolGen _cp = cg.getConstantPool(); addMethodToClassGenerator(cg, _factory, t);
InstructionList il = new InstructionList(); }
Class parentClass = this.getParentClass(); }
//Die Argumentliste generieren: private void addMethodToClassGenerator(ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) {
org.apache.commons.bcel6.generic.Type[] argumentTypes = org.apache.commons.bcel6.generic.Type.NO_ARGS; DHBWConstantPoolGen _cp = cg.getConstantPool();
String[] argumentNames = new String[]{}; InstructionList il = new InstructionList();
if(this.parameterlist != null && this.parameterlist.size() > 0){
argumentTypes = new org.apache.commons.bcel6.generic.Type[this.parameterlist.size()];
argumentNames = new String[this.parameterlist.size()];
int i = 0;
for(FormalParameter parameter : this.parameterlist){
argumentTypes[i] = parameter.getType().getBytecodeType(cg, t);
argumentNames[i] = parameter.getIdentifier();
org.apache.commons.bcel6.generic.Type[] argumentTypes = org.apache.commons.bcel6.generic.Type.NO_ARGS;
String[] argumentNames = new String[]{};
if(this.parameterlist != null && this.parameterlist.size() > 0){
generateArgumentList(argumentTypes, argumentNames, cg, _factory, t);
}
_factory.getStoreIndex(parameter.getIdentifier()); short constants = Constants.ACC_PUBLIC;
if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC;
i++; Type returnType = this.getType();
}
}
String nameAndSignature = get_Method_Name()+Arrays.toString(argumentTypes); MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes , argumentNames, this.get_Method_Name(), getParentClass().name, il, _cp);
Logger.getLogger("nameAndSignature").error(nameAndSignature, Section.CODEGEN); cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t));
}
private void generateArgumentList(org.apache.commons.bcel6.generic.Type[] argumentTypes, String[] argumentNames, ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) {
argumentTypes = new org.apache.commons.bcel6.generic.Type[this.parameterlist.size()];
argumentNames = new String[this.parameterlist.size()];
int i = 0;
for(FormalParameter parameter : this.parameterlist){
argumentTypes[i] = parameter.getType().getBytecodeType(cg, t);
argumentNames[i] = parameter.getIdentifier();
short constants = Constants.ACC_PUBLIC; //Per Definition ist jede Methode public _factory.getStoreIndex(parameter.getIdentifier());
if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC;
Type returnType = this.getType(); i++;
//Methode generieren:
MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes , argumentNames, this.get_Method_Name(), parentClass.name, il, _cp);
//Methode generieren und anfügen:
cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t));
Logger.getLogger("createMethod").debug(this.toString(), Section.CODEGEN);
} }
} }
} }