import { Type } from "./Type"; export enum ConcretePrimitiveType { BOOL, INT, STRING, VOID //WILDCARD // pseuCo currently does not support wildcard types } export class PrimitiveType extends Type { constructor(readonly concretePrimitiveType: ConcretePrimitiveType) { super(); } override equals(otherType: Type): boolean { return otherType instanceof PrimitiveType && otherType.concretePrimitiveType == this.concretePrimitiveType; } override isAssignableTo(otherType: Type): boolean { return this.equals(otherType) } override toString(): string { switch (this.concretePrimitiveType) { case ConcretePrimitiveType.BOOL: return "bool"; case ConcretePrimitiveType.INT: return "int"; case ConcretePrimitiveType.STRING: return "string"; case ConcretePrimitiveType.VOID: return "void"; } } override get isIntType() : boolean { return this.concretePrimitiveType == ConcretePrimitiveType.INT; } override get isStringType() : boolean { return this.concretePrimitiveType == ConcretePrimitiveType.STRING; } override get isBoolType() : boolean { return this.concretePrimitiveType == ConcretePrimitiveType.BOOL; } override get isVoidType() : boolean { return this.concretePrimitiveType == ConcretePrimitiveType.VOID; } } export const PrimitiveTypes = { bool: new PrimitiveType(ConcretePrimitiveType.BOOL), int: new PrimitiveType(ConcretePrimitiveType.INT), string: new PrimitiveType(ConcretePrimitiveType.STRING), void: new PrimitiveType(ConcretePrimitiveType.VOID) }