JavaTXCompilerInJavaTX/javatx-src/main/java/de/dhbwstuttgart/syntaxtree/Field.jav
2024-04-27 17:37:15 +02:00

54 lines
1.3 KiB
Java

package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import java.lang.String;
import java.lang.Integer;
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import java.lang.Iterable;
import de.dhbwstuttgart.syntaxtree.TypeScope;
import java.util.ArrayList;
//TODO: curretly types are needed, or else wrong bytecode type in visitor.accept -> runtime crash, figure out why
public class Field extends SyntaxTreeNode implements TypeScope {
public final int modifier;
private String name;
private RefTypeOrTPHOrWildcardOrGeneric type;
public Field(String name, RefTypeOrTPHOrWildcardOrGeneric type, int modifier, Token offset) {
super(offset);
this.name = name;
this.type = type;
this.modifier = modifier;
}
public String getName() {
return this.name;
}
public RefTypeOrTPHOrWildcardOrGeneric getType() {
return type;
}
@Override
public void accept(ASTVisitor visitor) {
visitor.visit(this);
}
@Override
public Iterable<? extends GenericTypeVar> getGenerics() {
return new ArrayList<>();
}
@Override
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
return type;
}
}