diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java index 9a59788a5..3dcaf42a4 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/syntaxtree/Method.java @@ -613,45 +613,41 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable DHBWInstructionFactory _factory = cg.getInstructionFactory(); for(TypeinferenceResultSet t: typeInterferenceResults){ - DHBWConstantPoolGen _cp = cg.getConstantPool(); - InstructionList il = new InstructionList(); - Class parentClass = this.getParentClass(); - - //Die Argumentliste generieren: - 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){ - 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(); - - - _factory.getStoreIndex(parameter.getIdentifier()); - - i++; - } - } - - String nameAndSignature = get_Method_Name()+Arrays.toString(argumentTypes); - - Logger.getLogger("nameAndSignature").error(nameAndSignature, Section.CODEGEN); - + addMethodToClassGenerator(cg, _factory, t); + } + } - short constants = Constants.ACC_PUBLIC; //Per Definition ist jede Methode public - if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC; - - Type returnType = this.getType(); + private void addMethodToClassGenerator(ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) { + DHBWConstantPoolGen _cp = cg.getConstantPool(); + InstructionList il = new InstructionList(); + + 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); + } + + short constants = Constants.ACC_PUBLIC; + if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC; + + Type returnType = this.getType(); + + MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes , argumentNames, this.get_Method_Name(), getParentClass().name, il, _cp); + + 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(); - //Methode generieren: - MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes , argumentNames, this.get_Method_Name(), parentClass.name, il, _cp); + _factory.getStoreIndex(parameter.getIdentifier()); - //Methode generieren und anfügen: - cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t)); - - Logger.getLogger("createMethod").debug(this.toString(), Section.CODEGEN); + i++; } } }