UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

43 lines (42 loc) 1.25 kB
import { isNullish } from "../util/IfcExpressionUtils.js"; import { Type } from "./Types.js"; import { TypeDisjunction } from "./TypeDisjunction.js"; export class SimpleType { constructor(name, superType = Type.ANY) { this.superType = superType; this.name = name; } getName() { return this.name; } isSameTypeAs(other) { return this === other || other.getName() === this.getName(); } isSuperTypeOf(other) { return other.isSubTypeOf(this); } isSubTypeOf(other) { if (other instanceof TypeDisjunction) { return other.isSuperTypeOf(this); } if (isNullish(this.superType)) { return false; } if (this.superType.isSameTypeAs(other)) { return true; } if (this.superType.isSameTypeAs(Type.ANY)) { return false; } return this.superType.isSubTypeOf(other); } overlapsWith(other) { return (this.isSameTypeAs(other) || this.isSuperTypeOf(other) || this.isSubTypeOf(other)); } isAssignableFrom(other) { return this.isSameTypeAs(other) || this.isSuperTypeOf(other); } } //# sourceMappingURL=SimpleType.js.map