forked from JavaTX/JavaCompilerCore
trying to get more jav files working
This commit is contained in:
parent
a6558ae7b5
commit
427e568ff8
BIN
JavaTXcompiler-1.0-jar-with-dependencies.jar
Normal file
BIN
JavaTXcompiler-1.0-jar-with-dependencies.jar
Normal file
Binary file not shown.
@ -9,6 +9,8 @@ import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
|
||||
import java.lang.Integer;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"})
|
||||
public class Java17Lexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.11.1", RuntimeMetaData.VERSION); }
|
||||
|
@ -3,15 +3,10 @@ package de.dhbwstuttgart.syntaxtree;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.lang.String;
|
||||
import java.lang.Object;
|
||||
import java.lang.Boolean;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
|
||||
/**
|
||||
* Entspricht einem GenericTypeVar, jedoch mit Bounds
|
||||
@ -28,32 +23,30 @@ public class GenericTypeVar extends SyntaxTreeNode
|
||||
/**
|
||||
* Hier sind die Bounds in Form von Type-Objekten abgespeichert
|
||||
*/
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> bounds=new ArrayList<RefTypeOrTPHOrWildcardOrGeneric>();
|
||||
List<? extends RefTypeOrTPHOrWildcardOrGeneric> bounds=new ArrayList<RefTypeOrTPHOrWildcardOrGeneric>();
|
||||
private Token endOffset;
|
||||
private String name;
|
||||
|
||||
public GenericTypeVar(s, bounds, offset, endOffset)
|
||||
public GenericTypeVar(String s, List<? extends RefTypeOrTPHOrWildcardOrGeneric> bounds, Token offset, Token endOffset)
|
||||
{
|
||||
super(offset);
|
||||
name = s;
|
||||
if(bounds != null) {
|
||||
for (RefTypeOrTPHOrWildcardOrGeneric t : bounds) {
|
||||
//if(t!=null)this.extendVars.add(t);
|
||||
}
|
||||
if(bounds != null)for(RefTypeOrTPHOrWildcardOrGeneric t : bounds){
|
||||
//if(t!=null)this.extendVars.add(t);
|
||||
}
|
||||
//this.genericTypeVar = new RefType(s,offset);
|
||||
this.bounds = bounds;
|
||||
this.endOffset = endOffset;
|
||||
}
|
||||
|
||||
public getBounds()
|
||||
public List<? extends RefTypeOrTPHOrWildcardOrGeneric> getBounds()
|
||||
{
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "BoGTV " + this.name + " " + this.bounds.toString();
|
||||
return "BoGTV " + this.name + " " + this.bounds;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
@ -65,11 +58,12 @@ public class GenericTypeVar extends SyntaxTreeNode
|
||||
return name.getParentClass();
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void accept(ASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
@ -77,6 +71,7 @@ public class GenericTypeVar extends SyntaxTreeNode
|
||||
return bounds.equals(that.bounds) && name.equals(that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(bounds, name);
|
||||
}
|
@ -13,6 +13,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
@ -21,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
|
@ -8,16 +8,18 @@ import de.dhbwstuttgart.syntaxtree.TypeScope;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.typeinference.constraints.GenericsResolver;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.Assumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.FunNClass;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import java.util.Optional;
|
||||
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
import java.lang.Integer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
|
||||
public class MethodAssumption extends Assumption{
|
||||
private ClassOrInterface receiver;
|
||||
@ -25,15 +27,12 @@ public class MethodAssumption extends Assumption{
|
||||
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params;
|
||||
private final Boolean isInherited;
|
||||
|
||||
public MethodAssumption(ClassOrInterface receiver, RefTypeOrTPHOrWildcardOrGeneric retType,
|
||||
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params, TypeScope scope, Boolean isInherited){
|
||||
|
||||
public MethodAssumption(receiver, retType, params, scope, isInherited){
|
||||
super(scope);
|
||||
this.receiver = receiver;
|
||||
this.retType = retType;
|
||||
this.params = params;
|
||||
this.isInherited = isInherited;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -43,26 +42,27 @@ public class MethodAssumption extends Assumption{
|
||||
}
|
||||
*/
|
||||
|
||||
public ClassOrInterface getReceiver(){
|
||||
public getReceiver(){
|
||||
return receiver;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
|
||||
public getReturnType() {
|
||||
return retType;
|
||||
}
|
||||
|
||||
public List<? extends RefTypeOrTPHOrWildcardOrGeneric> getArgTypes(){
|
||||
public getArgTypes(){
|
||||
return params;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReturnType(GenericsResolver resolver) {
|
||||
public getReturnType(resolver) {
|
||||
return resolver.resolve(retType);
|
||||
}
|
||||
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgTypes(GenericsResolver resolver) {
|
||||
public getArgTypes(resolver) {
|
||||
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> ret = new ArrayList<>();
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric param : params){
|
||||
|
||||
for(param : this.params){
|
||||
param = resolver.resolve(param);
|
||||
ret.add(param);
|
||||
}
|
||||
@ -75,11 +75,11 @@ public class MethodAssumption extends Assumption{
|
||||
* @param resolver
|
||||
* @return
|
||||
*/
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReceiverType(GenericsResolver resolver) {
|
||||
|
||||
public getReceiverType(resolver) {
|
||||
|
||||
if (receiver == null) return null;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
for(GenericTypeVar gtv : receiver.getGenerics()){
|
||||
for(gtv : receiver.getGenerics()){
|
||||
//Die Generics werden alle zu TPHs umgewandelt.
|
||||
params.add(resolver.resolve(new GenericRefType(gtv.getName(), new NullToken())));
|
||||
}
|
||||
@ -93,7 +93,7 @@ public class MethodAssumption extends Assumption{
|
||||
return receiverType;
|
||||
}
|
||||
|
||||
public Boolean isInherited() {
|
||||
public isInherited() {
|
||||
return isInherited;
|
||||
}
|
||||
}
|
2
makefile
2
makefile
@ -1,7 +1,7 @@
|
||||
JFLAGS = -g:none -implicit:none
|
||||
JC = javac
|
||||
|
||||
JTX = JavaTXcompiler-0.9-jar-with-dependencies.jar
|
||||
JTX = JavaTXcompiler-1.0-jar-with-dependencies.jar
|
||||
|
||||
SRCDIR = javatx-src/main/java
|
||||
DESTDIR = out
|
||||
|
@ -294,8 +294,9 @@ public class SyntaxTreeGenerator {
|
||||
member = (MemberdeclContext) classBody;
|
||||
Integer membermodifiers = 0;
|
||||
for (ModifierContext mod : member.modifier()) {
|
||||
String text = mod.getText();
|
||||
membermodifiers += allmodifiers.get(text);
|
||||
if (mod.classOrInterfaceModifier() != null && mod.classOrInterfaceModifier().annotation() != null)
|
||||
continue; // TODO don't eat annotations
|
||||
membermodifiers += allmodifiers.get(mod.getText());
|
||||
}
|
||||
switch (member.memberDeclaration()) {
|
||||
case MemberclassorinterfaceContext memberclsoif: {
|
||||
|
@ -2,6 +2,7 @@ package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.IdentifierContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.TypeArgumentsContext;
|
||||
@ -68,7 +69,7 @@ public class TypeGenerator {
|
||||
case "double":
|
||||
return new RefType(ASTFactory.createClass(Double.class).getClassName(), typeContext.getStart());
|
||||
default:
|
||||
throw new NotImplementedException("only primitive types boolean, int and double are supported");
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
} else if (!typeContext.LBRACK().isEmpty()) { // ArrayType über eckige Klammer prüfen
|
||||
// System.out.println(unannTypeContext.getText());
|
||||
@ -121,8 +122,10 @@ public class TypeGenerator {
|
||||
if (wildcardContext.getChildCount() < 3) {
|
||||
if (!Objects.isNull(wildcardContext.extendsWildcardType())) {
|
||||
return new ExtendsWildcardType(convert(wildcardContext.extendsWildcardType().typeType(), reg, generics), wildcardContext.getStart());
|
||||
} else {
|
||||
} else if (!Objects.isNull(wildcardContext.superWildcardType())) {
|
||||
return new SuperWildcardType(convert(wildcardContext.superWildcardType().typeType(), reg, generics), wildcardContext.getStart());
|
||||
} else {
|
||||
return new ExtendsWildcardType(new RefType(new JavaClassName("java.lang.Object"), new NullToken()), wildcardContext.getStart());
|
||||
}
|
||||
} else {
|
||||
throw new NotImplementedException(); // Wildcard ohne Bound
|
||||
|
@ -102,7 +102,8 @@ public class TYPEStmt implements StatementVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
throw new NotImplementedException();
|
||||
castExpr.expr.accept(this);
|
||||
constraintsSet.addUndConstraint(new Pair(castExpr.getType(), castExpr.expr.getType(), PairOperator.SMALLERDOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,7 +197,7 @@ public class TYPEStmt implements StatementVisitor {
|
||||
*/
|
||||
}
|
||||
if (methodConstraints.size() < 1) {
|
||||
throw new TypeinferenceException("Methode " + methodCall.name + " ist in Klasse " + methodCall.receiver.getType() + " nicht vorhanden!", methodCall.getOffset());
|
||||
throw new TypeinferenceException("Methode " + methodCall.name + " in Klasse " + methodCall.receiver.getType()+ " ist nicht vorhanden!", methodCall.getOffset());
|
||||
}
|
||||
constraintsSet.addOderConstraint(methodConstraints);
|
||||
}
|
||||
@ -253,6 +254,9 @@ public class TYPEStmt implements StatementVisitor {
|
||||
// Es wird in OderConstraints davon ausgegangen dass die Bedingungen für die Typen der Argumente links stehen
|
||||
// und die Typen der Rückgabewerte immer rechts stehen (vgl. JavaTXCompiler)
|
||||
public void visit(BinaryExpr binary) {
|
||||
if(binary.getType().toString().equals("TPH ACK")){
|
||||
System.out.println();
|
||||
}
|
||||
binary.lexpr.accept(this);
|
||||
binary.rexpr.accept(this);
|
||||
if (binary.operation.equals(BinaryExpr.Operator.DIV) || binary.operation.equals(BinaryExpr.Operator.MUL) || binary.operation.equals(BinaryExpr.Operator.MOD) || binary.operation.equals(BinaryExpr.Operator.ADD) || binary.operation.equals(BinaryExpr.Operator.SUB)) {
|
||||
|
@ -60,7 +60,9 @@ public class AllgemeinTest {
|
||||
//String className = "Iteration";
|
||||
|
||||
//String className = "Cycle";
|
||||
String className = "TripleTest";
|
||||
//String className = "TripleTest";
|
||||
//String className = "WildcardList";
|
||||
String className = "List";
|
||||
//PL 2019-10-24: genutzt fuer unterschiedliche Tests
|
||||
path = System.getProperty("user.dir")+"/resources/AllgemeinTest/" + className + ".jav";
|
||||
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
|
||||
|
@ -3,9 +3,7 @@ import de.dhbwstuttgart.environment.ByteArrayClassLoader;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Vector;
|
||||
|
||||
@ -824,6 +822,7 @@ public class TestComplete {
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
|
||||
assertNull(clazz.getDeclaredMethod("m").invoke(instance));
|
||||
assertEquals(clazz.getDeclaredMethod("m2").invoke(instance), 'C');
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -833,4 +832,95 @@ public class TestComplete {
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
assertEquals(clazz.getSuperclass().getDeclaredField("x").get(instance), 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringConcat() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Op2.jav");
|
||||
var clazz = classFiles.get("Op2");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLamRunnable() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "LamRunnable.jav");
|
||||
var clazz = classFiles.get("LamRunnable");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccess() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Access.jav");
|
||||
var clazzPublic = classFiles.get("Access");
|
||||
var clazzDefault = classFiles.get("AccessDefault");
|
||||
|
||||
assertEquals(clazzPublic.getModifiers(), Modifier.PUBLIC);
|
||||
assertEquals(clazzDefault.getModifiers(), 0);
|
||||
|
||||
assertEquals(clazzPublic.getDeclaredMethod("mPublic").getModifiers(), Modifier.PUBLIC);
|
||||
assertEquals(clazzPublic.getDeclaredMethod("mProtected").getModifiers(), Modifier.PROTECTED);
|
||||
assertEquals(clazzPublic.getDeclaredMethod("mDefault").getModifiers(), 0);
|
||||
assertEquals(clazzPublic.getDeclaredMethod("mPrivate").getModifiers(), Modifier.PRIVATE);
|
||||
|
||||
assertEquals(clazzPublic.getDeclaredField("fPublic").getModifiers(), Modifier.PUBLIC);
|
||||
assertEquals(clazzPublic.getDeclaredField("fProtected").getModifiers(), Modifier.PROTECTED);
|
||||
assertEquals(clazzPublic.getDeclaredField("fDefault").getModifiers(), 0);
|
||||
assertEquals(clazzPublic.getDeclaredField("fPrivate").getModifiers(), Modifier.PRIVATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypeCast() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "TypeCast.jav");
|
||||
var clazz = classFiles.get("TypeCast");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnnotation() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Annotation.jav");
|
||||
var clazz = classFiles.get("Annotation");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWilcards() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Wildcards.jav");
|
||||
var clazz = classFiles.get("Wildcards");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBug122() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug122.jav");
|
||||
var clazz = classFiles.get("Bug122");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug123() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug123.jav");
|
||||
var clazz = classFiles.get("Bug123");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug125() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug125.jav");
|
||||
var clazz = classFiles.get("Bug125");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug112() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug112.jav");
|
||||
var clazz = classFiles.get("Bug112");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug285() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug285.jav");
|
||||
var clazz = classFiles.get("Bug285");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import java.util.List;
|
||||
|
||||
public class TestPackages {
|
||||
|
||||
private static final String bytecodeDirectory = System.getProperty("user.dir") + "/src/test/resources/testBytecode/generatedBC/";
|
||||
private static final String bytecodeDirectory = System.getProperty("user.dir") + "targetTest";
|
||||
|
||||
@Test
|
||||
public void testPackages() throws Exception {
|
||||
|
@ -22,7 +22,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void emptyClass() {
|
||||
ClassOrInterface emptyClass = new ClassOrInterface(0, new JavaClassName("EmptyClass"), new ArrayList<>(), Optional.empty(), Optional.empty(), new ArrayList<>(), new ArrayList<>(), new GenericDeclarationList(new ArrayList<>(), new NullToken()), new RefType(new JavaClassName("Object"), new NullToken()), false, false, new ArrayList<>(), new ArrayList<>(), new NullToken());
|
||||
ClassOrInterface emptyClass = new ClassOrInterface(0, new JavaClassName("EmptyClass"), new ArrayList<>(), Optional.empty(), Optional.empty(), new ArrayList<>(), new ArrayList<>(), new GenericDeclarationList(new ArrayList<>(), new NullToken()), new RefType(new JavaClassName("Object"), new NullToken()), false, false, new ArrayList<>(), new ArrayList<>(), new NullToken(), null);
|
||||
ResultSet emptyResultSet = new ResultSet(new HashSet<>());
|
||||
TargetStructure emptyTargetClass = new ASTToTargetAST(List.of(emptyResultSet)).convert(emptyClass);
|
||||
assert emptyTargetClass.getName().equals("EmptyClass");
|
||||
@ -32,7 +32,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void overloading() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Overloading.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Overloading.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -54,7 +54,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void tphsAndGenerics() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Tph2.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Tph2.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -65,7 +65,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void cycles() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Cycle.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Cycle.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -76,7 +76,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void infimum() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Infimum.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Infimum.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -87,7 +87,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void gen() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Gen.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Gen.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -103,7 +103,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void definedGenerics() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Generics.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -121,7 +121,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void definedGenerics2() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Generics2.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics2.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -137,7 +137,7 @@ public class ASTToTypedTargetAST {
|
||||
@Test
|
||||
@Ignore("Not implemented")
|
||||
public void definedGenerics3() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Generics3.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics3.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -148,7 +148,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void definedGenerics4() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/Generics4.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics4.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
|
@ -31,7 +31,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TestCodegen {
|
||||
static final Path outputPath = Path.of(System.getProperty("user.dir"), "src/test/resources/target/");
|
||||
static final Path outputPath = Path.of(System.getProperty("user.dir"), "/targetTest");
|
||||
|
||||
private static void writeClassFile(String name, byte[] code) throws IOException {
|
||||
Files.createDirectories(outputPath);
|
||||
@ -40,6 +40,7 @@ public class TestCodegen {
|
||||
|
||||
public static Map<String, ? extends Class<?>> generateClassFiles(IByteArrayClassLoader classLoader, String... files) throws IOException, ClassNotFoundException {
|
||||
var path = Path.of(System.getProperty("user.dir"), "resources/bytecode/javFiles/");
|
||||
Files.createDirectories(outputPath);
|
||||
var filenames = Arrays.stream(files).map(filename -> Path.of(path.toString(), filename).toFile()).toList();
|
||||
var compiler = new JavaTXCompiler(filenames, List.of(path.toFile(), outputPath.toFile()));
|
||||
var resultSet = compiler.typeInference();
|
||||
@ -81,7 +82,7 @@ public class TestCodegen {
|
||||
}
|
||||
|
||||
public static Map<String, ? extends Class<?>> generateClassFiles(String filename, IByteArrayClassLoader classLoader) throws IOException, ClassNotFoundException {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/javFiles/", filename).toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/", filename).toFile();
|
||||
var compiler = new JavaTXCompiler(List.of(file), List.of(file.getParentFile()));
|
||||
var resultSet = compiler.typeInference();
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||
|
||||
public class TestGenerics {
|
||||
private static final String rootDirectory = System.getProperty("user.dir") + "/resources/insertGenerics/javFiles/";
|
||||
private static final String bytecodeDirectory = System.getProperty("user.dir") + "/src/test/resources/testBytecode/generatedBC/";
|
||||
private static final String bytecodeDirectory = System.getProperty("user.dir") + "targetTest";
|
||||
|
||||
private record Result(List<GenericsResult> genericsResults, ClassOrInterface clazz) {
|
||||
Method findMethod(String name) {
|
||||
|
Loading…
Reference in New Issue
Block a user