NewClass Statement

This commit is contained in:
Enrico Schrödter 2015-11-18 18:10:29 +01:00
parent fc03a744fe
commit 2958c52610
4 changed files with 11 additions and 5 deletions

View File

@ -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/syntaxtree/statement/LambdaExpression.java=UTF-8
encoding//src/de/dhbwstuttgart/typeinference/SingleConstraint.java=UTF-8 encoding//src/de/dhbwstuttgart/typeinference/SingleConstraint.java=UTF-8
encoding//src/de/dhbwstuttgart/typeinference/UndConstraint.java=UTF-8 encoding//src/de/dhbwstuttgart/typeinference/UndConstraint.java=UTF-8
encoding/<project>=UTF-8

View File

@ -745,7 +745,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
} }
public void genByteCode(ClassGenerator cg) { 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(); DHBWConstantPoolGen _cp = cg.getConstantPool();
DHBWInstructionFactory _factory = new DHBWInstructionFactory(cg, _cp); DHBWInstructionFactory _factory = new DHBWInstructionFactory(cg, _cp);
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
@ -760,7 +760,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
int i = 0; int i = 0;
for(FormalParameter parameter : this.parameterlist){ for(FormalParameter parameter : this.parameterlist){
if(parameter.getType() instanceof TypePlaceholder){ if(parameter.getType() instanceof TypePlaceholder){
argumentTypes[i] = ((TypePlaceholder) parameter.getType()).getBytecodeType(cg, t); argumentTypes[i] = ((TypePlaceholder) parameter.getType()).getBytecodeType(cg, 0);
}else{ }else{
argumentTypes[i] = parameter.getType().getBytecodeType(cg); argumentTypes[i] = parameter.getType().getBytecodeType(cg);
} }
@ -776,8 +776,10 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
//Methode generieren und anfügen: //Methode generieren und anfügen:
cg.addMethod(method.createMethod(cg, getParameterList(), getType(), get_Block())); cg.addMethod(method.createMethod(cg, getParameterList(), getType(), get_Block()));
//}
} }
}
} }
// ino.end // ino.end

View File

@ -195,6 +195,10 @@ public class NewClass extends Expr
@Override @Override
public InstructionList genByteCode(ClassGenerator _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
il.append(_cg.getInstructionFactory().createNew(get_Name()));
il.append(InstructionConstants.DUP);
if(arglist!=null){ if(arglist!=null){
il.append(arglist.generateBytecode(_cg)); il.append(arglist.generateBytecode(_cg));
il.append(_cg.getInstructionFactory().createInvoke(this.get_Name(), "<init>", il.append(_cg.getInstructionFactory().createInvoke(this.get_Name(), "<init>",

View File

@ -2,9 +2,8 @@ import java.util.Vector;
class NewStatement{ class NewStatement{
Vector<Integer> vi;
void methode(){ void methode(){
Vector<Integer> vi;
vi = new Vector<Integer>(); vi = new Vector<Integer>();
} }