ifc-expressions
Version:
Parsing and evaluation of IFC expressions
26 lines (25 loc) • 988 B
JavaScript
import { Expr0 } from "../Expr0.js";
import { ExprKind } from "../ExprKind.js";
import { ExprEvalErrorObj, ExprEvalStatus } from "../ExprEvalResult.js";
import { toExpressionValue } from "../../builtin/BuiltinRuntimeValueConverter.js";
export class BuiltinRootReferenceExpr extends Expr0 {
constructor(name, type) {
super(ExprKind.REF_BUILTIN_ROOT);
this.name = name.replace(/^\$/, "");
this.type = type;
}
doEvaluate(ctx) {
const value = ctx.resolveBuiltinVariable(this.name);
if (value === undefined || value === null) {
return new ExprEvalErrorObj(this.getKind(), ExprEvalStatus.NOT_FOUND, `No builtin variable found with name '$${this.name}'`, this.getTextSpan());
}
return toExpressionValue(value, this.type);
}
buildExprString(builder) {
builder.appendString(`$${this.name}`);
}
getType() {
return this.type;
}
}
//# sourceMappingURL=BuiltinRootReferenceExpr.js.map