From 2958c52610b546f292a1960de4f7da029100ee7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Schr=C3=B6dter?= Date: Wed, 18 Nov 2015 18:10:29 +0100 Subject: [PATCH] NewClass Statement --- .settings/org.eclipse.core.resources.prefs | 1 + src/de/dhbwstuttgart/syntaxtree/Method.java | 8 +++++--- src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java | 4 ++++ test/bytecode/types/NewStatement.jav | 3 +-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 83b729ef9..5c6e10808 100755 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -3,3 +3,4 @@ encoding//src/de/dhbwstuttgart/core/MyCompiler.java=UTF-8 encoding//src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java=UTF-8 encoding//src/de/dhbwstuttgart/typeinference/SingleConstraint.java=UTF-8 encoding//src/de/dhbwstuttgart/typeinference/UndConstraint.java=UTF-8 +encoding/=UTF-8 diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java index f4743a088..659a522d9 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/syntaxtree/Method.java @@ -745,7 +745,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable } public void genByteCode(ClassGenerator cg) { - for(int t = 0; t < cg.getTypeinferenceResults().getTypeReconstructions().size(); t++){ + //for(int t = 0; t < cg.getTypeinferenceResults().getTypeReconstructions().size(); t++){ DHBWConstantPoolGen _cp = cg.getConstantPool(); DHBWInstructionFactory _factory = new DHBWInstructionFactory(cg, _cp); InstructionList il = new InstructionList(); @@ -760,7 +760,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable int i = 0; for(FormalParameter parameter : this.parameterlist){ if(parameter.getType() instanceof TypePlaceholder){ - argumentTypes[i] = ((TypePlaceholder) parameter.getType()).getBytecodeType(cg, t); + argumentTypes[i] = ((TypePlaceholder) parameter.getType()).getBytecodeType(cg, 0); }else{ argumentTypes[i] = parameter.getType().getBytecodeType(cg); } @@ -776,8 +776,10 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable //Methode generieren und anfügen: cg.addMethod(method.createMethod(cg, getParameterList(), getType(), get_Block())); - } + //} } + + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index bdba34bfa..03abb51ff 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -195,6 +195,10 @@ public class NewClass extends Expr @Override public InstructionList genByteCode(ClassGenerator _cg) { InstructionList il = new InstructionList(); + + il.append(_cg.getInstructionFactory().createNew(get_Name())); + il.append(InstructionConstants.DUP); + if(arglist!=null){ il.append(arglist.generateBytecode(_cg)); il.append(_cg.getInstructionFactory().createInvoke(this.get_Name(), "", diff --git a/test/bytecode/types/NewStatement.jav b/test/bytecode/types/NewStatement.jav index ccded70b5..9a8128367 100644 --- a/test/bytecode/types/NewStatement.jav +++ b/test/bytecode/types/NewStatement.jav @@ -2,9 +2,8 @@ import java.util.Vector; class NewStatement{ - Vector vi; - void methode(){ + Vector vi; vi = new Vector(); }