UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

23 lines (22 loc) 907 B
import { FuncArgBase } from "./FuncArgBase.js"; import { ExprEvalTypeErrorObj, } from "../../ExprEvalResult.js"; import { ExprKind } from "../../ExprKind.js"; import { Decimal } from "decimal.js"; import { Type } from "../../../type/Types.js"; export class FuncArgNumeric extends FuncArgBase { constructor(required, name, defaultValue) { super(required, name, defaultValue); } getType() { return Type.NUMERIC; } transformForTypeCheck(callingExpr, invocationValue) { const result = invocationValue.result; const value = result.getValue(); if (Decimal.isDecimal(value)) { return invocationValue; } return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be a number, but was ${JSON.stringify(value)}`, value, callingExpr.getTextSpan()); } } //# sourceMappingURL=FuncArgNumeric.js.map