UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

28 lines (27 loc) 1.37 kB
import { FuncArgBase } from "./FuncArgBase.js"; import { ExprEvalTypeErrorObj, } from "../../ExprEvalResult.js"; import { ExprKind } from "../../ExprKind.js"; import { isObjectAccessor } from "../../../context/ObjectAccessor.js"; import { Type } from "../../../type/Types.js"; import { IfcExpressionFunctionConfigException } from "../../../error/IfcExpressionFunctionConfigException.js"; export class FuncArgObjectAccessor extends FuncArgBase { constructor(required, name, specificType, defaultValue) { super(required, name, defaultValue); if (!Type.IFC_OBJECT_REF.isAssignableFrom(specificType)) { throw new IfcExpressionFunctionConfigException(`${Type.IFC_OBJECT_REF.getName()} is not assignable from provided object accessor type ${specificType.getName()}`); } this.type = specificType; } getType() { return this.type; } transformForTypeCheck(callingExpr, invocationValue) { const result = invocationValue.result; const value = result.getValue(); if (isObjectAccessor(value)) { return invocationValue; } return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be an ObjectAccessor, but was ${JSON.stringify(value)}`, value, callingExpr.getTextSpan()); } } //# sourceMappingURL=FuncArgObjectAccessor.js.map