import { Type } from "./Type"; export class ProcedureType extends Type { constructor(readonly argumentTypes: Type[], readonly returnType: Type) { super(); } override equals(otherType: Type): boolean { if (otherType instanceof ProcedureType && this.argumentTypes.length === otherType.argumentTypes.length) { for (let i = 0; i < this.argumentTypes.length; i++) { if (!this.argumentTypes[i].equals(otherType.argumentTypes[i])) { return false; } } return this.returnType.equals(otherType.returnType); } else { return false; } } override isAssignableTo(otherType: Type): boolean { return false; } override toString(): string { const argumentsString = this.argumentTypes.map( t => t.toString()).join(" x "); return `${argumentsString} -> ${this.returnType.toString()}`; } }