modified: ../../../src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java

Bei Int-Literal werden imports beruecksichtigt
This commit is contained in:
Martin Plümicke 2018-11-05 12:01:16 +01:00
parent e6387dca6b
commit f0ba7c03b5
2 changed files with 21 additions and 8 deletions

View File

@ -4,6 +4,7 @@ import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
@ -18,6 +19,7 @@ import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class TYPEStmt implements StatementVisitor{
@ -374,24 +376,34 @@ public class TYPEStmt implements StatementVisitor{
constraintsSet.addUndConstraint(new Pair(literal.getType(), doublee, PairOperator.EQUALSDOT));
return;
}
if (literal.value instanceof Double) {
if (literal.value instanceof Long) {
constraintsSet.addUndConstraint(new Pair(literal.getType(), longg, PairOperator.EQUALSDOT));
return;
}
if (literal.value instanceof Integer) {
//constraintsSet.addUndConstraint(new Pair(literal.getType(),integer, PairOperator.EQUALSDOT));
// /*
HashSet<JavaClassName> clNames = info.getAvailableClasses().stream().map(x -> x.getClassName()).collect(Collectors.toCollection(HashSet::new));
Set<Constraint> oderConstraints = new HashSet<>();
Constraint constraint = new Constraint();
constraint.add(new Pair(literal.getType(), integer, PairOperator.EQUALSDOT));
oderConstraints.add(constraint);
constraint = new Constraint();
constraint.add(new Pair(literal.getType(), doublee, PairOperator.EQUALSDOT));
oderConstraints.add(constraint);
constraint = new Constraint();
constraint.add(new Pair(literal.getType(), longg, PairOperator.EQUALSDOT));
oderConstraints.add(constraint);
constraintsSet.addOderConstraint(oderConstraints);
if (clNames.stream().filter(x -> x.toString().equals("java.lang.Double")).findAny().isPresent()) {
constraint = new Constraint();
constraint.add(new Pair(literal.getType(), doublee, PairOperator.EQUALSDOT));
oderConstraints.add(constraint);
}
if (clNames.stream().filter(x -> x.toString().equals("java.lang.Long")).findAny().isPresent()) {
constraint = new Constraint();
constraint.add(new Pair(literal.getType(), longg, PairOperator.EQUALSDOT));
oderConstraints.add(constraint);
}
if (clNames.stream().filter(x -> x.toString().equals("java.lang.Float")).findAny().isPresent()) {
constraint = new Constraint();
constraint.add(new Pair(literal.getType(), floatt, PairOperator.EQUALSDOT));
oderConstraints.add(constraint);
}
constraintsSet.addOderConstraint(oderConstraints);
// */
return;
}

View File

@ -1,5 +1,6 @@
import java.util.Vector;
import java.lang.Integer;
import java.lang.Float;
//import java.lang.Byte;
import java.lang.Boolean;