[typer][be] Add helper for checking type.kind

This commit is contained in:
Sathya Gunasekaran
2023-02-14 19:10:37 +00:00
parent 5673588be4
commit 81b23f9242
+8 -4
View File
@@ -691,20 +691,24 @@ function typeVarEquals(tA: Type, tB: Type): boolean {
return false;
}
function typeKindCheck(tA: Type, tb: Type, type: string): boolean {
return tA.kind === type && tb.kind === type;
}
function primitiveTypeEquals(tA: Type, tB: Type): boolean {
return tA.kind === "Primitive" && tB.kind === "Primitive";
return typeKindCheck(tA, tB, "Primitive");
}
function polyTypeEquals(tA: Type, tB: Type): boolean {
return tA.kind === "Poly" && tB.kind === "Poly";
return typeKindCheck(tA, tB, "Poly");
}
function objectTypeEquals(tA: Type, tB: Type): boolean {
return tA.kind === "Object" && tB.kind === "Object";
return typeKindCheck(tA, tB, "Object");
}
function funcTypeEquals(tA: Type, tB: Type): boolean {
return tA.kind === "Function" && tB.kind === "Function";
return typeKindCheck(tA, tB, "Function");
}
function phiTypeEquals(tA: Type, tB: Type): boolean {