diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index 709a3350f..23f04d2bd 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.target.generate; +import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.syntaxtree.ASTVisitor; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.Field; @@ -9,6 +10,7 @@ import de.dhbwstuttgart.syntaxtree.type.*; import de.dhbwstuttgart.target.tree.*; import de.dhbwstuttgart.target.tree.expression.TargetBlock; import de.dhbwstuttgart.target.tree.type.*; +import de.dhbwstuttgart.typeinference.result.ResultSet; import java.util.ArrayList; import java.util.List; @@ -17,6 +19,10 @@ import java.util.stream.Collectors; public class ASTToTargetAST { + public TargetClass convert(ClassOrInterface input, ResultSet resultSet){ + throw new NotImplementedException(); + } + public TargetClass convert(ClassOrInterface input, Map sigma){ List targetConstructors = new ArrayList<>(); //TODO constructor conversion -> also reduce syntactic sugar diff --git a/src/test/java/targetast/ASTToTypedTargetAST.java b/src/test/java/targetast/ASTToTypedTargetAST.java new file mode 100644 index 000000000..e4c93d1a7 --- /dev/null +++ b/src/test/java/targetast/ASTToTypedTargetAST.java @@ -0,0 +1,32 @@ +package targetast; + +import de.dhbwstuttgart.parser.NullToken; +import de.dhbwstuttgart.parser.scope.JavaClassName; +import de.dhbwstuttgart.syntaxtree.*; +import de.dhbwstuttgart.syntaxtree.type.RefType; +import de.dhbwstuttgart.target.generate.ASTToTargetAST; +import de.dhbwstuttgart.target.tree.TargetClass; +import de.dhbwstuttgart.typeinference.result.ResultSet; +import org.antlr.v4.runtime.Token; +import org.junit.Test; + +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; + +public class ASTToTypedTargetAST { + + @Test + public void emptyClass(){ + ClassOrInterface emptyClass = new ClassOrInterface(0, new JavaClassName("EmptyClass"), new ArrayList<>(), java.util.Optional.empty(), new ArrayList<>(), new ArrayList<>(), new GenericDeclarationList(new ArrayList<>(), new NullToken()), + new RefType(new JavaClassName("Object"), new NullToken()), false, new ArrayList<>(), new NullToken()); + ResultSet emptyResultSet = new ResultSet(new HashSet<>()); + TargetClass emptyTargetClass = new ASTToTargetAST().convert(emptyClass, emptyResultSet); + assert emptyTargetClass.getName().equals("EmptyClass"); + assert emptyTargetClass.methods().size() == 0; + assert emptyTargetClass.fields().size() == 0; + } + +}