UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

70 lines (69 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ArrayType = void 0; const TupleType_js_1 = require("./TupleType.js"); 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_js_1.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_js_1.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_js_1.TupleType) { for (const t of other.getTypes()) { if (!this.elementType.overlapsWith(t)) { return false; } } return true; } return false; } } exports.ArrayType = ArrayType; //# sourceMappingURL=ArrayType.js.map