implement Constraint, Substitution

This commit is contained in:
Johanna Stuber 2021-01-27 11:10:09 +01:00
parent c21242e3e1
commit a642279be1
2 changed files with 18 additions and 10 deletions

View File

@ -6,6 +6,10 @@ import edu.kit.typicalc.model.type.Type;
* Constrains two types to be equal.
*/
public class Constraint {
private final Type a;
private final Type b;
/**
* Creates a new constraint using the two types.
*
@ -13,23 +17,23 @@ public class Constraint {
* @param b second type
*/
public Constraint(Type a, Type b) {
// TODO
// TODO: null checks?
this.a = a;
this.b = b;
}
/**
* @return the first type
*/
public Type getFirstType() {
return null;
// TODO
return a;
}
/**
* @return the second type
*/
public Type getSecondType() {
return null;
// TODO
return b;
}
}

View File

@ -7,6 +7,10 @@ import edu.kit.typicalc.model.type.TypeVariable;
* A substitution specifies that some type should be replaced by a different type.
*/
public class Substitution {
private final TypeVariable a;
private final Type b;
/**
* Creates a new substitution using a type variable a and a type b. When the substitution is applied to a type,
* all occurring instances of a should be substituted with b.
@ -15,22 +19,22 @@ public class Substitution {
* @param b type to insert
*/
public Substitution(TypeVariable a, Type b) {
// TODO
// TODO: null checks?
this.a = a;
this.b = b;
}
/**
* @return the type variable
*/
public TypeVariable getVariable() {
return null;
// TODO
return a;
}
/**
* @return the replacement type
*/
Type getType() {
return null;
// TODO
return b;
}
}