ifc-expressions
Version:
Parsing and evaluation of IFC expressions
25 lines (24 loc) • 1.02 kB
JavaScript
import { FuncArgBase } from "./FuncArgBase.js";
import { ExprEvalSuccessObj, ExprEvalTypeErrorObj, } from "../../ExprEvalResult.js";
import { ExprKind } from "../../ExprKind.js";
import { StringValue } from "../../../value/StringValue.js";
import { Type } from "../../../type/Types.js";
export class FuncArgRegex extends FuncArgBase {
constructor(required, name, defaultValue) {
super(required, name, defaultValue);
}
getType() {
return Type.STRING;
}
transformForTypeCheck(callingExpr, invocationValue) {
const result = invocationValue.result;
if (result instanceof StringValue) {
return this.toRegexString(result);
}
return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be a string, but was ${JSON.stringify(result)}`, result, callingExpr.getTextSpan());
}
toRegexString(patternString) {
return new ExprEvalSuccessObj(patternString);
}
}
//# sourceMappingURL=FuncArgRegex.js.map