UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

30 lines (29 loc) 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FuncArgInt = void 0; const FuncArgBase_js_1 = require("./FuncArgBase.js"); const ExprEvalResult_js_1 = require("../../ExprEvalResult.js"); const ExprKind_js_1 = require("../../ExprKind.js"); const NumericValue_js_1 = require("../../../value/NumericValue.js"); const Types_js_1 = require("../../../type/Types.js"); class FuncArgInt 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; if (!NumericValue_js_1.NumericValue.isNumericValueType(result)) { return new ExprEvalResult_js_1.ExprEvalTypeErrorObj(ExprKind_js_1.ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be a NumericValue, but was ${result}`, result, callingExpr.getTextSpan()); } const value = result.numericValue; if (value.isInteger()) { return invocationValue; } return new ExprEvalResult_js_1.ExprEvalTypeErrorObj(ExprKind_js_1.ExprKind.FUNCTION_ARGUMENTS, `Value of argument ${this.name} must be an integer, but was ${value}`, value, callingExpr.getTextSpan()); } } exports.FuncArgInt = FuncArgInt; //# sourceMappingURL=FuncArgInt.js.map