Fehler behoben

This commit is contained in:
JanUlrich 2014-08-07 14:26:02 +02:00
parent b9dde7b015
commit 63a10f4775
10 changed files with 219 additions and 152 deletions

View File

@ -128,6 +128,7 @@ public class FieldDeclaration extends Field{
}
@Override
public ConstraintsSet TYPE(TypeAssumptions publicAssumptions) {
if(this.wert == null)throw new TypeinferenceException("Typlose Felder müssen mit Wert initialisiert werden", this);
ConstraintsSet ret = new ConstraintsSet();
TypeAssumptions localAssumptions = publicAssumptions.clone();

File diff suppressed because it is too large Load Diff

View File

@ -389,7 +389,7 @@ public class IfStmt extends Statement
ret.add(this.else_block.TYPEStmt(assumptions));
if(!(else_block.getType() instanceof Void))ret.add(new SingleConstraint(else_block.getType(),this.getType()));
}
ret.add(new SingleConstraint(expr.getType(),new RefType("boolean",0))); //(expressionDesIfStmt)<.boolean
ret.add(new SingleConstraint(expr.getType(),assumptions.getTypeFor(new RefType("Boolean",0)))); //(expressionDesIfStmt)<.boolean
if(!(then_block.getType() instanceof Void))ret.add(new SingleConstraint(then_block.getType(),this.getType()));
if(then_block.getType() instanceof Void &&
(else_block == null || else_block.getType() instanceof Void))this.setType(new Void(this.getOffset()));

View File

@ -182,7 +182,7 @@ public class WhileStmt extends Statement
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet();
ret.add(expr.TYPEExpr(assumptions));
SingleConstraint exprMustBeBool = new SingleConstraint(expr.getType(), new RefType("boolean", 0)); // while(expr){}; expr <. boolean
SingleConstraint exprMustBeBool = new SingleConstraint(expr.getType(), assumptions.getTypeFor(new RefType("Boolean", 0))); // while(expr){}; expr <. boolean
ret.add(exprMustBeBool);
ret.add(this.loop_block.TYPEStmt(assumptions));
this.setType(loop_block.getType());

View File

@ -0,0 +1,14 @@
class TestIfStmt {
methode(){
var;
if(true){
var=this;
}else{
var=this;
}
return 1;
}
}

View File

@ -0,0 +1,16 @@
package plugindevelopment.TypeInsertTests;
import java.util.Vector;
import org.junit.Test;
public class LambdaTest19 {
private static final String TEST_FILE = "LambdaTest19.jav";
@Test
public void run(){
Vector<String> mustContain = new Vector<String>();
mustContain.add("TestIfStmt var");
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
}
}

View File

@ -0,0 +1,11 @@
class WhileTest{
var;
public method(){
while(true){
var = "String";
}
}
}

View File

@ -0,0 +1,16 @@
package plugindevelopment.TypeInsertTests;
import java.util.Vector;
import org.junit.Test;
public class LambdaTest20 {
private static final String TEST_FILE = "LambdaTest21.jav";
@Test
public void run(){
Vector<String> mustContain = new Vector<String>();
//mustContain.add("TestIfStmt var");
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
}
}

View File

@ -0,0 +1,9 @@
class Test{
void methode(){
var;
var.toString();
}
}

View File

@ -65,8 +65,8 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
System.out.println("Setze " + tip + " ein:");
inferedSource = point.insertType(tip, TypeInsertTester.getFileContent(rootDirectory + sourceFileToInfere));
System.out.println(inferedSource);
gesamterSrc += inferedSource;
}
gesamterSrc += inferedSource;
}
}
} catch (IOException | yyException e) {