forked from JavaTX/JavaCompilerCore
modified: TYPEStmt.java
Bei der Addition + Abfragen eingefuegt, ob die Subtypen von Number jeweils import sind. Nur dann werden Annahmen erstellt. modified: ../../../../../test/bytecode/javFiles/Matrix.jav modified: ../../../../../test/bytecode/javFiles/OL.jav
This commit is contained in:
parent
2a5c727400
commit
fd64b84072
@ -223,50 +223,75 @@ public class TYPEStmt implements StatementVisitor{
|
||||
//Zuerst der Fall für Numerische AusdrücPairOpnumericeratorke, das sind Mul, Mod und Div immer:
|
||||
//see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
|
||||
//Expression muss zu Numeric Convertierbar sein. also von Numeric erben
|
||||
Constraint<Pair> numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), longg, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), floatt, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), doublee, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
Constraint<Pair> numeric;
|
||||
//PL eingefuegt 2018-07-17
|
||||
if (info.getAvailableClasses().stream().map(x -> x.getClassName()).collect(Collectors.toCollection(HashSet::new)).contains(bytee.getName())) {
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
}
|
||||
//PL eingefuegt 2018-07-17
|
||||
if (info.getAvailableClasses().stream().map(x -> x.getClassName()).collect(Collectors.toCollection(HashSet::new)).contains(shortt.getName())) {
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
}
|
||||
//PL eingefuegt 2018-07-17
|
||||
if (info.getAvailableClasses().stream().map(x -> x.getClassName()).collect(Collectors.toCollection(HashSet::new)).contains(integer.getName())) {
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
}
|
||||
//PL eingefuegt 2018-07-17
|
||||
if (info.getAvailableClasses().stream().map(x -> x.getClassName()).collect(Collectors.toCollection(HashSet::new)).contains(longg.getName())) {
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), longg, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
}
|
||||
//PL eingefuegt 2018-07-17
|
||||
if (info.getAvailableClasses().stream().map(x -> x.getClassName()).collect(Collectors.toCollection(HashSet::new)).contains(floatt.getName())) {
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), floatt, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
}
|
||||
//PL eingefuegt 2018-07-17
|
||||
if (info.getAvailableClasses().stream().map(x -> x.getClassName()).collect(Collectors.toCollection(HashSet::new)).contains(doublee.getName())) {
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||
numeric.add(new Pair(binary.getType(), doublee, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
}
|
||||
/* PL auskommentiert Anfang 2018-07-17
|
||||
/*
|
||||
In Java passiert bei den binären Operatoren eine sogenannte Type Promotion:
|
||||
https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.6.2
|
||||
Das bedeutet, dass Java die Typen je nach belieben castet, so lange sie nur von Number erben
|
||||
*/
|
||||
|
||||
numeric = new Constraint<>();
|
||||
numeric.add(new Pair(binary.getType(), number, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
* PL auskommentiert Ende 2018-07-17 */
|
||||
|
||||
if(binary.operation.equals(BinaryExpr.Operator.ADD)) {
|
||||
//Dann kann der Ausdruck auch das aneinanderfügen zweier Strings sein: ("a" + "b") oder (1 + 2)
|
||||
Constraint<Pair> stringConcat = new Constraint<>();
|
||||
stringConcat.add(new Pair(binary.lexpr.getType(), string, PairOperator.EQUALSDOT));
|
||||
stringConcat.add(new Pair(binary.rexpr.getType(), string, PairOperator.EQUALSDOT));
|
||||
stringConcat.add(new Pair(binary.getType(), string, PairOperator.EQUALSDOT));
|
||||
numericAdditionOrStringConcatenation.add(stringConcat);
|
||||
if (info.getAvailableClasses().stream().map(x -> x.getClassName()).collect(Collectors.toCollection(HashSet::new)).contains(string.getName())) {
|
||||
Constraint<Pair> stringConcat = new Constraint<>();
|
||||
stringConcat.add(new Pair(binary.lexpr.getType(), string, PairOperator.EQUALSDOT));
|
||||
stringConcat.add(new Pair(binary.rexpr.getType(), string, PairOperator.EQUALSDOT));
|
||||
stringConcat.add(new Pair(binary.getType(), string, PairOperator.EQUALSDOT));
|
||||
numericAdditionOrStringConcatenation.add(stringConcat);
|
||||
}
|
||||
}
|
||||
constraintsSet.addOderConstraint(numericAdditionOrStringConcatenation);
|
||||
}else if(binary.operation.equals(BinaryExpr.Operator.LESSEQUAL) ||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Byte;
|
||||
import java.lang.Boolean;
|
||||
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
@ -8,8 +9,8 @@ public class Matrix extends Vector<Vector<Integer>> {
|
||||
}
|
||||
|
||||
Matrix(vv) {
|
||||
Integer i;
|
||||
i = 0;
|
||||
//Integer i;
|
||||
var i = 0;
|
||||
while(i < vv.size()) {
|
||||
// Boolean a = this.add(vv.elementAt(i));
|
||||
this.add(vv.elementAt(i));
|
||||
|
@ -2,9 +2,9 @@ import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
|
||||
|
||||
class OL {
|
||||
class OL {
|
||||
|
||||
m(java.lang.Double x) { return x + x; }
|
||||
m(java.lang.Integer x) { return x + x; }
|
||||
|
||||
//m(x) { return x || x; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user