diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java b/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java index 32570541..1719d64d 100644 --- a/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java +++ b/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java @@ -69,6 +69,10 @@ public class BytecodeGenMethod implements StatementVisitor { private SourceFile sf; private IStatement statement = null; + private boolean returnParentOfUnary = false; + // speichert, ob der Argument RefType ist. + private List argList = new LinkedList<>(); + // private int numMethodCalls = 0; // for tests ** @@ -273,10 +277,6 @@ public class BytecodeGenMethod implements StatementVisitor { } - /* - * Diese Methode wird nicht mehr gebraucht, da es jetzt nicht möglich ist, dass - * solche Fälle: Integer -> Integer (OP) Short ,... usw, nicht vorkommen! - */ private String getLargerType(String lexpType, String rexpType) { if (lexpType.equals(Type.getInternalName(String.class)) || rexpType.equals(Type.getInternalName(String.class))) { @@ -713,6 +713,10 @@ public class BytecodeGenMethod implements StatementVisitor { String mDesc = ""; List argListMethCall = new LinkedList<>(); if(methodRefl == null) { + // Alle Argumente sind nicht Primitiv + for(Expression arg : methodCall.arglist.getArguments()) { + argList.add(true); + } MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(), receiverName, genericsAndBoundsMethod, genericsAndBounds); mDesc = method.accept(new DescriptorToString(resultSet)); @@ -864,10 +868,13 @@ public class BytecodeGenMethod implements StatementVisitor { // Für Byte und Short muss noch einen Cast geben i2b, i2s // das wird später gemacht, da bytecode für cast noch nicht erzeugt wird - if (isIncOrDec && (unaryExpr.expr instanceof LocalVar)) { + if (isIncOrDec && (unaryExpr.expr instanceof LocalVar) && !returnParentOfUnary) { LocalVar local = (LocalVar) unaryExpr.expr; mv.visitVarInsn(Opcodes.ASTORE, paramsAndLocals.get(local.name)); } + + if(returnParentOfUnary) + returnParentOfUnary = false; } private void doVisitNegIns(String typeOfUnary) { @@ -913,7 +920,10 @@ public class BytecodeGenMethod implements StatementVisitor { public void visit(Return aReturn) { statement = new ReturnStmt(aReturn.retexpr); isBinaryExp = statement.isExprBinary(); - + + if(aReturn.retexpr instanceof UnaryExpr) + returnParentOfUnary = true; + aReturn.retexpr.accept(this); if (isBinaryExp) { @@ -1173,7 +1183,15 @@ public class BytecodeGenMethod implements StatementVisitor { public void visit(ArgumentList argumentList) { for (Expression al : argumentList.getArguments()) { statement = new ArgumentExpr(al); + isBinaryExp = statement.isExprBinary(); al.accept(this); + //TODO: teste, ob man das für unary braucht + if (isBinaryExp) { + BinaryExpr binary = (BinaryExpr) al; + String binaryType = getResolvedType(binary.getType()); + doBoxing(binaryType); + isBinaryExp = false; + } statement = null; } } diff --git a/test/bytecode/javFiles/PTGen.jav b/test/bytecode/javFiles/PTGen.jav deleted file mode 100644 index f08bdc83..00000000 --- a/test/bytecode/javFiles/PTGen.jav +++ /dev/null @@ -1,5 +0,0 @@ -public class PTGen { - m(List list) { - return list; - } -} \ No newline at end of file