UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

27 lines (26 loc) 1.17 kB
import { FuncArgString } from "./FuncArgString.js"; import { ExprEvalTypeErrorObj, isExprEvalError, } from "../../ExprEvalResult.js"; import { ExprKind } from "../../ExprKind.js"; import { Type } from "../../../type/Types.js"; import { IfcDurationValue } from "../../../value/IfcDurationValue.js"; export class FuncArgIfcDurationString extends FuncArgString { constructor(required, name, defaultValue) { super(required, name, defaultValue); } getType() { return Type.STRING; } transformForTypeCheck(callingExpr, invocationValue) { const val = super.transformForTypeCheck(callingExpr, invocationValue); if (isExprEvalError(val)) { return val; } const stringValue = val.result.getValue(); if (!IfcDurationValue.isValidStringRepresentation(stringValue)) { return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} is an IfcDate of the form 'YYYY-MM-DD'.` + `The provided value, '${stringValue}' is not allowed. `, callingExpr.getTextSpan()); } return val; } } //# sourceMappingURL=FuncArgIfcDurationString.js.map