forked from JavaTX/JavaCompilerCore
modified: ../../../src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java
Bei Int-Literal werden imports beruecksichtigt
This commit is contained in:
parent
e6387dca6b
commit
f0ba7c03b5
@ -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,23 +376,33 @@ 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);
|
||||
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;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Float;
|
||||
//import java.lang.Byte;
|
||||
import java.lang.Boolean;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user