ifc-expressions
Version:
Parsing and evaluation of IFC expressions
30 lines (29 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BuiltinRootReferenceExpr = void 0;
const Expr0_js_1 = require("../Expr0.js");
const ExprKind_js_1 = require("../ExprKind.js");
const ExprEvalResult_js_1 = require("../ExprEvalResult.js");
const BuiltinRuntimeValueConverter_js_1 = require("../../builtin/BuiltinRuntimeValueConverter.js");
class BuiltinRootReferenceExpr extends Expr0_js_1.Expr0 {
constructor(name, type) {
super(ExprKind_js_1.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 ExprEvalResult_js_1.ExprEvalErrorObj(this.getKind(), ExprEvalResult_js_1.ExprEvalStatus.NOT_FOUND, `No builtin variable found with name '$${this.name}'`, this.getTextSpan());
}
return (0, BuiltinRuntimeValueConverter_js_1.toExpressionValue)(value, this.type);
}
buildExprString(builder) {
builder.appendString(`$${this.name}`);
}
getType() {
return this.type;
}
}
exports.BuiltinRootReferenceExpr = BuiltinRootReferenceExpr;
//# sourceMappingURL=BuiltinRootReferenceExpr.js.map