UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

25 lines (24 loc) 1.1 kB
import { ExprEvalTypeErrorObj, } from "../../ExprEvalResult.js"; import { ExprKind } from "../../ExprKind.js"; import { FuncArgNumeric } from "./FuncArgNumeric.js"; import { NumericValue } from "../../../value/NumericValue.js"; import { Type, Types } from "../../../type/Types.js"; export class FuncArgIfcTimeStampNumeric extends FuncArgNumeric { constructor(required, name, defaultValue) { super(required, name, defaultValue); } getType() { return Types.or(Type.NUMERIC); } transformForTypeCheck(callingExpr, invocationValue) { const result = invocationValue.result; if (result instanceof NumericValue) { const value = result.getValue(); if (value.isInteger()) { return invocationValue; } } return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be an integer or an IfcDateTimeValue, but was ${JSON.stringify(result.getValue())}`, result.getValue(), callingExpr.getTextSpan()); } } //# sourceMappingURL=FuncArgIfcTimeStampNumeric.js.map