forked from JavaTX/JavaCompilerCore
== Operator anfügen
This commit is contained in:
parent
1e037a0019
commit
c72204428f
@ -583,7 +583,10 @@ public class StatementGenerator {
|
||||
if(expression.equalityExpression() == null){
|
||||
return convert(expression.relationalExpression());
|
||||
}else{
|
||||
throw new NotImplementedException();
|
||||
String operator = expression.getChild(1).getText();
|
||||
Expression leftSide = convert(expression.equalityExpression());
|
||||
Expression rightSide = convert(expression.relationalExpression());
|
||||
return new BinaryExpr(convertBinaryOperator(operator), TypePlaceholder.fresh(expression.getStart()), leftSide, rightSide, expression.getStart());
|
||||
}
|
||||
}
|
||||
|
||||
@ -619,8 +622,12 @@ public class StatementGenerator {
|
||||
return BinaryExpr.Operator.BIGGERTHAN;
|
||||
}else if(operator.equals(">=")) {
|
||||
return BinaryExpr.Operator.BIGGEREQUAL;
|
||||
} else if(operator.equals("<=")) {
|
||||
return BinaryExpr.Operator.LESSEQUAL;
|
||||
} else if(operator.equals("<=")) {
|
||||
return BinaryExpr.Operator.LESSEQUAL;
|
||||
} else if(operator.equals("==")) {
|
||||
return BinaryExpr.Operator.EQUAL;
|
||||
} else if(operator.equals("!=")) {
|
||||
return BinaryExpr.Operator.NOTEQUAL;
|
||||
} else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -23,7 +23,9 @@ public class BinaryExpr extends Expression
|
||||
LESSTHAN, // <
|
||||
BIGGERTHAN, // >
|
||||
LESSEQUAL, // <=
|
||||
BIGGEREQUAL // >=
|
||||
BIGGEREQUAL, // >=
|
||||
EQUAL, // ==
|
||||
NOTEQUAL // !=
|
||||
}
|
||||
|
||||
public final Operator operation;
|
||||
|
@ -223,7 +223,8 @@ public class TYPEStmt implements StatementVisitor{
|
||||
if(binary.operation.equals(BinaryExpr.Operator.DIV) ||
|
||||
binary.operation.equals(BinaryExpr.Operator.MUL)||
|
||||
binary.operation.equals(BinaryExpr.Operator.MOD)||
|
||||
binary.operation.equals(BinaryExpr.Operator.ADD)){
|
||||
binary.operation.equals(BinaryExpr.Operator.ADD)||
|
||||
binary.operation.equals(BinaryExpr.Operator.SUB)){
|
||||
Set<Constraint<Pair>> numericAdditionOrStringConcatenation = new HashSet<>();
|
||||
|
||||
//Zuerst der Fall für Numerische AusdrücPairOpnumericeratorke, das sind Mul, Mod und Div immer:
|
||||
@ -303,7 +304,7 @@ public class TYPEStmt implements StatementVisitor{
|
||||
}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)){
|
||||
binary.operation.equals(BinaryExpr.Operator.LESSTHAN)) {
|
||||
/* //eingefuegt PL 2018-05-24
|
||||
Set<Constraint<Pair>> numericRelationConcatenation = new HashSet<>();
|
||||
Constraint<Pair> numeric = new Constraint<>();
|
||||
@ -352,6 +353,12 @@ public class TYPEStmt implements StatementVisitor{
|
||||
//constraintsSet.addUndConstraint(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERDOT));
|
||||
//Rückgabetyp ist Boolean
|
||||
//constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.EQUALSDOT));
|
||||
}else if(binary.operation.equals(BinaryExpr.Operator.EQUAL) || binary.operation.equals(BinaryExpr.Operator.NOTEQUAL)){
|
||||
/*Auszug aus https://docs.oracle.com/javase/specs/jls/se9/html/jls-15.html#jls-15.21
|
||||
The equality operators may be used to compare two operands that are convertible (§5.1.8) to numeric type, or two operands of type boolean or Boolean, or two operands that are each of either reference type or the null type. All other cases result in a compile-time error.
|
||||
*/
|
||||
//Der Equals Operator geht mit fast allen Typen, daher werden hier keine Constraints gesetzt
|
||||
constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.SMALLERDOT));
|
||||
}else{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user