Bug 77 gefixt

This commit is contained in:
Fayez Abu Alia 2018-05-08 17:42:58 +02:00
parent 22ca2cbd4a
commit 521a1cbf3b
3 changed files with 16 additions and 4 deletions

View File

@ -772,7 +772,19 @@ public class BytecodeGenMethod implements StatementVisitor {
@Override
public void visit(Return aReturn) {
if(aReturn.retexpr instanceof BinaryExpr)
isBinaryExp = true;
aReturn.retexpr.accept(this);
if (isBinaryExp) {
BinaryExpr binary = (BinaryExpr) aReturn.retexpr;
String lexpType = getResolvedType(binary.lexpr.getType());
String rexpType = getResolvedType(binary.rexpr.getType());
getValueOfIns(getLargerType(lexpType, rexpType));
isBinaryExp = false;
}
mv.visitInsn(Opcodes.ARETURN);
}

View File

@ -29,7 +29,7 @@ public class OpTest {
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/examples/";
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Op");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -9,8 +9,8 @@ import java.lang.Byte;
public class Op {
m(a,b) {
var c = a+b;
return c;
Integer m(Integer a, Integer b) {
//var c = a+b;
return a+b;
}
}