ifc-expressions
Version:
Parsing and evaluation of IFC expressions
41 lines (40 loc) • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FuncArgBase = void 0;
const FuncArg_js_1 = require("../FuncArg.js");
const ExprEvalResult_js_1 = require("../../ExprEvalResult.js");
const IfcExpression_js_1 = require("../../../IfcExpression.js");
class FuncArgBase extends FuncArg_js_1.FuncArg {
constructor(required, name, defaultValue) {
super(required, name, defaultValue);
}
transformValue(callingExpr, invocationValue) {
if ((0, ExprEvalResult_js_1.isExprEvalSuccess)(invocationValue)) {
return this.errorIfNullish(this.transformForTypeCheck(callingExpr, invocationValue), callingExpr);
}
return this.errorIfNullish(this.transformForError(callingExpr, invocationValue), callingExpr);
}
errorIfNullish(result, callingExpr) {
if ((0, IfcExpression_js_1.isNullish)(result)) {
return new ExprEvalResult_js_1.ExprEvalTypeErrorObj(IfcExpression_js_1.ExprKind.FUNCTION_ARGUMENTS, `Cannot obtain value of argument ${this.name}`, callingExpr.getTextSpan());
}
return result;
}
/**
* Override to type-check the successfully evaluated invocationValue.
* @protected
*/
transformForTypeCheck(callingExpr, invocationValue) {
return invocationValue;
}
/**
* Override to transform the error result obtained from evaluating the invocation value.
* @param invocationValue
* @protected
*/
transformForError(callingExpr, invocationValue) {
return invocationValue;
}
}
exports.FuncArgBase = FuncArgBase;
//# sourceMappingURL=FuncArgBase.js.map