forked from JavaTX/JavaCompilerCore
Box test
This commit is contained in:
parent
c40fbd9399
commit
4307371dee
@ -873,6 +873,7 @@ public class Codegen {
|
|||||||
mv.visitLabel(start);
|
mv.visitLabel(start);
|
||||||
if (_for.termination() != null)
|
if (_for.termination() != null)
|
||||||
generate(state, _for.termination());
|
generate(state, _for.termination());
|
||||||
|
else mv.visitInsn(ICONST_1);
|
||||||
mv.visitJumpInsn(IFEQ, end);
|
mv.visitJumpInsn(IFEQ, end);
|
||||||
generate(state, _for.body());
|
generate(state, _for.body());
|
||||||
if (_for.increment() != null) {
|
if (_for.increment() != null) {
|
||||||
@ -913,7 +914,7 @@ public class Codegen {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TargetReturn ret: {
|
case TargetReturn ret: {
|
||||||
if (ret.expression() != null) {
|
if (ret.expression() != null && state.returnType != null) {
|
||||||
generate(state, ret.expression());
|
generate(state, ret.expression());
|
||||||
convertTo(state, ret.expression().type(), state.returnType);
|
convertTo(state, ret.expression().type(), state.returnType);
|
||||||
boxPrimitive(state, state.returnType);
|
boxPrimitive(state, state.returnType);
|
||||||
|
@ -37,7 +37,7 @@ public class TestCodegen {
|
|||||||
|
|
||||||
public static Map<String, Class<?>> generateClassFiles(String filename, ByteArrayClassLoader classLoader) throws IOException, ClassNotFoundException {
|
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 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 resultSet = compiler.typeInference();
|
||||||
var sourceFile = compiler.sourceFiles.get(file);
|
var sourceFile = compiler.sourceFiles.get(file);
|
||||||
var converter = new ASTToTargetAST(resultSet, sourceFile, classLoader);
|
var converter = new ASTToTargetAST(resultSet, sourceFile, classLoader);
|
||||||
|
@ -8,6 +8,7 @@ import java.lang.reflect.Array;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.TypeVariable;
|
import java.lang.reflect.TypeVariable;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
class Box<A> {
|
|
||||||
void m(A a) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
class B { }
|
class B { }
|
||||||
class Box_Main extends B {
|
class Box_Main extends B {
|
||||||
m(b) {
|
m(b) {
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
class Box<A> {
|
||||||
|
void m(A a) { }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user