From 99ce7c1122f51a292fac5e34849a61421e1f76c8 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 28 Feb 2018 16:33:18 +0100 Subject: [PATCH] =?UTF-8?q?<,=20>=20Operatoren=20einf=C3=BChren?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../typeinference/typeAlgo/TYPEStmt.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index e6b82a10..8ed2343c 100644 --- a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -187,6 +187,7 @@ public class TYPEStmt implements StatementVisitor{ private final RefType number = new RefType(ASTFactory.createClass(Number.class).getClassName(), new NullToken()); private final RefType string = new RefType(ASTFactory.createClass(String.class).getClassName(), new NullToken()); + private final RefType bool = new RefType(ASTFactory.createClass(Boolean.class).getClassName(), new NullToken()); @Override public void visit(UnaryExpr unaryExpr) { if(unaryExpr.operation == UnaryExpr.Operation.POSTDECREMENT || @@ -229,7 +230,15 @@ public class TYPEStmt implements StatementVisitor{ numericAdditionOrStringConcatenation.add(stringConcat); } constraintsSet.addOderConstraint(numericAdditionOrStringConcatenation); - }else { + }else if(binary.operation.equals(BinaryExpr.Operator.LESSEQUAL) || + binary.operation.equals(BinaryExpr.Operator.BIGGEREQUAL) || + binary.operation.equals(BinaryExpr.Operator.BIGGERTHAN) || + binary.operation.equals(BinaryExpr.Operator.LESSTHAN)){ + constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT)); + constraintsSet.addUndConstraint(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERDOT)); + //Rückgabetyp ist Boolean + constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.EQUALSDOT)); + }else{ throw new NotImplementedException(); } }