ifc-expressions
Version:
Parsing and evaluation of IFC expressions
31 lines (30 loc) • 1.38 kB
JavaScript
import { StringValue } from "../../../value/StringValue.js";
import { ExprEvalTypeErrorObj, isExprEvalError, } from "../../ExprEvalResult.js";
import { ExprKind } from "../../ExprKind.js";
import { Type, Types } from "../../../type/Types.js";
import { IfcTimeValue } from "../../../value/IfcTimeValue.js";
import { FuncArgBase } from "./FuncArgBase.js";
export class FuncArgIfcTimeString extends FuncArgBase {
constructor(required, name, defaultValue) {
super(required, name, defaultValue);
}
getType() {
return Types.or(Type.STRING);
}
transformForTypeCheck(callingExpr, invocationValue) {
const val = super.transformForTypeCheck(callingExpr, invocationValue);
if (isExprEvalError(val)) {
return val;
}
if (val.result instanceof StringValue) {
const stringValue = val.result.getValue();
if (!IfcTimeValue.isValidStringRepresentation(stringValue)) {
return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} is an IfcTime of the form 'HH:MM:SS.sss...'.` +
`a trailing time zone specification is allowed.` +
`The provided value, '${stringValue}' is not allowed. `, callingExpr.getTextSpan());
}
return val;
}
}
}
//# sourceMappingURL=FuncArgIfcTimeString.js.map