erge branch 'bigRefactoring' into sat

This commit is contained in:
JanUlrich 2018-03-07 23:04:16 +01:00
commit dfd6a1f532
3 changed files with 20 additions and 3 deletions

View File

@ -205,6 +205,7 @@ public class TYPEStmt implements StatementVisitor{
@Override @Override
public void visit(BinaryExpr binary) { public void visit(BinaryExpr binary) {
if(binary.operation.equals(BinaryExpr.Operator.DIV) || if(binary.operation.equals(BinaryExpr.Operator.DIV) ||
binary.operation.equals(BinaryExpr.Operator.MUL)|| binary.operation.equals(BinaryExpr.Operator.MUL)||
binary.operation.equals(BinaryExpr.Operator.MOD)|| binary.operation.equals(BinaryExpr.Operator.MOD)||
@ -216,9 +217,12 @@ public class TYPEStmt implements StatementVisitor{
//Expression muss zu Numeric Convertierbar sein. also von Numeric erben //Expression muss zu Numeric Convertierbar sein. also von Numeric erben
numeric.add(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT)); numeric.add(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT));
numeric.add(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERDOT)); numeric.add(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERDOT));
//The type of a multiplicative expression is the promoted type of its operands. /*
numeric.add(new Pair(binary.rexpr.getType(), binary.getType(), PairOperator.SMALLERDOT)); In Java passiert bei den binären Operatoren eine sogenannte Type Promotion:
numeric.add(new Pair(binary.lexpr.getType(), binary.getType(), PairOperator.SMALLERDOT)); 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.add(new Pair(binary.getType(), number, PairOperator.SMALLERDOT));
numericAdditionOrStringConcatenation.add(numeric); numericAdditionOrStringConcatenation.add(numeric);
if(binary.operation.equals(BinaryExpr.Operator.ADD)) { if(binary.operation.equals(BinaryExpr.Operator.ADD)) {
//Dann kann der Ausdruck auch das aneinanderfügen zweier Strings sein: ("a" + "b") oder (1 + 2) //Dann kann der Ausdruck auch das aneinanderfügen zweier Strings sein: ("a" + "b") oder (1 + 2)

View File

@ -0,0 +1,9 @@
import java.lang.Integer;
import java.lang.Long;
public class AddLong{
add(Integer a, Long b) {
Long c = a+b;
return c;
}
}

View File

@ -72,6 +72,10 @@ public class JavaTXCompilerTest {
public void expressions() throws IOException, ClassNotFoundException { public void expressions() throws IOException, ClassNotFoundException {
execute(new File(rootDirectory+"Expressions.jav")); execute(new File(rootDirectory+"Expressions.jav"));
} }
@Test
public void addLong() throws IOException, ClassNotFoundException {
execute(new File(rootDirectory+"AddLong.jav"));
}
private static class TestResultSet{ private static class TestResultSet{