diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index 36cba603f..49e83aae6 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -818,8 +818,12 @@ public class StatementGenerator { } private Expression convert(Java8Parser.LiteralContext literal) { - if(literal.IntegerLiteral() != null || literal.FloatingPointLiteral()!= null){ - Number value = Double.parseDouble(literal.IntegerLiteral().getText()); + if(literal.IntegerLiteral() != null){ + Number value = Integer.parseInt(literal.IntegerLiteral().getText()); + return new Literal(TypePlaceholder.fresh(literal.getStart()), + value, literal.getStart()); + } else if(literal.FloatingPointLiteral()!= null){ + Number value = Double.parseDouble(literal.FloatingPointLiteral().getText()); return new Literal(TypePlaceholder.fresh(literal.getStart()), value, literal.getStart()); }else if(literal.BooleanLiteral() != null){ diff --git a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index 8e0a98b37..ad674ddd6 100644 --- a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -370,12 +370,41 @@ public class TYPEStmt implements StatementVisitor{ //PL 2018-06-23 Sie haben einen Typ. Der muesste hier eingefuegt werden //wie hier fuer double gezeigt. Im Momment auskommentiert, weil zu wenige Literaltypen //funktionieren - //if (literal.value instanceof Double) { - // constraintsSet.addUndConstraint(new Pair(literal.getType(), doublee, PairOperator.EQUALSDOT)); - //} - //else { - // throw new NotImplementedException(); - //} + if (literal.value instanceof Double) { + constraintsSet.addUndConstraint(new Pair(literal.getType(), doublee, PairOperator.EQUALSDOT)); + return; + } + if (literal.value instanceof Double) { + constraintsSet.addUndConstraint(new Pair(literal.getType(), longg, PairOperator.EQUALSDOT)); + return; + } + if (literal.value instanceof Integer) { + constraintsSet.addUndConstraint(new Pair(literal.getType(), integer, PairOperator.EQUALSDOT)); + return; + } + if (literal.value instanceof Short) { + constraintsSet.addUndConstraint(new Pair(literal.getType(),shortt, PairOperator.EQUALSDOT)); + return; + } + if (literal.value instanceof Byte) { + constraintsSet.addUndConstraint(new Pair(literal.getType(),bytee, PairOperator.EQUALSDOT)); + return; + } + if (literal.value instanceof Float) { + constraintsSet.addUndConstraint(new Pair(literal.getType(),floatt, PairOperator.EQUALSDOT)); + return; + } + if (literal.value instanceof String) { + constraintsSet.addUndConstraint(new Pair(literal.getType(),string, PairOperator.EQUALSDOT)); + return; + } + if (literal.value instanceof Boolean) { + constraintsSet.addUndConstraint(new Pair(literal.getType(),bool, PairOperator.EQUALSDOT)); + return; + } + else { + throw new NotImplementedException(); + } } @Override diff --git a/test/bytecode/javFiles/MatrixOP.jav b/test/bytecode/javFiles/MatrixOP.jav index a56fde775..828a270bd 100644 --- a/test/bytecode/javFiles/MatrixOP.jav +++ b/test/bytecode/javFiles/MatrixOP.jav @@ -3,12 +3,12 @@ import java.lang.Integer; //import java.lang.Byte; import java.lang.Boolean; -public class Matrix extends Vector> { +public class MatrixOP extends Vector> { - Matrix () { + MatrixOP () { } - Matrix(vv) { + MatrixOP(vv) { Integer i; i = 0; while(i < vv.size()) { @@ -19,7 +19,7 @@ public class Matrix extends Vector> { } mul = (m1, m2) -> { - var ret = new Matrix(); + var ret = new MatrixOP(); var i = 0; while(i < size()) { var v1 = m1.elementAt(i);