Add to Target AST

This commit is contained in:
JanUlrich 2022-04-16 18:25:13 +02:00
parent a0367d5464
commit 5c60918c47
5 changed files with 15 additions and 6 deletions

View File

@ -20,7 +20,8 @@ public class ASTToTargetAST {
public TargetClass convert(ClassOrInterface input, Map<TypePlaceholder, TargetType> sigma){
List<TargetConstructor> targetConstructors = new ArrayList<>();
//TODO constructor conversion -> also reduce syntactic sugar
return new TargetClass(input.getModifiers(),input.getClassName().toString(), sigma.get(input.getSuperClass()),
return new TargetClass(input.getModifiers(),input.getClassName().toString(), null,
sigma.get(input.getSuperClass()),
input.getSuperInterfaces().stream().map(it -> sigma.get(it)).collect(Collectors.toList()),
targetConstructors,
input.getFieldDecl().stream().map(it -> convert(it, sigma)).collect(Collectors.toList()),
@ -42,7 +43,7 @@ public class ASTToTargetAST {
}
private TargetField convert(Field input, Map<TypePlaceholder, TargetType> sigma) {
return null;
return new TargetField(convert(input.getType(), sigma), input.getName());
}
private TargetType convert(RefTypeOrTPHOrWildcardOrGeneric input, Map<TypePlaceholder, TargetType> sigma) {

View File

@ -0,0 +1,7 @@
package de.dhbwstuttgart.target.tree;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.target.tree.type.TargetType;
public record GenericDeclaration(GenericRefType generic, TargetType bound) {
}

View File

@ -5,6 +5,7 @@ import de.dhbwstuttgart.target.tree.type.TargetType;
import java.util.List;
public record TargetClass(int modifiers, String qualifiedName, TargetType superType, List<TargetType> implementingInterfaces,
public record TargetClass(int modifiers, String qualifiedName, List<GenericDeclaration> generics, TargetType superType,
List<TargetType> implementingInterfaces,
List<TargetConstructor> constructors, List<TargetField> fields, List<TargetMethod> methods) {}

View File

@ -1,7 +1,9 @@
package de.dhbwstuttgart.target.tree;
import de.dhbwstuttgart.target.tree.expression.TargetBlock;
import java.util.List;
public record TargetConstructor(List<MethodParameter> parameterTypes) {
public record TargetConstructor(List<MethodParameter> parameterTypes, TargetBlock block) {
}

View File

@ -1,7 +1,5 @@
package de.dhbwstuttgart.target.tree.type;
import java.util.List;
public record TargetExtendsWildcard(TargetType innerType) implements TargetType{
}