ifc-expressions
Version:
Parsing and evaluation of IFC expressions
42 lines (41 loc) • 1.28 kB
JavaScript
export class ContextObjectType {
constructor(name, baseType, members) {
this.name = name;
this.baseType = baseType;
this.members = members;
}
static fromBuiltinDefinition(definition) {
return new ContextObjectType(definition.name, definition.type, definition.members);
}
getMemberDefinition(name) {
return this.members.get(name?.replace(/^\$/, "").toUpperCase());
}
getMemberDefinitions() {
return [...this.members.values()];
}
getName() {
return this.name;
}
isSuperTypeOf(other) {
return other.isSubTypeOf(this);
}
isSameTypeAs(other) {
return this === other || other.getName() === this.getName();
}
isSubTypeOf(other) {
return (this.baseType.isSameTypeAs(other) || this.baseType.isSubTypeOf(other));
}
overlapsWith(other) {
if (this.isSameTypeAs(other)) {
return true;
}
if (other instanceof ContextObjectType) {
return this.baseType.overlapsWith(other.baseType);
}
return this.baseType.overlapsWith(other);
}
isAssignableFrom(other) {
return this.isSameTypeAs(other) || this.isSuperTypeOf(other);
}
}
//# sourceMappingURL=ContextObjectType.js.map