forked from JavaTX/JavaCompilerCore
erge branch 'bigRefactoring' into sat
This commit is contained in:
commit
dfd6a1f532
@ -205,6 +205,7 @@ public class TYPEStmt implements StatementVisitor{
|
||||
|
||||
@Override
|
||||
public void visit(BinaryExpr binary) {
|
||||
|
||||
if(binary.operation.equals(BinaryExpr.Operator.DIV) ||
|
||||
binary.operation.equals(BinaryExpr.Operator.MUL)||
|
||||
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
|
||||
numeric.add(new Pair(binary.lexpr.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));
|
||||
numeric.add(new Pair(binary.lexpr.getType(), binary.getType(), PairOperator.SMALLERDOT));
|
||||
/*
|
||||
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.add(new Pair(binary.getType(), number, PairOperator.SMALLERDOT));
|
||||
numericAdditionOrStringConcatenation.add(numeric);
|
||||
if(binary.operation.equals(BinaryExpr.Operator.ADD)) {
|
||||
//Dann kann der Ausdruck auch das aneinanderfügen zweier Strings sein: ("a" + "b") oder (1 + 2)
|
||||
|
9
test/javFiles/AddLong.jav
Normal file
9
test/javFiles/AddLong.jav
Normal 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;
|
||||
}
|
||||
}
|
@ -72,6 +72,10 @@ public class JavaTXCompilerTest {
|
||||
public void expressions() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Expressions.jav"));
|
||||
}
|
||||
@Test
|
||||
public void addLong() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"AddLong.jav"));
|
||||
}
|
||||
|
||||
private static class TestResultSet{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user