From 1017b027045fafb6745f0fc757b3baa5a97b9c2b Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Fri, 27 Nov 2015 16:53:01 +0100 Subject: [PATCH] Fehler in Bytecodegen der Methode beheben --- src/de/dhbwstuttgart/syntaxtree/Method.java | 22 +++++++++---------- .../syntaxtree/statement/NewClass.java | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java index 8cd9ce2b..27dc321f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/syntaxtree/Method.java @@ -767,18 +767,18 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable argumentNames[i] = parameter.getIdentifier(); i++; } - - 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(); - - //Methode generieren: - MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg), argumentTypes , argumentNames, this.get_Method_Name(), parentClass.name, il, _cp); - - //Methode generieren und anfügen: - cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block())); } + 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(); + + //Methode generieren: + MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg), argumentTypes , argumentNames, this.get_Method_Name(), parentClass.name, il, _cp); + + //Methode generieren und anfügen: + cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block())); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index c6a96214..c5b6915d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -197,7 +197,8 @@ public class NewClass extends Expr InstructionList il = new InstructionList(); //il.append(_cg.getInstructionFactory().createNew(get_Name())); il.append(_cg.getInstructionFactory().createNew(this.getType().getBytecodeType(_cg).toString())); - + il.append(InstructionConstants.DUP); + if(arglist!=null){ il.append(arglist.generateBytecode(_cg)); il.append(_cg.getInstructionFactory().createInvoke(this.getType().getDescription(), "",