From ed246e0f8860dd175cd6b608b3725138817082a1 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Fri, 13 Nov 2015 16:29:41 +0100 Subject: [PATCH] Fehler in NewClass und Constructor beheben --- src/de/dhbwstuttgart/syntaxtree/Constructor.java | 2 +- src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/Constructor.java b/src/de/dhbwstuttgart/syntaxtree/Constructor.java index 251124cde..7a6b443cb 100644 --- a/src/de/dhbwstuttgart/syntaxtree/Constructor.java +++ b/src/de/dhbwstuttgart/syntaxtree/Constructor.java @@ -66,7 +66,7 @@ public class Constructor extends Method { InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen Class parentClass = this.getParentClass(); - MethodGenerator method = new MethodGenerator(Constants.ACC_PUBLIC, this.getType().getBytecodeType(cg), org.apache.commons.bcel6.generic.Type.NO_ARGS , new String[] { }, "", parentClass.name, il, _cp); + MethodGenerator method = new MethodGenerator(Constants.ACC_PUBLIC, this.getType().getBytecodeType(cg), this.parameterlist.getBytecodeTypeList(cg) , this.parameterlist.getParameterNameArray(), "", parentClass.name, il, _cp); //FieldInitializations an Block anfügen Block block = this.get_Block(); diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index bdba34bfa..b8c7143e3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -195,13 +195,15 @@ public class NewClass extends Expr @Override public InstructionList genByteCode(ClassGenerator _cg) { InstructionList il = new InstructionList(); + 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.get_Name(), "", + il.append(_cg.getInstructionFactory().createInvoke(this.getType().getDescription(), "", org.apache.commons.bcel6.generic.Type.VOID, this.arglist.getBytecodeTypeList(_cg), Constants.INVOKESPECIAL)); }else{ - il.append(_cg.getInstructionFactory().createInvoke(this.get_Name(), "", + il.append(_cg.getInstructionFactory().createInvoke(this.getType().getDescription(), "", org.apache.commons.bcel6.generic.Type.VOID, new org.apache.commons.bcel6.generic.Type[]{}, Constants.INVOKESPECIAL)); }