UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

19 lines (18 loc) 882 B
import { ValidationException } from "../error/ValidationException.js"; import { isNullish } from "../util/IfcExpressionUtils.js"; export class ExprManager { constructor() { this.contextToExpr = new Map(); } registerExprWithContext(expr, ctx) { const otherCtx = this.contextToExpr.get(expr); if (!isNullish(otherCtx) && otherCtx !== ctx) { throw new ValidationException(`Expression (of kind '${expr.getKind}') at line ${ctx.start.line}, column ${ctx.start.start} is already associated with a ParserRuleContext of type ${otherCtx.constructor.name}' cannot associate it with another one (${ctx.constructor.name} at ${ctx.start.line}:${ctx.start.start}')`, ctx); } this.contextToExpr.set(expr, ctx); } getContext(expr) { return this.contextToExpr.get(expr); } } //# sourceMappingURL=ExprManager.js.map