BinaryTest funktioniert
This commit is contained in:
parent
5d0603f423
commit
dd8b4f322e
@ -69,6 +69,10 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
private SourceFile sf;
|
private SourceFile sf;
|
||||||
private IStatement statement = null;
|
private IStatement statement = null;
|
||||||
|
|
||||||
|
private boolean returnParentOfUnary = false;
|
||||||
|
// speichert, ob der Argument RefType ist.
|
||||||
|
private List<Boolean> argList = new LinkedList<>();
|
||||||
|
|
||||||
// private int numMethodCalls = 0;
|
// private int numMethodCalls = 0;
|
||||||
|
|
||||||
// for tests **
|
// 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) {
|
private String getLargerType(String lexpType, String rexpType) {
|
||||||
if (lexpType.equals(Type.getInternalName(String.class))
|
if (lexpType.equals(Type.getInternalName(String.class))
|
||||||
|| rexpType.equals(Type.getInternalName(String.class))) {
|
|| rexpType.equals(Type.getInternalName(String.class))) {
|
||||||
@ -713,6 +713,10 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
String mDesc = "";
|
String mDesc = "";
|
||||||
List<Boolean> argListMethCall = new LinkedList<>();
|
List<Boolean> argListMethCall = new LinkedList<>();
|
||||||
if(methodRefl == null) {
|
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(),
|
MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(),
|
||||||
receiverName, genericsAndBoundsMethod, genericsAndBounds);
|
receiverName, genericsAndBoundsMethod, genericsAndBounds);
|
||||||
mDesc = method.accept(new DescriptorToString(resultSet));
|
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
|
// 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
|
// 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;
|
LocalVar local = (LocalVar) unaryExpr.expr;
|
||||||
mv.visitVarInsn(Opcodes.ASTORE, paramsAndLocals.get(local.name));
|
mv.visitVarInsn(Opcodes.ASTORE, paramsAndLocals.get(local.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(returnParentOfUnary)
|
||||||
|
returnParentOfUnary = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doVisitNegIns(String typeOfUnary) {
|
private void doVisitNegIns(String typeOfUnary) {
|
||||||
@ -914,6 +921,9 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
statement = new ReturnStmt(aReturn.retexpr);
|
statement = new ReturnStmt(aReturn.retexpr);
|
||||||
isBinaryExp = statement.isExprBinary();
|
isBinaryExp = statement.isExprBinary();
|
||||||
|
|
||||||
|
if(aReturn.retexpr instanceof UnaryExpr)
|
||||||
|
returnParentOfUnary = true;
|
||||||
|
|
||||||
aReturn.retexpr.accept(this);
|
aReturn.retexpr.accept(this);
|
||||||
|
|
||||||
if (isBinaryExp) {
|
if (isBinaryExp) {
|
||||||
@ -1173,7 +1183,15 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
public void visit(ArgumentList argumentList) {
|
public void visit(ArgumentList argumentList) {
|
||||||
for (Expression al : argumentList.getArguments()) {
|
for (Expression al : argumentList.getArguments()) {
|
||||||
statement = new ArgumentExpr(al);
|
statement = new ArgumentExpr(al);
|
||||||
|
isBinaryExp = statement.isExprBinary();
|
||||||
al.accept(this);
|
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;
|
statement = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
public class PTGen {
|
|
||||||
m(List<E> list) {
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user