UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

66 lines (65 loc) 1.95 kB
import { TupleType } from "./TupleType.js"; export class ArrayType { constructor(elementType) { this.elementType = elementType; } getElementType() { return this.elementType; } getName() { return `[${this.elementType.getName()}]`; } isAssignableFrom(other) { return this.isSameTypeAs(other) || this.isSuperTypeOf(other); } isSameTypeAs(other) { return (other instanceof ArrayType && this.elementType.isSameTypeAs(other.elementType)); } isSubTypeOf(other) { if (other instanceof ArrayType) { return this.elementType.isSubTypeOf(other.elementType); } else if (other instanceof TupleType) { for (const t of other.getTypes()) { if (!this.elementType.isSubTypeOf(t)) { return false; } } return true; } return false; } isSuperTypeOf(other) { if (other instanceof ArrayType) { return this.elementType.isSuperTypeOf(other.elementType); } else if (other instanceof TupleType) { for (const t of other.getTypes()) { let found = false; if (!this.elementType.isSuperTypeOf(t)) { found = true; } if (!found) return false; } return true; } return false; } overlapsWith(other) { if (other instanceof ArrayType) { return this.elementType.overlapsWith(other.elementType); } else if (other instanceof TupleType) { for (const t of other.getTypes()) { if (!this.elementType.overlapsWith(t)) { return false; } } return true; } return false; } } //# sourceMappingURL=ArrayType.js.map