This commit is contained in:
Victorious3 2022-11-13 13:47:24 +01:00
parent c40fbd9399
commit 4307371dee
5 changed files with 7 additions and 6 deletions

View File

@ -873,6 +873,7 @@ public class Codegen {
mv.visitLabel(start);
if (_for.termination() != null)
generate(state, _for.termination());
else mv.visitInsn(ICONST_1);
mv.visitJumpInsn(IFEQ, end);
generate(state, _for.body());
if (_for.increment() != null) {
@ -913,7 +914,7 @@ public class Codegen {
break;
}
case TargetReturn ret: {
if (ret.expression() != null) {
if (ret.expression() != null && state.returnType != null) {
generate(state, ret.expression());
convertTo(state, ret.expression().type(), state.returnType);
boxPrimitive(state, state.returnType);

View File

@ -37,7 +37,7 @@ public class TestCodegen {
public static Map<String, Class<?>> generateClassFiles(String filename, ByteArrayClassLoader classLoader) throws IOException, ClassNotFoundException {
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/", filename).toFile();
var compiler = new JavaTXCompiler(file);
var compiler = new JavaTXCompiler(List.of(file), List.of(file.getParentFile()));
var resultSet = compiler.typeInference();
var sourceFile = compiler.sourceFiles.get(file);
var converter = new ASTToTargetAST(resultSet, sourceFile, classLoader);

View File

@ -8,6 +8,7 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Vector;

View File

@ -1,7 +1,3 @@
class Box<A> {
void m(A a) { }
}
class B { }
class Box_Main extends B {
m(b) {

View File

@ -0,0 +1,3 @@
class Box<A> {
void m(A a) { }
}