forked from JavaTX/JavaCompilerCore
Fehler behoben
This commit is contained in:
parent
b9dde7b015
commit
63a10f4775
@ -128,6 +128,7 @@ public class FieldDeclaration extends Field{
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ConstraintsSet TYPE(TypeAssumptions publicAssumptions) {
|
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();
|
ConstraintsSet ret = new ConstraintsSet();
|
||||||
TypeAssumptions localAssumptions = publicAssumptions.clone();
|
TypeAssumptions localAssumptions = publicAssumptions.clone();
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -389,7 +389,7 @@ public class IfStmt extends Statement
|
|||||||
ret.add(this.else_block.TYPEStmt(assumptions));
|
ret.add(this.else_block.TYPEStmt(assumptions));
|
||||||
if(!(else_block.getType() instanceof Void))ret.add(new SingleConstraint(else_block.getType(),this.getType()));
|
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))ret.add(new SingleConstraint(then_block.getType(),this.getType()));
|
||||||
if(then_block.getType() instanceof Void &&
|
if(then_block.getType() instanceof Void &&
|
||||||
(else_block == null || else_block.getType() instanceof Void))this.setType(new Void(this.getOffset()));
|
(else_block == null || else_block.getType() instanceof Void))this.setType(new Void(this.getOffset()));
|
||||||
|
@ -182,7 +182,7 @@ public class WhileStmt extends Statement
|
|||||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
||||||
ConstraintsSet ret = new ConstraintsSet();
|
ConstraintsSet ret = new ConstraintsSet();
|
||||||
ret.add(expr.TYPEExpr(assumptions));
|
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(exprMustBeBool);
|
||||||
ret.add(this.loop_block.TYPEStmt(assumptions));
|
ret.add(this.loop_block.TYPEStmt(assumptions));
|
||||||
this.setType(loop_block.getType());
|
this.setType(loop_block.getType());
|
||||||
|
14
test/plugindevelopment/TypeInsertTests/LambdaTest19.jav
Normal file
14
test/plugindevelopment/TypeInsertTests/LambdaTest19.jav
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
class TestIfStmt {
|
||||||
|
|
||||||
|
methode(){
|
||||||
|
var;
|
||||||
|
if(true){
|
||||||
|
var=this;
|
||||||
|
}else{
|
||||||
|
var=this;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
test/plugindevelopment/TypeInsertTests/LambdaTest19.java
Normal file
16
test/plugindevelopment/TypeInsertTests/LambdaTest19.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
11
test/plugindevelopment/TypeInsertTests/LambdaTest20.jav
Normal file
11
test/plugindevelopment/TypeInsertTests/LambdaTest20.jav
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
class WhileTest{
|
||||||
|
|
||||||
|
var;
|
||||||
|
public method(){
|
||||||
|
while(true){
|
||||||
|
var = "String";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
test/plugindevelopment/TypeInsertTests/LambdaTest20.java
Normal file
16
test/plugindevelopment/TypeInsertTests/LambdaTest20.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
9
test/plugindevelopment/TypeInsertTests/LambdaTest21.jav
Normal file
9
test/plugindevelopment/TypeInsertTests/LambdaTest21.jav
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
class Test{
|
||||||
|
|
||||||
|
void methode(){
|
||||||
|
var;
|
||||||
|
var.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -65,8 +65,8 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
|
|||||||
System.out.println("Setze " + tip + " ein:");
|
System.out.println("Setze " + tip + " ein:");
|
||||||
inferedSource = point.insertType(tip, TypeInsertTester.getFileContent(rootDirectory + sourceFileToInfere));
|
inferedSource = point.insertType(tip, TypeInsertTester.getFileContent(rootDirectory + sourceFileToInfere));
|
||||||
System.out.println(inferedSource);
|
System.out.println(inferedSource);
|
||||||
|
gesamterSrc += inferedSource;
|
||||||
}
|
}
|
||||||
gesamterSrc += inferedSource;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException | yyException e) {
|
} catch (IOException | yyException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user