Studienarbeit beginnen
This commit is contained in:
parent
f00f9c9215
commit
9e14473975
@ -53,7 +53,7 @@ public class JavaTXCompiler {
|
||||
for(File forSourceFile : sourceFiles.keySet())
|
||||
for(JavaClassName name : sourceFiles.get(forSourceFile).getImports()){
|
||||
ClassOrInterface importedClass = ASTFactory.createClass(
|
||||
ClassLoader.getSystemClassLoader().loadClass(name.toString()));
|
||||
ClassLoader.getSystemClassLoader().loadClass(name.toString()));// Konvertiert class -> ClassOrInterface
|
||||
importedClasses.add(importedClass);
|
||||
}
|
||||
allClasses.addAll(importedClasses);
|
||||
@ -78,6 +78,12 @@ public class JavaTXCompiler {
|
||||
return results.stream().map((unifyPairs ->
|
||||
new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Object strucTypeInference(){
|
||||
//TODO mvr
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private Map<String, TypePlaceholder> generateTPHMap(ConstraintSet<Pair> constraints){
|
||||
HashMap<String, TypePlaceholder> ret = new HashMap<>();
|
||||
|
32
src/de/dhbwstuttgart/strucTypes/CheckTypeVisitor.java
Normal file
32
src/de/dhbwstuttgart/strucTypes/CheckTypeVisitor.java
Normal file
@ -0,0 +1,32 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class CheckTypeVisitor extends DefaultASTVisitor {
|
||||
|
||||
private boolean isTypeVariable;
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
public void visit(RefType refType) {
|
||||
this.isTypeVariable = true;
|
||||
this.name = refType.getName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
this.isTypeVariable = false;
|
||||
this.name = typePlaceholder.getName();
|
||||
}
|
||||
|
||||
public boolean isTypeVariable() {
|
||||
return isTypeVariable;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
}
|
44
src/de/dhbwstuttgart/strucTypes/ConstraintsSet.java
Normal file
44
src/de/dhbwstuttgart/strucTypes/ConstraintsSet.java
Normal file
@ -0,0 +1,44 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstraintsSet {
|
||||
|
||||
private List<SubTypeConstraint> subTypeConstraints;
|
||||
private List<FieldConstraint> fieldConstraints;
|
||||
private List<MethodConstraint> methodConstraints;
|
||||
|
||||
public ConstraintsSet() {
|
||||
this.subTypeConstraints = new ArrayList<>();
|
||||
this.fieldConstraints = new ArrayList<>();
|
||||
this.methodConstraints = new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<SubTypeConstraint> getSubTypeConstraints() {
|
||||
return subTypeConstraints;
|
||||
}
|
||||
|
||||
public List<FieldConstraint> getFieldConstraints() {
|
||||
return fieldConstraints;
|
||||
}
|
||||
|
||||
public List<MethodConstraint> getMethodConstraints() {
|
||||
return methodConstraints;
|
||||
}
|
||||
|
||||
public void addConstraint(SubTypeConstraint constraint){
|
||||
this.subTypeConstraints.add(constraint);
|
||||
}
|
||||
|
||||
public void addConstraint(FieldConstraint constraint){
|
||||
this.fieldConstraints.add(constraint);
|
||||
}
|
||||
|
||||
public void addConstraint(MethodConstraint constraint){
|
||||
this.methodConstraints.add(constraint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
314
src/de/dhbwstuttgart/strucTypes/DefaultASTVisitor.java
Normal file
314
src/de/dhbwstuttgart/strucTypes/DefaultASTVisitor.java
Normal file
@ -0,0 +1,314 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Assign;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.AssignToField;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.CastExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.DoStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.EmptyStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ExpressionReceiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ForStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.IfStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.InstanceOf;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.MethodCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewArray;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewClass;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ReturnVoid;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.StaticClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Super;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.This;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.UnaryPlus;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class DefaultASTVisitor implements ASTVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(ArgumentList argumentList) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Assign assign) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Binary binary) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Block block) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(EmptyStmt emptyStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FieldVar fieldVar) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ForStmt forStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IfStmt ifStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InstanceOf instanceOf) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVar localVar) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVarDecl localVarDecl) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodCall methodCall) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewClass methodCall) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewArray newArray) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Return aReturn) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ReturnVoid aReturn) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StaticClassName staticClassName) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Super aSuper) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(This aThis) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryPlus unaryPlus) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(WhileStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DoStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Null aNull) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Literal literal) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToField assignLeftSide) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToLocal assignLeftSide) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperCall superCall) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExpressionReceiver expressionReceiver) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SourceFile sourceFile) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericTypeVar genericTypeVar) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FormalParameter formalParameter) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericDeclarationList genericTypeVars) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method field) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Constructor field) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ParameterList formalParameters) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassOrInterface classOrInterface) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RefType refType) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperWildcardType superWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExtendsWildcardType extendsWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericRefType genericRefType) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
}
|
33
src/de/dhbwstuttgart/strucTypes/FieldConstraint.java
Normal file
33
src/de/dhbwstuttgart/strucTypes/FieldConstraint.java
Normal file
@ -0,0 +1,33 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
public class FieldConstraint {
|
||||
|
||||
private RefTypeOrTPHOrWildcardOrGeneric classType;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric fieldType;
|
||||
private String fieldName;
|
||||
|
||||
public FieldConstraint(RefTypeOrTPHOrWildcardOrGeneric classType, RefTypeOrTPHOrWildcardOrGeneric fieldType,
|
||||
String fieldName) {
|
||||
this.classType = classType;
|
||||
this.fieldType = fieldType;
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getClassType() {
|
||||
return classType;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getFieldType() {
|
||||
return fieldType;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
57
src/de/dhbwstuttgart/strucTypes/MethodConstraint.java
Normal file
57
src/de/dhbwstuttgart/strucTypes/MethodConstraint.java
Normal file
@ -0,0 +1,57 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class MethodConstraint {
|
||||
|
||||
private RefTypeOrTPHOrWildcardOrGeneric classType;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric returnType;
|
||||
private String methodName;
|
||||
private List<SubTypeConstraint> arguments;
|
||||
|
||||
public MethodConstraint(RefTypeOrTPHOrWildcardOrGeneric classType, RefTypeOrTPHOrWildcardOrGeneric returnType,
|
||||
String methodName, List<SubTypeConstraint> arguments) {
|
||||
this.classType = classType;
|
||||
this.returnType = returnType;
|
||||
this.methodName = methodName;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getClassType() {
|
||||
return classType;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public List<SubTypeConstraint> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public void addArgument(SubTypeConstraint... subTypeConstraints){
|
||||
for (SubTypeConstraint subTypeConstraint : subTypeConstraints) {
|
||||
this.arguments.add(subTypeConstraint);
|
||||
}
|
||||
}
|
||||
|
||||
public void addArgument(RefTypeOrTPHOrWildcardOrGeneric... parameters){
|
||||
for (RefTypeOrTPHOrWildcardOrGeneric parameter : parameters) {
|
||||
Token offset = parameter.getOffset();
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(offset);
|
||||
SubTypeConstraint subTypeConstraint = new SubTypeConstraint(parameter, tph);
|
||||
this.arguments.add(subTypeConstraint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
16
src/de/dhbwstuttgart/strucTypes/StrucTYPE.java
Normal file
16
src/de/dhbwstuttgart/strucTypes/StrucTYPE.java
Normal file
@ -0,0 +1,16 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
|
||||
public class StrucTYPE {
|
||||
|
||||
private TypeAssumptions assumptions;
|
||||
private SourceFile sourceFile;
|
||||
|
||||
public StrucTYPE(TypeAssumptions assumptions, SourceFile sourceFile) {
|
||||
this.assumptions = assumptions;
|
||||
this.sourceFile = sourceFile;
|
||||
}
|
||||
|
||||
|
||||
}
|
187
src/de/dhbwstuttgart/strucTypes/StrucTypeVisitor.java
Normal file
187
src/de/dhbwstuttgart/strucTypes/StrucTypeVisitor.java
Normal file
@ -0,0 +1,187 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Assign;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.AssignToField;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.DoStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.EmptyStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ForStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.IfStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.InstanceOf;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewArray;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ReturnVoid;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.StaticClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Super;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.UnaryPlus;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
|
||||
public abstract class StrucTypeVisitor implements ASTVisitor {
|
||||
@Override
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Assign assign) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Binary binary) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(EmptyStmt emptyStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ForStmt forStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IfStmt ifStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InstanceOf instanceOf) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVarDecl localVarDecl) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewArray newArray) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ReturnVoid aReturn) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StaticClassName staticClassName) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Super aSuper) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryPlus unaryPlus) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(WhileStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DoStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Null aNull) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Literal literal) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToField assignLeftSide) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToLocal assignLeftSide) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperCall superCall) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericTypeVar genericTypeVar) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericDeclarationList genericTypeVars) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Constructor field) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperWildcardType superWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExtendsWildcardType extendsWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericRefType genericRefType) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
}
|
22
src/de/dhbwstuttgart/strucTypes/SubTypeConstraint.java
Normal file
22
src/de/dhbwstuttgart/strucTypes/SubTypeConstraint.java
Normal file
@ -0,0 +1,22 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
public class SubTypeConstraint {
|
||||
|
||||
private RefTypeOrTPHOrWildcardOrGeneric subtype;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric supertype;
|
||||
|
||||
public SubTypeConstraint(RefTypeOrTPHOrWildcardOrGeneric subtype, RefTypeOrTPHOrWildcardOrGeneric supertype) {
|
||||
this.subtype = subtype;
|
||||
this.supertype = supertype;
|
||||
}
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getSubtype() {
|
||||
return subtype;
|
||||
}
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getSupertype() {
|
||||
return supertype;
|
||||
}
|
||||
|
||||
|
||||
}
|
361
src/de/dhbwstuttgart/strucTypes/SyntaxTreePrinter.java
Normal file
361
src/de/dhbwstuttgart/strucTypes/SyntaxTreePrinter.java
Normal file
@ -0,0 +1,361 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Assign;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.AssignToField;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.CastExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.DoStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.EmptyStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ExpressionReceiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ForStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.IfStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.InstanceOf;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.MethodCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewArray;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewClass;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Receiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ReturnVoid;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.StaticClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Super;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.This;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.UnaryPlus;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class SyntaxTreePrinter implements ASTVisitor {
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void visit(SourceFile sourceFile) {
|
||||
sourceFile.KlassenVektor.forEach(cl -> cl.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassOrInterface classOrInterface) {
|
||||
JavaClassName className = classOrInterface.getClassName();
|
||||
List<Field> fields = classOrInterface.getFieldDecl();
|
||||
List<Method> methods = classOrInterface.getMethods();
|
||||
RefType superClass = classOrInterface.getSuperClass();
|
||||
List<? extends RefTypeOrTPHOrWildcardOrGeneric> implementedInterfaces = classOrInterface.implementedInterfaces;
|
||||
System.out.println("class: " + className);
|
||||
fields.forEach(f->f.accept(this));
|
||||
methods.forEach(m->m.accept(this));
|
||||
System.out.print("superClass: ");
|
||||
superClass.accept(this);
|
||||
System.out.println("implemented Interfaces: ");
|
||||
implementedInterfaces.forEach(i -> i.accept(this));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
String name = field.getName();
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = field.getType();
|
||||
System.out.print("field: " + name + " : ");
|
||||
type.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method method) {
|
||||
String name = method.getName();
|
||||
RefTypeOrTPHOrWildcardOrGeneric returnType = method.getReturnType();
|
||||
ParameterList parameterList = method.getParameterList();
|
||||
System.out.print("method: " + name + " : ");
|
||||
returnType.accept(this);
|
||||
parameterList.accept(this);
|
||||
method.block.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Block block) {
|
||||
block.statements.forEach(s->s.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ArgumentList argumentList) {
|
||||
List<Expression> arguments = argumentList.getArguments();
|
||||
System.out.println("arguments: ");
|
||||
arguments.forEach(a->a.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ParameterList formalParameters) {
|
||||
List<FormalParameter> formalparalist = formalParameters.getFormalparalist();
|
||||
formalparalist.forEach(p->p.accept(this));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FormalParameter formalParameter) {
|
||||
String name = formalParameter.getName();
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = formalParameter.getType();
|
||||
System.out.print("parameter: " + name + " : ");
|
||||
type.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodCall methodCall) {
|
||||
String name = methodCall.name;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = methodCall.getType();
|
||||
ArgumentList argumentList = methodCall.getArgumentList();
|
||||
Receiver receiver = methodCall.receiver;
|
||||
System.out.print("methodCall: " + name + " : ");
|
||||
type.accept(this);
|
||||
argumentList.accept(this);
|
||||
System.out.print("receiver: ");
|
||||
receiver.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Return aReturn) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = aReturn.getType();
|
||||
System.out.println("returnType: " + type);
|
||||
aReturn.retexpr.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVar localVar) {
|
||||
String name = localVar.name;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = localVar.getType();
|
||||
System.out.print("localVar: " + name + " : ");
|
||||
type.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVarDecl localVarDecl) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FieldVar fieldVar) {
|
||||
String name = fieldVar.fieldVarName;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = fieldVar.getType();
|
||||
Expression receiver = fieldVar.receiver;
|
||||
System.out.print("fieldVar: " + name + " : ");
|
||||
type.accept(this);
|
||||
System.out.println("receiver: ");
|
||||
receiver.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
Expression expr = castExpr.expr;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = castExpr.getType();
|
||||
System.out.print("castExpr: ");
|
||||
expr.accept(this);
|
||||
System.out.print("typeCastExpr: ");
|
||||
type.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewClass newClass) {
|
||||
String name = newClass.name;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = newClass.getType();
|
||||
ArgumentList argumentList = newClass.getArgumentList();
|
||||
System.out.print("new: " + name + " : ");
|
||||
type.accept(this);
|
||||
argumentList.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(This aThis) {
|
||||
ArgumentList arglist = aThis.arglist;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = aThis.getType();
|
||||
System.out.print("this: " + " : ");
|
||||
type.accept(this);
|
||||
if( arglist != null) arglist.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RefType refType) {
|
||||
JavaClassName name = refType.getName();
|
||||
System.out.println(name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
String name = typePlaceholder.getName();
|
||||
System.out.println("TPH " + name);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewArray newArray) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ReturnVoid aReturn) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StaticClassName staticClassName) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Super aSuper) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryPlus unaryPlus) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(WhileStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DoStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Assign assign) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ForStmt forStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Binary binary) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IfStmt ifStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(EmptyStmt emptyStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Null aNull) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Literal literal) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = literal.getType();
|
||||
System.out.print("literal: ");
|
||||
type.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InstanceOf instanceOf) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToField assignLeftSide) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToLocal assignLeftSide) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperCall superCall) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExpressionReceiver expressionReceiver) {
|
||||
Expression expr = expressionReceiver.expr;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = expressionReceiver.getType();
|
||||
System.out.print("expressionReceiverType: " + type);
|
||||
System.out.print(" expressionReceiver: ");
|
||||
expr.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericTypeVar genericTypeVar) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericDeclarationList genericTypeVars) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Constructor field) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperWildcardType superWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExtendsWildcardType extendsWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericRefType genericRefType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
188
src/de/dhbwstuttgart/strucTypes/TYPEExpr.java
Normal file
188
src/de/dhbwstuttgart/strucTypes/TYPEExpr.java
Normal file
@ -0,0 +1,188 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Assign;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.AssignToField;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.CastExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.DoStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.EmptyStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ExpressionReceiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ForStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.IfStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.InstanceOf;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.MethodCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewArray;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewClass;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ReturnVoid;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.StaticClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Super;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.This;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.UnaryPlus;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class TYPEExpr extends StrucTypeVisitor {
|
||||
|
||||
private TypeAssumptions assumptions;
|
||||
private ConstraintsSet constraints;
|
||||
|
||||
public TYPEExpr(TypeAssumptions assumptions) {
|
||||
this.assumptions = assumptions;
|
||||
}
|
||||
|
||||
public ConstraintsSet getConstraints(){
|
||||
return this.constraints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SourceFile sourceFile) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassOrInterface classOrInterface) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method method) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ParameterList formalParameters) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FormalParameter formalParameter) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Block block) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Return aReturn) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExpressionReceiver expressionReceiver) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVar localVar) {
|
||||
// keine neuen Constraints
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FieldVar fieldVar) {
|
||||
fieldVar.receiver.accept(this);
|
||||
CheckTypeVisitor fieldTypeVisitor = new CheckTypeVisitor();
|
||||
fieldVar.getType().accept(fieldTypeVisitor);
|
||||
//TODO check ty in Ass && rty f in fields(ty)
|
||||
if(!fieldTypeVisitor.isTypeVariable()){} // keine neuen Constraints
|
||||
else{
|
||||
FieldConstraint fieldConstraint = new FieldConstraint(fieldVar.receiver.getType(), fieldVar.getType(), fieldVar.fieldVarName);
|
||||
this.constraints.addConstraint(fieldConstraint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodCall methodCall) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ArgumentList argumentList) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewClass newClass) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RefType refType) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(This aThis) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
5
src/de/dhbwstuttgart/strucTypes/TypeAssumptions.java
Normal file
5
src/de/dhbwstuttgart/strucTypes/TypeAssumptions.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
public class TypeAssumptions {
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope{
|
||||
private GenericDeclarationList genericClassParameters;
|
||||
private RefType superClass;
|
||||
protected boolean isInterface;
|
||||
private List<? extends RefTypeOrTPHOrWildcardOrGeneric> implementedInterfaces;
|
||||
public final List<? extends RefTypeOrTPHOrWildcardOrGeneric> implementedInterfaces;
|
||||
private List<Constructor> constructors;
|
||||
|
||||
public ClassOrInterface(int modifiers, JavaClassName name, List<Field> fielddecl, List<Method> methods, List<Constructor> constructors, GenericDeclarationList genericClassParameters,
|
||||
|
@ -1,20 +0,0 @@
|
||||
package strucType;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
|
||||
public class Test {
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/test/strucType/javFiles/";
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void test() throws ClassNotFoundException, IOException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory + "test.jav"));
|
||||
System.out.println("test ende");
|
||||
}
|
||||
|
||||
}
|
73
test/strucType/TestSyntaxTreePrinter.java
Normal file
73
test/strucType/TestSyntaxTreePrinter.java
Normal file
@ -0,0 +1,73 @@
|
||||
package strucType;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.strucTypes.SyntaxTreePrinter;
|
||||
|
||||
public class TestSyntaxTreePrinter {
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/test/strucType/javFiles/";
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void test() throws ClassNotFoundException, IOException {
|
||||
ArrayList<File> files = new ArrayList<>();
|
||||
files.add(new File(rootDirectory + "testLocalVar.jav"));
|
||||
files.add(new File(rootDirectory + "testCast.jav"));
|
||||
files.add(new File(rootDirectory + "testNew.jav"));
|
||||
files.add(new File(rootDirectory + "testFieldVar.jav"));
|
||||
files.add(new File(rootDirectory + "testFieldMethod.jav"));
|
||||
files.add(new File(rootDirectory + "testPaperExample.jav"));
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(files);
|
||||
compiler.sourceFiles.keySet().forEach(f->{
|
||||
String name = f.getName();
|
||||
System.out.println("Filename: " + name);
|
||||
compiler.sourceFiles.get(f).accept(new SyntaxTreePrinter());
|
||||
System.out.println();
|
||||
});
|
||||
// this.printSyntaxTree(compiler);
|
||||
System.out.println("test end");
|
||||
}
|
||||
|
||||
// private void printSyntaxTree(JavaTXCompiler compiler){
|
||||
// Collection<SourceFile> sourceFiles= compiler.sourceFiles.values();
|
||||
// for (SourceFile sourceFile : sourceFiles) {
|
||||
// List<ClassOrInterface> klassenVektor = sourceFile.KlassenVektor;
|
||||
// for (ClassOrInterface classOrInterface : klassenVektor) {
|
||||
// JavaClassName className = classOrInterface.getClassName();
|
||||
// System.out.println("class: "+ className);
|
||||
// List<Field> fields = classOrInterface.getFieldDecl();
|
||||
// List<Method> methods = classOrInterface.getMethods();
|
||||
// for (Field field : fields) {
|
||||
// String fName = field.getName();
|
||||
// RefTypeOrTPHOrWildcardOrGeneric fType = field.getType();
|
||||
// System.out.println("field: "+ fName + " : " + fType);
|
||||
// }
|
||||
// for (Method method : methods) {
|
||||
// String mName = method.getName();
|
||||
// RefTypeOrTPHOrWildcardOrGeneric mReturnType = method.getReturnType();
|
||||
// System.out.println("method: " + mName + " : " + mReturnType);
|
||||
// ParameterList mParameterList = method.getParameterList();
|
||||
// for (FormalParameter formalParameter : mParameterList) {
|
||||
// String paraName = formalParameter.getName();
|
||||
// RefTypeOrTPHOrWildcardOrGeneric paraType = formalParameter.getType();
|
||||
// System.out.println("parameter: " + paraName + " : " + paraType);
|
||||
// }
|
||||
// RefTypeOrTPHOrWildcardOrGeneric blockType = method.block.getType();
|
||||
// System.out.println("blockType: " + blockType);
|
||||
// List<Statement> blockStatements = method.block.getStatements();
|
||||
// for (Statement statement : blockStatements) {
|
||||
// RefTypeOrTPHOrWildcardOrGeneric statementType = statement.getType();
|
||||
// System.out.println("statementType: " + statementType);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
class C1 extends Object
|
||||
{
|
||||
m(para) { return para; }
|
||||
}
|
4
test/strucType/javFiles/testCast.jav
Normal file
4
test/strucType/javFiles/testCast.jav
Normal file
@ -0,0 +1,4 @@
|
||||
class C
|
||||
{
|
||||
mC(x){return (Integer)x; }
|
||||
}
|
5
test/strucType/javFiles/testFieldMethod.jav
Normal file
5
test/strucType/javFiles/testFieldMethod.jav
Normal file
@ -0,0 +1,5 @@
|
||||
class M
|
||||
{
|
||||
f;
|
||||
mM(x, y) { return f.mF(x, y); }
|
||||
}
|
8
test/strucType/javFiles/testFieldVar.jav
Normal file
8
test/strucType/javFiles/testFieldVar.jav
Normal file
@ -0,0 +1,8 @@
|
||||
class F
|
||||
{
|
||||
f;
|
||||
|
||||
mF() { return f; }
|
||||
|
||||
mX(x) { return x.f; }
|
||||
}
|
6
test/strucType/javFiles/testLocalVar.jav
Normal file
6
test/strucType/javFiles/testLocalVar.jav
Normal file
@ -0,0 +1,6 @@
|
||||
import java.util.List;
|
||||
|
||||
class C1 implements List
|
||||
{
|
||||
m(x) { return x; }
|
||||
}
|
4
test/strucType/javFiles/testNew.jav
Normal file
4
test/strucType/javFiles/testNew.jav
Normal file
@ -0,0 +1,4 @@
|
||||
class N
|
||||
{
|
||||
mN(s) {return new String(s); }
|
||||
}
|
4
test/strucType/javFiles/testPaperExample.jav
Normal file
4
test/strucType/javFiles/testPaperExample.jav
Normal file
@ -0,0 +1,4 @@
|
||||
class A
|
||||
{
|
||||
mt(x, y, z) { return x.sub(y).add(z); }
|
||||
}
|
Loading…
Reference in New Issue
Block a user