forked from JavaTX/JavaCompilerCore
Bug 77 gefixt
This commit is contained in:
parent
22ca2cbd4a
commit
521a1cbf3b
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user