UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

23 lines (22 loc) 998 B
import { FuncArgBase } from "./FuncArgBase.js"; import { ExprEvalTypeErrorObj, } from "../../ExprEvalResult.js"; import { ExprKind } from "../../ExprKind.js"; import { Type, Types } from "../../../type/Types.js"; import { LogicalValue } from "../../../value/LogicalValue.js"; export class FuncArgLogicalOrBoolean extends FuncArgBase { constructor(required, name, defaultValue) { super(required, name, defaultValue); } getType() { return Types.or(Type.BOOLEAN, Type.LOGICAL); } transformForTypeCheck(callingExpr, invocationValue) { const result = invocationValue.result; const value = result.getValue(); if (LogicalValue.isLogical(value)) { return invocationValue; } return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be a boolean or logical, but was ${JSON.stringify(value)}`, value, callingExpr.getTextSpan()); } } //# sourceMappingURL=FuncArgLogicalOrBoolean.js.map