UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

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