From e33b9fd76ee5e27dc43cdf409aa7ddacec3aff43 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 19 Feb 2014 17:32:43 +0100 Subject: [PATCH] weitere Fehler behoben --- bin/mycompiler/myparser/JavaParser.jay | 42 +++++++------- src/mycompiler/myclass/Class.java | 29 ++++++---- src/mycompiler/myclass/Constructor.java | 22 +++----- src/mycompiler/myclass/Method.java | 55 +++++++++---------- src/mycompiler/myclass/ParameterList.java | 9 ++- src/mycompiler/myparser/JavaParser.java | 42 +++++++------- src/mycompiler/myparser/JavaParser.jay | 42 +++++++------- test/mycompiler/test/lambda/TestWhile.jav | 2 +- .../test/lambda/testResults/LambdaTest.log | 10 ++-- 9 files changed, 128 insertions(+), 125 deletions(-) diff --git a/bin/mycompiler/myparser/JavaParser.jay b/bin/mycompiler/myparser/JavaParser.jay index a2755734b..793ea1630 100755 --- a/bin/mycompiler/myparser/JavaParser.jay +++ b/bin/mycompiler/myparser/JavaParser.jay @@ -1035,45 +1035,45 @@ boundedMethodParameters : boundedMethodParameter // returns Method methodheader :'<' boundedMethodParameters '>' type methoddeclarator { - $5.setReturnType($4); + $5.setType($4); $5.setGenericMethodParameters($2); $$=$5; } | type methoddeclarator { - $2.setReturnType($1); + $2.setType($1); $$=$2; } | modifiers type methoddeclarator { $3.set_Modifiers($1); - $3.setReturnType($2); + $3.setType($2); $$=$3; } | modifiers '<' boundedMethodParameters '>' type methoddeclarator { $6.set_Modifiers($1); $6.setGenericMethodParameters($3); - $6.setReturnType($5); + $6.setType($5); $$=$6; } | type methoddeclarator throws { - $2.setReturnType($1); + $2.setType($1); $2.set_ExceptionList($3); $$=$2; } | '<' boundedMethodParameters '>' type methoddeclarator throws { $5.setGenericMethodParameters($2); - $5.setReturnType($4); + $5.setType($4); $5.set_ExceptionList($6); $$=$5; } | modifiers type methoddeclarator throws { $3.set_Modifiers($1); - $3.setReturnType($2); + $3.setType($2); $3.set_ExceptionList($4); $$=$3; } @@ -1081,27 +1081,27 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator { $6.set_Modifiers($1); $6.setGenericMethodParameters($3); - $6.setReturnType($5); + $6.setType($5); $6.set_ExceptionList($7); $$=$6; } | VOID methoddeclarator { Void Voit = new Void($1.getOffset()); - $2.setReturnType(Voit); + $2.setType(Voit); $$=$2; } | modifiers VOID methoddeclarator { Void voit = new Void($2.getOffset()); $3.set_Modifiers($1); - $3.setReturnType(voit); + $3.setType(voit); $$=$3; } | VOID methoddeclarator throws { Void voyt = new Void($1.getOffset()); - $2.setReturnType(voyt); + $2.setType(voyt); $2.set_ExceptionList($3); $$=$2; } @@ -1109,14 +1109,14 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator { Void voyd = new Void($2.getOffset()); $3.set_Modifiers($1); - $3.setReturnType(voyd); + $3.setType(voyd); $3.set_ExceptionList($4); $$=$3; } | '<' boundedMethodParameters '>' VOID methoddeclarator { Void Voit = new Void($4.getOffset()); - $5.setReturnType(Voit); + $5.setType(Voit); $5.setGenericMethodParameters($2); $$=$5; } @@ -1124,14 +1124,14 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator { Void voit = new Void($5.getOffset()); $6.set_Modifiers($1); - $6.setReturnType(voit); + $6.setType(voit); $6.setGenericMethodParameters($3); $$=$6; } | '<' boundedMethodParameters '>' VOID methoddeclarator throws { Void voyt = new Void($4.getOffset()); - $5.setReturnType(voyt); + $5.setType(voyt); $5.set_ExceptionList($6); $5.setGenericMethodParameters($2); $$=$5; @@ -1140,7 +1140,7 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator { Void voyd = new Void($5.getOffset()); $6.set_Modifiers($1); - $6.setReturnType(voyd); + $6.setType(voyd); $6.set_ExceptionList($7); $6.setGenericMethodParameters($3); $$=$6; @@ -1148,12 +1148,12 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator | methoddeclarator { - //auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh()); $$=$1; } | '<' boundedMethodParameters '>' methoddeclarator { - //auskommentiert von Andreas Stadelmeier (a10023) $4.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh()); $4.setGenericMethodParameters($2); $$=$4; } @@ -1161,19 +1161,19 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator | modifiers methoddeclarator { $2.set_Modifiers($1); - //auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh()); $$=$2; } | methoddeclarator throws { - //auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh()); $1.set_ExceptionList($2); $$=$1; } | modifiers methoddeclarator throws { $2.set_Modifiers($1); - //auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh()); $2.set_ExceptionList($3); $$=$2; } diff --git a/src/mycompiler/myclass/Class.java b/src/mycompiler/myclass/Class.java index 49e01d961..e89d30a77 100755 --- a/src/mycompiler/myclass/Class.java +++ b/src/mycompiler/myclass/Class.java @@ -247,14 +247,8 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface */ public void addField(Field i) { - Field tempField = i; - if(i instanceof Method){ - Method method = (Method)i; - if(method.get_Method_Name().equals(this.getName()) ){ - tempField = new Constructor(method); - } - } - fielddecl.addElement(tempField); + + fielddecl.addElement(i); } // ino.method.getUsedIdsToCheck.23050.definition @@ -1267,6 +1261,23 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface @Override public void parserPostProcessing(SyntaxTreeNode parent) { super.parserPostProcessing(parent); + + //Alle Methoden auf Konstruktoren durchsuchen und diese umwandeln: + Vector tempFields = new Vector(); + for(Field f : this.getFields()){ + if(f instanceof Method && !(f instanceof Constructor)){ + Method method = (Method)f; + if(method.get_Method_Name().equals(this.getName()) ){ + tempFields.add(new Constructor(method)); + }else{ + tempFields.add(f); + } + }else{ + tempFields.add(f); + } + } + this.fielddecl = tempFields; + //Prüfen ob ein Konstruktor vorhanden ist: boolean constructorVorhanden = false; for(Field f : this.getFields()){ @@ -1276,8 +1287,6 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface } } if(!constructorVorhanden){//Falls kein Konstruktor vorhanden ist, muss noch der Standardkonstruktor angefügt werden: - - Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(this.getName(), this)); this.addField(standardKonstruktor); } diff --git a/src/mycompiler/myclass/Constructor.java b/src/mycompiler/myclass/Constructor.java index 767a683f0..5a611fc96 100644 --- a/src/mycompiler/myclass/Constructor.java +++ b/src/mycompiler/myclass/Constructor.java @@ -15,6 +15,7 @@ import typinferenz.ConstraintsSet; import typinferenz.JavaCodeResult; import typinferenz.ResultSet; import typinferenz.SingleConstraint; +import typinferenz.TypinferenzException; import typinferenz.assumptions.TypeAssumptions; public class Constructor extends Method { @@ -27,6 +28,7 @@ public class Constructor extends Method { public Constructor(Method methode){ this.methode = methode; this.setDeclIdVector(methode.getDeclIdVector()); + this.methode.setType(new RefType(this.methode.getParentClass().getName(),0)); } @Override @@ -51,7 +53,7 @@ public class Constructor extends Method { @Override public String getTypeName() { - return this.methode.getTypeName(); + return this.getType().getName(); } @Override @@ -60,11 +62,7 @@ public class Constructor extends Method { return this.methode.get_Block(); } - @Override - public void setReturnType(Type type) { - - this.methode.setReturnType(type); - } + @Override public void set_Block(Block blo) { @@ -120,12 +118,6 @@ public class Constructor extends Method { this.methode.setOverloadedID(overloadedID); } - @Override - public Type getReturnType() { - - return this.methode.getReturnType(); - } - @Override public String get_codegen_Param_Type(Vector paralist) { @@ -262,13 +254,13 @@ public class Constructor extends Method { @Override public void setType(Type t) { - - this.methode.setType(t); + throw new TypinferenzException("Einem Konstruktor kann kein Typ zugewiesen werden"); + //this.methode.setType(t); } @Override public Type getType() { - return new RefType(this.methode.getParentClass().getName(),0); + return this.methode.getType(); } diff --git a/src/mycompiler/myclass/Method.java b/src/mycompiler/myclass/Method.java index f2465cc48..702402b4c 100755 --- a/src/mycompiler/myclass/Method.java +++ b/src/mycompiler/myclass/Method.java @@ -38,6 +38,7 @@ import typinferenz.ConstraintsSet; import typinferenz.ResultSet; import typinferenz.TypeInsertable; import typinferenz.assumptions.MethodAssumption; +import typinferenz.assumptions.ParameterAssumption; import typinferenz.assumptions.TypeAssumptions; @@ -168,10 +169,10 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith // ino.end // ino.method.getTypeName.23533.body { - if( this.getReturnType() == null ) + if( this.getType() == null ) return null; else - return this.getReturnType().getName(); + return this.getType().getName(); } // ino.end @@ -191,7 +192,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith */ // ino.end // ino.method.setReturnType.23539.definition - public void setReturnType(Type type) + private void setReturnType(Type type) // ino.end // ino.method.setReturnType.23539.body { @@ -301,20 +302,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith } // ino.end - /** - * Liefert den Return Type der Methode. - * Dieser entspricht dem Returntype des Methoden-Block's - * @returnb - */ - // ino.method.getReturnType.23569.definition - public Type getReturnType() - // ino.end - // ino.method.getReturnType.23569.body - { - return this.returntype; //auskommentiert von Andreas Stadelmeier (a10023) - } - // ino.end - + // ino.method.get_codegen_Param_Type.23572.definition @@ -331,13 +319,13 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith { ret += this.getParameterList().get_codegen_ParameterList(paralist); } - if(this.getReturnType() == null) + if(this.getType() == null) { ret += "V"; } else { - ret += this.getReturnType().get_codegen_Type(paralist); + ret += this.getType().get_codegen_Type(paralist); } return ret; } @@ -372,7 +360,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith // ino.end // ino.method.codegen.23581.body { - classfile.add_method(declid.firstElement().get_Name(), this.get_codegen_Param_Type(paralist), this.getParameterList(), this.getReturnType(), block, declid.firstElement().get_access_flags(), paralist, isAbstract); + classfile.add_method(declid.firstElement().get_Name(), this.get_codegen_Param_Type(paralist), this.getParameterList(), this.getType(), block, declid.firstElement().get_access_flags(), paralist, isAbstract); } // ino.end @@ -472,7 +460,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith // ino.end // ino.method.toString.23605.body { - return this.getReturnType() + " " + block.toString(); + return this.getType() + " " + block.toString(); } // ino.end @@ -511,7 +499,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith // ino.method.wandleRefTypeAttributes2GenericAttributes.23614.body { // Zuerst Returntype untersuchen - Type returnType=getReturnType(); + Type returnType=getType(); GenericTypeVar pendantReturnType=ClassHelper.findGenericType(returnType, paralist,genericMethodParameters); if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren setReturnType(pendantReturnType); @@ -547,8 +535,13 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith public ConstraintsSet TYPE(TypeAssumptions ass) { ConstraintsSet ret = new ConstraintsSet(); - - ret.add(this.block.TYPEStmt(ass)); + TypeAssumptions localAss = new TypeAssumptions(); + localAss.add(ass); //Die globalen Assumptions anhängen + //Die Parameter zu den Assumptions hinzufügen: + if(this.parameterlist!=null)for(FormalParameter param : this.parameterlist){ + localAss.addParameterAssumption(new ParameterAssumption(param)); + } + ret.add(this.block.TYPEStmt(localAss)); //eine Verknüpfung mit der Type Assumption aus dem Assumption Set und dem ermittelten Typ der Methode: ret.add(new SingleConstraint(this.block.getType(), this.returntype)); return ret; @@ -560,13 +553,13 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith */ public String getTypeInformation(){ if(this.parameterlist!=null)return "Methode "+this.get_Name()+ " Parameter: "+this.parameterlist.getTypeInformation()+", Block: "+this.block.getTypeInformation(); - return "Methode "+this.get_Name()+" : "+this.getReturnType()+", Block: "+this.block.getTypeInformation(); + return "Methode "+this.get_Name()+" : "+this.getType()+", Block: "+this.block.getTypeInformation(); } @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { JavaCodeResult ret = new JavaCodeResult(); - ret.attach(this.getReturnType().printJavaCode(resultSet)).attach(" ").attach(this.get_Method_Name()).attach("()\n"); //TODO: hier müssen auch noch die Parameter ausgegeben werden! + ret.attach(this.getType().printJavaCode(resultSet)).attach(" ").attach(this.get_Method_Name()).attach("()\n"); //TODO: hier müssen auch noch die Parameter ausgegeben werden! ret.attach(this.block.printJavaCode(resultSet)); return ret; @@ -581,7 +574,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith /* TypeAssumptions assumptions = new TypeAssumptions(); this.assumedType = null; - //if((this.get_Method_Name().equals(classmember.getName()) || this.get_Method_Name().equals("")) && ((this.getReturnType().equals(new mycompiler.mytype.Void(0))) || this.getReturnType() instanceof TypePlaceholder)){ + //if((this.get_Method_Name().equals(classmember.getName()) || this.get_Method_Name().equals("")) && ((this.getType().equals(new mycompiler.mytype.Void(0))) || this.getType() instanceof TypePlaceholder)){ if((this.get_Method_Name().equals(classmember.getName()) || this.get_Method_Name().equals(""))) { this.set_Method_Name(""); this.assumedType = new RefType(classmember.getName(),0); @@ -609,7 +602,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith //methodList.addElement(method); //F�r V_fields_methods: - CMethodTypeAssumption methodAssum = new CMethodTypeAssumption(classmember.getType(), this.get_Method_Name(), this.getReturnType(), this.getParameterCount(),this.getLineNumber(),this.getOffset(),new Vector(),this.getGenericMethodParameters()); // Typannahme bauen... + CMethodTypeAssumption methodAssum = new CMethodTypeAssumption(classmember.getType(), this.get_Method_Name(), this.getType(), this.getParameterCount(),this.getLineNumber(),this.getOffset(),new Vector(),this.getGenericMethodParameters()); // Typannahme bauen... //Methode in V_Fields_methods ablegen @@ -681,6 +674,9 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith this.returntype = t; } + /** + * Der Typ einer Methode ist ihr Returntype + */ @Override public Type getType(){ //Methode und Block teilen sich einen ReturnType: @@ -695,8 +691,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith Block tempBlock = new Block(); //tempBlock.setType(new RefType(parent.getName(),0)); ret.set_Block(tempBlock); - ret.setType(TypePlaceholder.fresh(ret)); - ret.parent = parent; + ret.parserPostProcessing(parent); return ret; } diff --git a/src/mycompiler/myclass/ParameterList.java b/src/mycompiler/myclass/ParameterList.java index 6a7b49528..ba299a550 100755 --- a/src/mycompiler/myclass/ParameterList.java +++ b/src/mycompiler/myclass/ParameterList.java @@ -16,7 +16,7 @@ import java.util.Iterator; // ino.class.ParameterList.23620.declaration -public class ParameterList +public class ParameterList implements Iterable // ino.end // ino.class.ParameterList.23620.body { @@ -146,5 +146,12 @@ public class ParameterList return ret; } + + + @Override + public Iterator iterator() { + return this.formalparameter.iterator(); + } + } // ino.end diff --git a/src/mycompiler/myparser/JavaParser.java b/src/mycompiler/myparser/JavaParser.java index 4c0a9726d..1f5ddd2d5 100644 --- a/src/mycompiler/myparser/JavaParser.java +++ b/src/mycompiler/myparser/JavaParser.java @@ -1563,7 +1563,7 @@ case 102: case 103: // line 1037 "./../src/mycompiler/myparser/JavaParser.jay" { - ((Method)yyVals[0+yyTop]).setReturnType(((Type)yyVals[-1+yyTop])); + ((Method)yyVals[0+yyTop]).setType(((Type)yyVals[-1+yyTop])); ((Method)yyVals[0+yyTop]).setGenericMethodParameters(((Vector)yyVals[-3+yyTop])); yyVal=((Method)yyVals[0+yyTop]); } @@ -1571,7 +1571,7 @@ case 103: case 104: // line 1043 "./../src/mycompiler/myparser/JavaParser.jay" { - ((Method)yyVals[0+yyTop]).setReturnType(((Type)yyVals[-1+yyTop])); + ((Method)yyVals[0+yyTop]).setType(((Type)yyVals[-1+yyTop])); yyVal=((Method)yyVals[0+yyTop]); } break; @@ -1579,7 +1579,7 @@ case 105: // line 1048 "./../src/mycompiler/myparser/JavaParser.jay" { ((Method)yyVals[0+yyTop]).set_Modifiers(((Modifiers)yyVals[-2+yyTop])); - ((Method)yyVals[0+yyTop]).setReturnType(((Type)yyVals[-1+yyTop])); + ((Method)yyVals[0+yyTop]).setType(((Type)yyVals[-1+yyTop])); yyVal=((Method)yyVals[0+yyTop]); } break; @@ -1588,14 +1588,14 @@ case 106: { ((Method)yyVals[0+yyTop]).set_Modifiers(((Modifiers)yyVals[-5+yyTop])); ((Method)yyVals[0+yyTop]).setGenericMethodParameters(((Vector)yyVals[-3+yyTop])); - ((Method)yyVals[0+yyTop]).setReturnType(((Type)yyVals[-1+yyTop])); + ((Method)yyVals[0+yyTop]).setType(((Type)yyVals[-1+yyTop])); yyVal=((Method)yyVals[0+yyTop]); } break; case 107: // line 1061 "./../src/mycompiler/myparser/JavaParser.jay" { - ((Method)yyVals[-1+yyTop]).setReturnType(((Type)yyVals[-2+yyTop])); + ((Method)yyVals[-1+yyTop]).setType(((Type)yyVals[-2+yyTop])); ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); } @@ -1604,7 +1604,7 @@ case 108: // line 1067 "./../src/mycompiler/myparser/JavaParser.jay" { ((Method)yyVals[-1+yyTop]).setGenericMethodParameters(((Vector)yyVals[-4+yyTop])); - ((Method)yyVals[-1+yyTop]).setReturnType(((Type)yyVals[-2+yyTop])); + ((Method)yyVals[-1+yyTop]).setType(((Type)yyVals[-2+yyTop])); ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); } @@ -1613,7 +1613,7 @@ case 109: // line 1074 "./../src/mycompiler/myparser/JavaParser.jay" { ((Method)yyVals[-1+yyTop]).set_Modifiers(((Modifiers)yyVals[-3+yyTop])); - ((Method)yyVals[-1+yyTop]).setReturnType(((Type)yyVals[-2+yyTop])); + ((Method)yyVals[-1+yyTop]).setType(((Type)yyVals[-2+yyTop])); ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); } @@ -1623,7 +1623,7 @@ case 110: { ((Method)yyVals[-1+yyTop]).set_Modifiers(((Modifiers)yyVals[-6+yyTop])); ((Method)yyVals[-1+yyTop]).setGenericMethodParameters(((Vector)yyVals[-4+yyTop])); - ((Method)yyVals[-1+yyTop]).setReturnType(((Type)yyVals[-2+yyTop])); + ((Method)yyVals[-1+yyTop]).setType(((Type)yyVals[-2+yyTop])); ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); } @@ -1632,7 +1632,7 @@ case 111: // line 1089 "./../src/mycompiler/myparser/JavaParser.jay" { Void Voit = new Void(((Token)yyVals[-1+yyTop]).getOffset()); - ((Method)yyVals[0+yyTop]).setReturnType(Voit); + ((Method)yyVals[0+yyTop]).setType(Voit); yyVal=((Method)yyVals[0+yyTop]); } break; @@ -1641,7 +1641,7 @@ case 112: { Void voit = new Void(((Token)yyVals[-1+yyTop]).getOffset()); ((Method)yyVals[0+yyTop]).set_Modifiers(((Modifiers)yyVals[-2+yyTop])); - ((Method)yyVals[0+yyTop]).setReturnType(voit); + ((Method)yyVals[0+yyTop]).setType(voit); yyVal=((Method)yyVals[0+yyTop]); } break; @@ -1649,7 +1649,7 @@ case 113: // line 1102 "./../src/mycompiler/myparser/JavaParser.jay" { Void voyt = new Void(((Token)yyVals[-2+yyTop]).getOffset()); - ((Method)yyVals[-1+yyTop]).setReturnType(voyt); + ((Method)yyVals[-1+yyTop]).setType(voyt); ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); } @@ -1659,7 +1659,7 @@ case 114: { Void voyd = new Void(((Token)yyVals[-2+yyTop]).getOffset()); ((Method)yyVals[-1+yyTop]).set_Modifiers(((Modifiers)yyVals[-3+yyTop])); - ((Method)yyVals[-1+yyTop]).setReturnType(voyd); + ((Method)yyVals[-1+yyTop]).setType(voyd); ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); } @@ -1668,7 +1668,7 @@ case 115: // line 1117 "./../src/mycompiler/myparser/JavaParser.jay" { Void Voit = new Void(((Token)yyVals[-1+yyTop]).getOffset()); - ((Method)yyVals[0+yyTop]).setReturnType(Voit); + ((Method)yyVals[0+yyTop]).setType(Voit); ((Method)yyVals[0+yyTop]).setGenericMethodParameters(((Vector)yyVals[-3+yyTop])); yyVal=((Method)yyVals[0+yyTop]); } @@ -1678,7 +1678,7 @@ case 116: { Void voit = new Void(((Token)yyVals[-1+yyTop]).getOffset()); ((Method)yyVals[0+yyTop]).set_Modifiers(((Modifiers)yyVals[-5+yyTop])); - ((Method)yyVals[0+yyTop]).setReturnType(voit); + ((Method)yyVals[0+yyTop]).setType(voit); ((Method)yyVals[0+yyTop]).setGenericMethodParameters(((Vector)yyVals[-3+yyTop])); yyVal=((Method)yyVals[0+yyTop]); } @@ -1687,7 +1687,7 @@ case 117: // line 1132 "./../src/mycompiler/myparser/JavaParser.jay" { Void voyt = new Void(((Token)yyVals[-2+yyTop]).getOffset()); - ((Method)yyVals[-1+yyTop]).setReturnType(voyt); + ((Method)yyVals[-1+yyTop]).setType(voyt); ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); ((Method)yyVals[-1+yyTop]).setGenericMethodParameters(((Vector)yyVals[-4+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); @@ -1698,7 +1698,7 @@ case 118: { Void voyd = new Void(((Token)yyVals[-2+yyTop]).getOffset()); ((Method)yyVals[-1+yyTop]).set_Modifiers(((Modifiers)yyVals[-6+yyTop])); - ((Method)yyVals[-1+yyTop]).setReturnType(voyd); + ((Method)yyVals[-1+yyTop]).setType(voyd); ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); ((Method)yyVals[-1+yyTop]).setGenericMethodParameters(((Vector)yyVals[-4+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); @@ -1707,14 +1707,14 @@ case 118: case 119: // line 1150 "./../src/mycompiler/myparser/JavaParser.jay" { - /*auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh()); */ + /*auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh()); */ yyVal=((Method)yyVals[0+yyTop]); } break; case 120: // line 1155 "./../src/mycompiler/myparser/JavaParser.jay" { - /*auskommentiert von Andreas Stadelmeier (a10023) $4.setReturnType(TypePlaceholder.fresh());*/ + /*auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh());*/ ((Method)yyVals[0+yyTop]).setGenericMethodParameters(((Vector)yyVals[-2+yyTop])); yyVal=((Method)yyVals[0+yyTop]); } @@ -1723,14 +1723,14 @@ case 121: // line 1162 "./../src/mycompiler/myparser/JavaParser.jay" { ((Method)yyVals[0+yyTop]).set_Modifiers(((Modifiers)yyVals[-1+yyTop])); - /*auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh());*/ + /*auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh());*/ yyVal=((Method)yyVals[0+yyTop]); } break; case 122: // line 1168 "./../src/mycompiler/myparser/JavaParser.jay" { - /*auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh());*/ + /*auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());*/ ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); } @@ -1739,7 +1739,7 @@ case 123: // line 1174 "./../src/mycompiler/myparser/JavaParser.jay" { ((Method)yyVals[-1+yyTop]).set_Modifiers(((Modifiers)yyVals[-2+yyTop])); - /*auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh());*/ + /*auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh());*/ ((Method)yyVals[-1+yyTop]).set_ExceptionList(((ExceptionList)yyVals[0+yyTop])); yyVal=((Method)yyVals[-1+yyTop]); } diff --git a/src/mycompiler/myparser/JavaParser.jay b/src/mycompiler/myparser/JavaParser.jay index a2755734b..793ea1630 100755 --- a/src/mycompiler/myparser/JavaParser.jay +++ b/src/mycompiler/myparser/JavaParser.jay @@ -1035,45 +1035,45 @@ boundedMethodParameters : boundedMethodParameter // returns Method methodheader :'<' boundedMethodParameters '>' type methoddeclarator { - $5.setReturnType($4); + $5.setType($4); $5.setGenericMethodParameters($2); $$=$5; } | type methoddeclarator { - $2.setReturnType($1); + $2.setType($1); $$=$2; } | modifiers type methoddeclarator { $3.set_Modifiers($1); - $3.setReturnType($2); + $3.setType($2); $$=$3; } | modifiers '<' boundedMethodParameters '>' type methoddeclarator { $6.set_Modifiers($1); $6.setGenericMethodParameters($3); - $6.setReturnType($5); + $6.setType($5); $$=$6; } | type methoddeclarator throws { - $2.setReturnType($1); + $2.setType($1); $2.set_ExceptionList($3); $$=$2; } | '<' boundedMethodParameters '>' type methoddeclarator throws { $5.setGenericMethodParameters($2); - $5.setReturnType($4); + $5.setType($4); $5.set_ExceptionList($6); $$=$5; } | modifiers type methoddeclarator throws { $3.set_Modifiers($1); - $3.setReturnType($2); + $3.setType($2); $3.set_ExceptionList($4); $$=$3; } @@ -1081,27 +1081,27 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator { $6.set_Modifiers($1); $6.setGenericMethodParameters($3); - $6.setReturnType($5); + $6.setType($5); $6.set_ExceptionList($7); $$=$6; } | VOID methoddeclarator { Void Voit = new Void($1.getOffset()); - $2.setReturnType(Voit); + $2.setType(Voit); $$=$2; } | modifiers VOID methoddeclarator { Void voit = new Void($2.getOffset()); $3.set_Modifiers($1); - $3.setReturnType(voit); + $3.setType(voit); $$=$3; } | VOID methoddeclarator throws { Void voyt = new Void($1.getOffset()); - $2.setReturnType(voyt); + $2.setType(voyt); $2.set_ExceptionList($3); $$=$2; } @@ -1109,14 +1109,14 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator { Void voyd = new Void($2.getOffset()); $3.set_Modifiers($1); - $3.setReturnType(voyd); + $3.setType(voyd); $3.set_ExceptionList($4); $$=$3; } | '<' boundedMethodParameters '>' VOID methoddeclarator { Void Voit = new Void($4.getOffset()); - $5.setReturnType(Voit); + $5.setType(Voit); $5.setGenericMethodParameters($2); $$=$5; } @@ -1124,14 +1124,14 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator { Void voit = new Void($5.getOffset()); $6.set_Modifiers($1); - $6.setReturnType(voit); + $6.setType(voit); $6.setGenericMethodParameters($3); $$=$6; } | '<' boundedMethodParameters '>' VOID methoddeclarator throws { Void voyt = new Void($4.getOffset()); - $5.setReturnType(voyt); + $5.setType(voyt); $5.set_ExceptionList($6); $5.setGenericMethodParameters($2); $$=$5; @@ -1140,7 +1140,7 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator { Void voyd = new Void($5.getOffset()); $6.set_Modifiers($1); - $6.setReturnType(voyd); + $6.setType(voyd); $6.set_ExceptionList($7); $6.setGenericMethodParameters($3); $$=$6; @@ -1148,12 +1148,12 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator | methoddeclarator { - //auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh()); $$=$1; } | '<' boundedMethodParameters '>' methoddeclarator { - //auskommentiert von Andreas Stadelmeier (a10023) $4.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh()); $4.setGenericMethodParameters($2); $$=$4; } @@ -1161,19 +1161,19 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator | modifiers methoddeclarator { $2.set_Modifiers($1); - //auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh()); $$=$2; } | methoddeclarator throws { - //auskommentiert von Andreas Stadelmeier (a10023) $1.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh()); $1.set_ExceptionList($2); $$=$1; } | modifiers methoddeclarator throws { $2.set_Modifiers($1); - //auskommentiert von Andreas Stadelmeier (a10023) $2.setReturnType(TypePlaceholder.fresh()); + //auskommentiert von Andreas Stadelmeier (a10023) $2.setType(TypePlaceholder.fresh()); $2.set_ExceptionList($3); $$=$2; } diff --git a/test/mycompiler/test/lambda/TestWhile.jav b/test/mycompiler/test/lambda/TestWhile.jav index 019bf8f4e..504a72cf1 100755 --- a/test/mycompiler/test/lambda/TestWhile.jav +++ b/test/mycompiler/test/lambda/TestWhile.jav @@ -1,7 +1,7 @@ class WhileTest{ - public method(){ var; + public method(){ while(true){ var = "String"; } diff --git a/test/mycompiler/test/lambda/testResults/LambdaTest.log b/test/mycompiler/test/lambda/testResults/LambdaTest.log index 34982e52d..57d84f71e 100644 --- a/test/mycompiler/test/lambda/testResults/LambdaTest.log +++ b/test/mycompiler/test/lambda/testResults/LambdaTest.log @@ -1,11 +1,11 @@ -Class DEBUG [Typeinference] Erstellte Assumptions: this: LambdaTest1Method Assumptions: -[typinferenz.assumptions.MethodAssumption@1e54f9f6, typinferenz.assumptions.MethodAssumption@5ce69508] +Class DEBUG [Typeinference] Erstellte Assumptions: this: WhileTestMethod Assumptions: +[typinferenz.assumptions.MethodAssumption@52f37721, typinferenz.assumptions.MethodAssumption@6e124212] FieldVar Assumptions: -[typinferenz.assumptions.FieldAssumption@26426fde] +[typinferenz.assumptions.FieldAssumption@70afe432] LocalVar Assumptions: [] Parameter Assumptions: [] -Block DEBUG [Typeinference] Prozessing statement: null Return null (( [ String text, ]) -> null { [null Return toAppend]) -Block DEBUG [Typeinference] Prozessing statement: null Return toAppend +Block DEBUG [Typeinference] Prozessing statement: WHILE null { [(var = mycompiler.mystatement.StringLiteral@2a2d0d78)] +Block DEBUG [Typeinference] Prozessing statement: (var = mycompiler.mystatement.StringLiteral@2a2d0d78)