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.
|
* Constrains two types to be equal.
|
||||||
*/
|
*/
|
||||||
public class Constraint {
|
public class Constraint {
|
||||||
|
|
||||||
|
private final Type a;
|
||||||
|
private final Type b;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new constraint using the two types.
|
* Creates a new constraint using the two types.
|
||||||
*
|
*
|
||||||
@ -13,23 +17,23 @@ public class Constraint {
|
|||||||
* @param b second type
|
* @param b second type
|
||||||
*/
|
*/
|
||||||
public Constraint(Type a, Type b) {
|
public Constraint(Type a, Type b) {
|
||||||
// TODO
|
// TODO: null checks?
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the first type
|
* @return the first type
|
||||||
*/
|
*/
|
||||||
public Type getFirstType() {
|
public Type getFirstType() {
|
||||||
return null;
|
return a;
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the second type
|
* @return the second type
|
||||||
*/
|
*/
|
||||||
public Type getSecondType() {
|
public Type getSecondType() {
|
||||||
return null;
|
return b;
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,10 @@ import edu.kit.typicalc.model.type.TypeVariable;
|
|||||||
* A substitution specifies that some type should be replaced by a different type.
|
* A substitution specifies that some type should be replaced by a different type.
|
||||||
*/
|
*/
|
||||||
public class Substitution {
|
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,
|
* 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.
|
* all occurring instances of a should be substituted with b.
|
||||||
@ -15,22 +19,22 @@ public class Substitution {
|
|||||||
* @param b type to insert
|
* @param b type to insert
|
||||||
*/
|
*/
|
||||||
public Substitution(TypeVariable a, Type b) {
|
public Substitution(TypeVariable a, Type b) {
|
||||||
// TODO
|
// TODO: null checks?
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the type variable
|
* @return the type variable
|
||||||
*/
|
*/
|
||||||
public TypeVariable getVariable() {
|
public TypeVariable getVariable() {
|
||||||
return null;
|
return a;
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the replacement type
|
* @return the replacement type
|
||||||
*/
|
*/
|
||||||
Type getType() {
|
Type getType() {
|
||||||
return null;
|
return b;
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user