ifc-expressions
Version:
Parsing and evaluation of IFC expressions
22 lines (21 loc) • 872 B
JavaScript
import { FuncArgBase } from "./FuncArgBase.js";
import { ExprEvalTypeErrorObj, } from "../../ExprEvalResult.js";
import { ExprKind } from "../../ExprKind.js";
import { Type } from "../../../type/Types.js";
export class FuncArgBoolean extends FuncArgBase {
constructor(required, name, defaultValue) {
super(required, name, defaultValue);
}
getType() {
return Type.BOOLEAN;
}
transformForTypeCheck(callingExpr, invocationValue) {
const result = invocationValue.result;
const value = result.getValue();
if (typeof value === "boolean") {
return invocationValue;
}
return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be a boolean, but was ${JSON.stringify(value)}`, value, callingExpr.getTextSpan());
}
}
//# sourceMappingURL=FuncArgBoolean.js.map