UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

27 lines (26 loc) 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FuncArgLogicalOrBoolean = 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"); const LogicalValue_js_1 = require("../../../value/LogicalValue.js"); class FuncArgLogicalOrBoolean extends FuncArgBase_js_1.FuncArgBase { constructor(required, name, defaultValue) { super(required, name, defaultValue); } getType() { return Types_js_1.Types.or(Types_js_1.Type.BOOLEAN, Types_js_1.Type.LOGICAL); } transformForTypeCheck(callingExpr, invocationValue) { const result = invocationValue.result; const value = result.getValue(); if (LogicalValue_js_1.LogicalValue.isLogical(value)) { return invocationValue; } return new ExprEvalResult_js_1.ExprEvalTypeErrorObj(ExprKind_js_1.ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be a boolean or logical, but was ${JSON.stringify(value)}`, value, callingExpr.getTextSpan()); } } exports.FuncArgLogicalOrBoolean = FuncArgLogicalOrBoolean; //# sourceMappingURL=FuncArgLogicalOrBoolean.js.map