mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
implement Constraint, Substitution
This commit is contained in:
parent
c21242e3e1
commit
a642279be1
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user