Fehler in LocalVarAssumption behoben

This commit is contained in:
JanUlrich 2014-02-19 06:09:59 +01:00
parent 8d26f06092
commit e31725f255
4 changed files with 42 additions and 19 deletions

View File

@ -14,6 +14,7 @@ import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.SingleConstraint;
import typinferenz.assumptions.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
public class Constructor extends Method { public class Constructor extends Method {
@ -222,10 +223,11 @@ public class Constructor extends Method {
this.methode.set_Method_Name(string); this.methode.set_Method_Name(string);
} }
@Override
public ConstraintsSet TYPE(TypeAssumptions ass) { public ConstraintsSet TYPE(TypeAssumptions ass) {
ConstraintsSet ret = new ConstraintsSet();
return this.methode.TYPE(ass);
ret.add(this.methode.get_Block().TYPEStmt(ass));
return ret;
} }
@Override @Override

View File

@ -203,9 +203,6 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
((TypePlaceholder)type).addReplacementListener(this); ((TypePlaceholder)type).addReplacementListener(this);
} }
// this.returntype = type; //auskommentiert von Andreas Stadelmeier (a10023) // this.returntype = type; //auskommentiert von Andreas Stadelmeier (a10023)
//Der ReturnType der Methode ist der Returntype des Methodenblocks:
if(block!=null)
this.block.setType(type);
this.returntype = type; this.returntype = type;
} }
// ino.end // ino.end
@ -314,8 +311,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
// ino.end // ino.end
// ino.method.getReturnType.23569.body // ino.method.getReturnType.23569.body
{ {
return this.block.getType(); return this.returntype; //auskommentiert von Andreas Stadelmeier (a10023)
//return this.returntype; //auskommentiert von Andreas Stadelmeier (a10023)
} }
// ino.end // ino.end
@ -688,7 +684,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
@Override @Override
public Type getType(){ public Type getType(){
//Methode und Block teilen sich einen ReturnType: //Methode und Block teilen sich einen ReturnType:
return this.block.getType(); return this.returntype;
} }
public static Method createEmptyMethod(String withSignature, Class parent){ public static Method createEmptyMethod(String withSignature, Class parent){

View File

@ -1,9 +1,19 @@
package typinferenz.assumptions; package typinferenz.assumptions;
import mycompiler.mytype.Type;
import mycompiler.mystatement.LocalVarDecl; import mycompiler.mystatement.LocalVarDecl;
public class LocalVarAssumption extends Assumption { public class LocalVarAssumption extends Assumption {
private LocalVarDecl localVar;
public LocalVarAssumption(LocalVarDecl localVar){ public LocalVarAssumption(LocalVarDecl localVar){
super(localVar); super(localVar);
this.localVar = localVar;
}
@Override
public Type getAssumedType() {
return this.localVar.getDeclType();
} }
} }

View File

@ -1,5 +1,5 @@
Class DEBUG [Typeinference] Erstellte Assumptions: this: WhileTestMethod Assumptions: Class DEBUG [Typeinference] Erstellte Assumptions: this: WhileTestMethod Assumptions:
[typinferenz.assumptions.MethodAssumption@757828eb, typinferenz.assumptions.MethodAssumption@23c6988d] [typinferenz.assumptions.MethodAssumption@33e8c1e4, typinferenz.assumptions.MethodAssumption@76117a5b]
FieldVar Assumptions: FieldVar Assumptions:
[] []
LocalVar Assumptions: LocalVar Assumptions:
@ -8,19 +8,34 @@ Parameter Assumptions:
[] []
Block DEBUG [Typeinference] Prozessing statement: no type [var] Block DEBUG [Typeinference] Prozessing statement: no type [var]
Block DEBUG [Typeinference] Prozessing statement: WHILE null { [(var = mycompiler.mystatement.StringLiteral@7bec09b0)] Block DEBUG [Typeinference] Prozessing statement: WHILE null { [(var = mycompiler.mystatement.StringLiteral@25cc8345)]
Block DEBUG [Typeinference] Prozessing statement: (var = mycompiler.mystatement.StringLiteral@7bec09b0) Block DEBUG [Typeinference] Prozessing statement: (var = mycompiler.mystatement.StringLiteral@25cc8345)
Block DEBUG [Typeinference] Prozessing statement: void(var: void = mycompiler.mystatement.StringLiteral@7bec09b0) Block DEBUG [Typeinference] Prozessing statement: void(var: TPH C = mycompiler.mystatement.StringLiteral@25cc8345)
Block DEBUG [Typeinference] Prozessing statement: WHILE void { [void(var: void = mycompiler.mystatement.StringLiteral@7bec09b0)] Block DEBUG [Typeinference] Prozessing statement: WHILE void { [void(var: TPH C = mycompiler.mystatement.StringLiteral@25cc8345)]
Block DEBUG [Typeinference] Prozessing statement: TPH C [var] Block DEBUG [Typeinference] Prozessing statement: TPH C [var]
Class DEBUG [Typeinference] Erstellte Constraints: boolean < boolean Class DEBUG [Typeinference] Erstellte Constraints: boolean < boolean
String < void String < TPH C
void < TPH D TPH C < TPH D
void < TPH A void < TPH A
void < TPH B
SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(boolean <. boolean), (String <. void), (void <. TPH D), (void <. TPH A), (void <. TPH B)]] SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(boolean <. boolean), (String <. TPH C), (TPH C <. TPH D), (void <. TPH A)]]
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [] SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH D = String), (TPH C = String), (TPH A = void)]]
SourceFile DEBUG [Typeinference] SourceFile DEBUG [Typeinference]
JavaFiles: JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH D = String), (TPH C = String), (TPH A = void)]
SourceFile DEBUG [Typeinference] class <B>WhileTest extends Object
{
void method()
{
String var;
while(true){
var = "String";
}
}
B WhileTest()
{
}
}