ifc-expressions
Version:
Parsing and evaluation of IFC expressions
25 lines (24 loc) • 1.03 kB
JavaScript
import { Func } from "../Func.js";
import { ExprEvalSuccessObj } from "../../ExprEvalResult.js";
import { Types } from "../../../type/Types.js";
import { FuncArgLogicalOrBoolean } from "../arg/FuncArgLogicalOrBoolean.js";
export class FuncBooleanBinary extends Func {
constructor(name, methodName) {
super(name, [
new FuncArgLogicalOrBoolean(true, FuncBooleanBinary.KEY_LEFT),
new FuncArgLogicalOrBoolean(true, FuncBooleanBinary.KEY_RIGHT),
]);
this.methodName = methodName;
}
getReturnType(argumentTypes) {
return Types.or(...argumentTypes);
}
calculateResult(callingExpr, evaluatedArguments) {
const left = evaluatedArguments.get(FuncBooleanBinary.KEY_LEFT);
const right = evaluatedArguments.get(FuncBooleanBinary.KEY_RIGHT);
return new ExprEvalSuccessObj(left[this.methodName].call(left, right));
}
}
FuncBooleanBinary.KEY_LEFT = "left";
FuncBooleanBinary.KEY_RIGHT = "right";
//# sourceMappingURL=FuncBooleanBinary.js.map