UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

27 lines (26 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FuncArgNumeric = void 0; const FuncArgBase_js_1 = require("./FuncArgBase.js"); const ExprEvalResult_js_1 = require("../../ExprEvalResult.js"); const ExprKind_js_1 = require("../../ExprKind.js"); const decimal_js_1 = require("decimal.js"); const Types_js_1 = require("../../../type/Types.js"); class FuncArgNumeric extends FuncArgBase_js_1.FuncArgBase { constructor(required, name, defaultValue) { super(required, name, defaultValue); } getType() { return Types_js_1.Type.NUMERIC; } transformForTypeCheck(callingExpr, invocationValue) { const result = invocationValue.result; const value = result.getValue(); if (decimal_js_1.Decimal.isDecimal(value)) { return invocationValue; } return new ExprEvalResult_js_1.ExprEvalTypeErrorObj(ExprKind_js_1.ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be a number, but was ${JSON.stringify(value)}`, value, callingExpr.getTextSpan()); } } exports.FuncArgNumeric = FuncArgNumeric; //# sourceMappingURL=FuncArgNumeric.js.map