ifc-expressions 2.3.0 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +255 -30
- package/dist/IfcExpression.d.ts +24 -26
- package/dist/IfcExpressionErrorListener.d.ts +3 -3
- package/dist/IfcExpressionOptions.d.ts +4 -0
- package/dist/autocomplete/CompletionItem.d.ts +24 -0
- package/dist/autocomplete/IfcExpressionAutocomplete.d.ts +11 -0
- package/dist/builtin/BuiltinRuntimeValueConverter.d.ts +7 -0
- package/dist/builtin/BuiltinVariableRegistry.d.ts +50 -0
- package/dist/cjs/IfcExpression.js +112 -37
- package/dist/cjs/IfcExpression.js.map +1 -1
- package/dist/cjs/IfcExpressionErrorListener.js +3 -8
- package/dist/cjs/IfcExpressionErrorListener.js.map +1 -1
- package/dist/cjs/IfcExpressionOptions.js +3 -0
- package/dist/cjs/IfcExpressionOptions.js.map +1 -0
- package/dist/cjs/autocomplete/CompletionItem.js +3 -0
- package/dist/cjs/autocomplete/CompletionItem.js.map +1 -0
- package/dist/cjs/autocomplete/IfcExpressionAutocomplete.js +654 -0
- package/dist/cjs/autocomplete/IfcExpressionAutocomplete.js.map +1 -0
- package/dist/cjs/builtin/BuiltinRuntimeValueConverter.js +124 -0
- package/dist/cjs/builtin/BuiltinRuntimeValueConverter.js.map +1 -0
- package/dist/cjs/builtin/BuiltinVariableRegistry.js +405 -0
- package/dist/cjs/builtin/BuiltinVariableRegistry.js.map +1 -0
- package/dist/cjs/compiler/ExprCompiler.js +44 -41
- package/dist/cjs/compiler/ExprCompiler.js.map +1 -1
- package/dist/cjs/compiler/ExprManager.js.map +1 -1
- package/dist/cjs/compiler/IfcExpressionValidationListener.js +85 -25
- package/dist/cjs/compiler/IfcExpressionValidationListener.js.map +1 -1
- package/dist/cjs/compiler/TypeManager.js.map +1 -1
- package/dist/cjs/context/IfcExpressionContext.js.map +1 -1
- package/dist/cjs/context/NopContext.js +3 -0
- package/dist/cjs/context/NopContext.js.map +1 -1
- package/dist/cjs/documentation/Documentation.js +11 -0
- package/dist/cjs/documentation/Documentation.js.map +1 -0
- package/dist/cjs/error/ExpressionTypeError.js.map +1 -1
- package/dist/cjs/error/IfcExpressionBuiltinConfigException.js +10 -0
- package/dist/cjs/error/IfcExpressionBuiltinConfigException.js.map +1 -0
- package/dist/cjs/error/InvalidSyntaxException.js.map +1 -1
- package/dist/cjs/error/NoSuchFunctionException.js.map +1 -1
- package/dist/cjs/error/NoSuchMemberException.js +13 -0
- package/dist/cjs/error/NoSuchMemberException.js.map +1 -0
- package/dist/cjs/error/ValidationException.js.map +1 -1
- package/dist/cjs/error/WrongFunctionArgumentTypeException.js.map +1 -1
- package/dist/cjs/expression/ExprKind.js +3 -0
- package/dist/cjs/expression/ExprKind.js.map +1 -1
- package/dist/cjs/expression/function/Func.js +18 -14
- package/dist/cjs/expression/function/Func.js.map +1 -1
- package/dist/cjs/expression/function/FuncArg.js +11 -5
- package/dist/cjs/expression/function/FuncArg.js.map +1 -1
- package/dist/cjs/expression/function/IfcExpressionFunctions.js +198 -42
- package/dist/cjs/expression/function/IfcExpressionFunctions.js.map +1 -1
- package/dist/cjs/expression/function/impl/CHOOSE.js.map +1 -1
- package/dist/cjs/expression/function/impl/IF.js.map +1 -1
- package/dist/cjs/expression/function/impl/MAP.js.map +1 -1
- package/dist/cjs/expression/function/impl/ReplacePattern.js +20 -2
- package/dist/cjs/expression/function/impl/ReplacePattern.js.map +1 -1
- package/dist/cjs/expression/reference/BuiltinFunctionCallExpr.js +59 -0
- package/dist/cjs/expression/reference/BuiltinFunctionCallExpr.js.map +1 -0
- package/dist/cjs/expression/reference/BuiltinPropertyAccessExpr.js +34 -0
- package/dist/cjs/expression/reference/BuiltinPropertyAccessExpr.js.map +1 -0
- package/dist/cjs/expression/reference/BuiltinRootReferenceExpr.js +29 -0
- package/dist/cjs/expression/reference/BuiltinRootReferenceExpr.js.map +1 -0
- package/dist/cjs/gen/parser/IfcExpressionLexer.js +126 -104
- package/dist/cjs/gen/parser/IfcExpressionLexer.js.map +1 -1
- package/dist/cjs/gen/parser/IfcExpressionListener.js +7 -4
- package/dist/cjs/gen/parser/IfcExpressionListener.js.map +1 -1
- package/dist/cjs/gen/parser/IfcExpressionParser.js +739 -682
- package/dist/cjs/gen/parser/IfcExpressionParser.js.map +1 -1
- package/dist/cjs/gen/parser/IfcExpressionVisitor.js +4 -4
- package/dist/cjs/gen/parser/IfcExpressionVisitor.js.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/type/ContextObjectType.js +45 -0
- package/dist/cjs/type/ContextObjectType.js.map +1 -0
- package/dist/cjs/type/Types.js +4 -6
- package/dist/cjs/type/Types.js.map +1 -1
- package/dist/cjs/value/ContextObjectValue.js +23 -0
- package/dist/cjs/value/ContextObjectValue.js.map +1 -0
- package/dist/cjs/value/ExpressionValue.js.map +1 -1
- package/dist/cjs/value/Value.js.map +1 -1
- package/dist/compiler/ExprCompiler.d.ts +8 -3
- package/dist/compiler/ExprManager.d.ts +1 -1
- package/dist/compiler/IfcExpressionValidationListener.d.ts +9 -3
- package/dist/compiler/TypeManager.d.ts +1 -1
- package/dist/context/IfcExpressionContext.d.ts +3 -4
- package/dist/context/NopContext.d.ts +1 -0
- package/dist/documentation/Documentation.d.ts +12 -0
- package/dist/error/ExpressionTypeError.d.ts +1 -1
- package/dist/error/IfcExpressionBuiltinConfigException.d.ts +3 -0
- package/dist/error/InvalidSyntaxException.d.ts +1 -1
- package/dist/error/NoSuchFunctionException.d.ts +1 -1
- package/dist/error/NoSuchMemberException.d.ts +6 -0
- package/dist/error/ValidationException.d.ts +1 -1
- package/dist/error/WrongFunctionArgumentTypeException.d.ts +1 -1
- package/dist/expression/ExprKind.d.ts +3 -0
- package/dist/expression/function/Func.d.ts +7 -21
- package/dist/expression/function/FuncArg.d.ts +6 -5
- package/dist/expression/function/IfcExpressionFunctions.d.ts +1 -0
- package/dist/expression/function/impl/CHOOSE.d.ts +1 -1
- package/dist/expression/function/impl/IF.d.ts +1 -1
- package/dist/expression/function/impl/MAP.d.ts +1 -1
- package/dist/expression/reference/BuiltinFunctionCallExpr.d.ts +19 -0
- package/dist/expression/reference/BuiltinPropertyAccessExpr.d.ts +15 -0
- package/dist/expression/reference/BuiltinRootReferenceExpr.d.ts +14 -0
- package/dist/gen/parser/IfcExpressionLexer.d.ts +9 -8
- package/dist/gen/parser/IfcExpressionListener.d.ts +89 -59
- package/dist/gen/parser/IfcExpressionParser.d.ts +192 -169
- package/dist/gen/parser/IfcExpressionVisitor.d.ts +51 -35
- package/dist/index.d.ts +2 -2
- package/dist/mjs/IfcExpression.js +104 -32
- package/dist/mjs/IfcExpression.js.map +1 -1
- package/dist/mjs/IfcExpressionErrorListener.js +3 -8
- package/dist/mjs/IfcExpressionErrorListener.js.map +1 -1
- package/dist/mjs/IfcExpressionOptions.js +2 -0
- package/dist/mjs/IfcExpressionOptions.js.map +1 -0
- package/dist/mjs/autocomplete/CompletionItem.js +2 -0
- package/dist/mjs/autocomplete/CompletionItem.js.map +1 -0
- package/dist/mjs/autocomplete/IfcExpressionAutocomplete.js +650 -0
- package/dist/mjs/autocomplete/IfcExpressionAutocomplete.js.map +1 -0
- package/dist/mjs/builtin/BuiltinRuntimeValueConverter.js +117 -0
- package/dist/mjs/builtin/BuiltinRuntimeValueConverter.js.map +1 -0
- package/dist/mjs/builtin/BuiltinVariableRegistry.js +399 -0
- package/dist/mjs/builtin/BuiltinVariableRegistry.js.map +1 -0
- package/dist/mjs/compiler/ExprCompiler.js +43 -40
- package/dist/mjs/compiler/ExprCompiler.js.map +1 -1
- package/dist/mjs/compiler/ExprManager.js.map +1 -1
- package/dist/mjs/compiler/IfcExpressionValidationListener.js +85 -22
- package/dist/mjs/compiler/IfcExpressionValidationListener.js.map +1 -1
- package/dist/mjs/compiler/TypeManager.js.map +1 -1
- package/dist/mjs/context/IfcExpressionContext.js.map +1 -1
- package/dist/mjs/context/NopContext.js +3 -0
- package/dist/mjs/context/NopContext.js.map +1 -1
- package/dist/mjs/documentation/Documentation.js +7 -0
- package/dist/mjs/documentation/Documentation.js.map +1 -0
- package/dist/mjs/error/ExpressionTypeError.js.map +1 -1
- package/dist/mjs/error/IfcExpressionBuiltinConfigException.js +6 -0
- package/dist/mjs/error/IfcExpressionBuiltinConfigException.js.map +1 -0
- package/dist/mjs/error/InvalidSyntaxException.js.map +1 -1
- package/dist/mjs/error/NoSuchFunctionException.js.map +1 -1
- package/dist/mjs/error/NoSuchMemberException.js +9 -0
- package/dist/mjs/error/NoSuchMemberException.js.map +1 -0
- package/dist/mjs/error/ValidationException.js.map +1 -1
- package/dist/mjs/error/WrongFunctionArgumentTypeException.js.map +1 -1
- package/dist/mjs/expression/ExprKind.js +3 -0
- package/dist/mjs/expression/ExprKind.js.map +1 -1
- package/dist/mjs/expression/function/Func.js +18 -14
- package/dist/mjs/expression/function/Func.js.map +1 -1
- package/dist/mjs/expression/function/FuncArg.js +11 -5
- package/dist/mjs/expression/function/FuncArg.js.map +1 -1
- package/dist/mjs/expression/function/IfcExpressionFunctions.js +198 -42
- package/dist/mjs/expression/function/IfcExpressionFunctions.js.map +1 -1
- package/dist/mjs/expression/function/impl/CHOOSE.js.map +1 -1
- package/dist/mjs/expression/function/impl/IF.js.map +1 -1
- package/dist/mjs/expression/function/impl/MAP.js.map +1 -1
- package/dist/mjs/expression/function/impl/ReplacePattern.js +20 -2
- package/dist/mjs/expression/function/impl/ReplacePattern.js.map +1 -1
- package/dist/mjs/expression/reference/BuiltinFunctionCallExpr.js +55 -0
- package/dist/mjs/expression/reference/BuiltinFunctionCallExpr.js.map +1 -0
- package/dist/mjs/expression/reference/BuiltinPropertyAccessExpr.js +30 -0
- package/dist/mjs/expression/reference/BuiltinPropertyAccessExpr.js.map +1 -0
- package/dist/mjs/expression/reference/BuiltinRootReferenceExpr.js +25 -0
- package/dist/mjs/expression/reference/BuiltinRootReferenceExpr.js.map +1 -0
- package/dist/mjs/gen/parser/IfcExpressionLexer.js +101 -104
- package/dist/mjs/gen/parser/IfcExpressionLexer.js.map +1 -1
- package/dist/mjs/gen/parser/IfcExpressionListener.js +5 -3
- package/dist/mjs/gen/parser/IfcExpressionListener.js.map +1 -1
- package/dist/mjs/gen/parser/IfcExpressionParser.js +700 -670
- package/dist/mjs/gen/parser/IfcExpressionParser.js.map +1 -1
- package/dist/mjs/gen/parser/IfcExpressionVisitor.js +2 -3
- package/dist/mjs/gen/parser/IfcExpressionVisitor.js.map +1 -1
- package/dist/mjs/index.js +1 -1
- package/dist/mjs/index.js.map +1 -1
- package/dist/mjs/type/ContextObjectType.js +41 -0
- package/dist/mjs/type/ContextObjectType.js.map +1 -0
- package/dist/mjs/type/Types.js +4 -6
- package/dist/mjs/type/Types.js.map +1 -1
- package/dist/mjs/value/ContextObjectValue.js +19 -0
- package/dist/mjs/value/ContextObjectValue.js.map +1 -0
- package/dist/mjs/value/ExpressionValue.js.map +1 -1
- package/dist/mjs/value/Value.js.map +1 -1
- package/dist/type/ContextObjectType.d.ts +17 -0
- package/dist/type/Types.d.ts +2 -6
- package/dist/value/ContextObjectValue.d.ts +11 -0
- package/dist/value/ExpressionValue.d.ts +2 -1
- package/dist/value/Value.d.ts +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuiltinVariableRegistry = exports.isBuiltinFunctionDefinition = exports.isBuiltinPropertyDefinition = void 0;
|
|
4
|
+
const ContextObjectType_js_1 = require("../type/ContextObjectType.js");
|
|
5
|
+
const IfcExpressionBuiltinConfigException_js_1 = require("../error/IfcExpressionBuiltinConfigException.js");
|
|
6
|
+
const Types_js_1 = require("../type/Types.js");
|
|
7
|
+
const BuiltinRootReferenceExpr_js_1 = require("../expression/reference/BuiltinRootReferenceExpr.js");
|
|
8
|
+
const ElemObjectReferenceExpr_js_1 = require("../expression/reference/ElemObjectReferenceExpr.js");
|
|
9
|
+
const PropObjectReferenceExpr_js_1 = require("../expression/reference/PropObjectReferenceExpr.js");
|
|
10
|
+
function isBuiltinPropertyDefinition(definition) {
|
|
11
|
+
return definition?.kind === "property";
|
|
12
|
+
}
|
|
13
|
+
exports.isBuiltinPropertyDefinition = isBuiltinPropertyDefinition;
|
|
14
|
+
function isBuiltinFunctionDefinition(definition) {
|
|
15
|
+
return definition?.kind === "function";
|
|
16
|
+
}
|
|
17
|
+
exports.isBuiltinFunctionDefinition = isBuiltinFunctionDefinition;
|
|
18
|
+
function normalizeBuiltinName(name) {
|
|
19
|
+
return name?.replace(/^\$/, "").toUpperCase();
|
|
20
|
+
}
|
|
21
|
+
function memberArg(labelKey, labelFallback, summaryKey, summaryFallback) {
|
|
22
|
+
return {
|
|
23
|
+
label: { key: labelKey, fallback: labelFallback },
|
|
24
|
+
documentation: { key: summaryKey, fallback: summaryFallback },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createStandardIfcObjectTypes() {
|
|
28
|
+
const elementMembers = new Map();
|
|
29
|
+
const propertyMembers = new Map();
|
|
30
|
+
const propertySetMembers = new Map();
|
|
31
|
+
const typeObjectMembers = new Map();
|
|
32
|
+
const propertyType = new ContextObjectType_js_1.ContextObjectType(Types_js_1.Type.IFC_PROPERTY_REF.getName(), Types_js_1.Type.IFC_PROPERTY_REF, propertyMembers);
|
|
33
|
+
const propertySetType = new ContextObjectType_js_1.ContextObjectType(Types_js_1.Type.IFC_PROPERTY_SET_REF.getName(), Types_js_1.Type.IFC_PROPERTY_SET_REF, propertySetMembers);
|
|
34
|
+
const typeObjectType = new ContextObjectType_js_1.ContextObjectType(Types_js_1.Type.IFC_TYPE_OBJECT_REF.getName(), Types_js_1.Type.IFC_TYPE_OBJECT_REF, typeObjectMembers);
|
|
35
|
+
const elementType = new ContextObjectType_js_1.ContextObjectType(Types_js_1.Type.IFC_ELEMENT_REF.getName(), Types_js_1.Type.IFC_ELEMENT_REF, elementMembers);
|
|
36
|
+
standardIfcElementMembers({
|
|
37
|
+
elementType,
|
|
38
|
+
propertyType,
|
|
39
|
+
propertySetType,
|
|
40
|
+
typeObjectType,
|
|
41
|
+
}).forEach((member) => {
|
|
42
|
+
elementMembers.set(normalizeBuiltinName(member.name), member);
|
|
43
|
+
});
|
|
44
|
+
standardIfcPropertyMembers({
|
|
45
|
+
elementType,
|
|
46
|
+
propertyType,
|
|
47
|
+
propertySetType,
|
|
48
|
+
typeObjectType,
|
|
49
|
+
}).forEach((member) => {
|
|
50
|
+
propertyMembers.set(normalizeBuiltinName(member.name), member);
|
|
51
|
+
});
|
|
52
|
+
standardIfcPropertySetMembers({
|
|
53
|
+
elementType,
|
|
54
|
+
propertyType,
|
|
55
|
+
propertySetType,
|
|
56
|
+
typeObjectType,
|
|
57
|
+
}).forEach((member) => {
|
|
58
|
+
propertySetMembers.set(normalizeBuiltinName(member.name), member);
|
|
59
|
+
});
|
|
60
|
+
standardIfcTypeObjectMembers({
|
|
61
|
+
elementType,
|
|
62
|
+
propertyType,
|
|
63
|
+
propertySetType,
|
|
64
|
+
typeObjectType,
|
|
65
|
+
}).forEach((member) => {
|
|
66
|
+
typeObjectMembers.set(normalizeBuiltinName(member.name), member);
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
elementType,
|
|
70
|
+
propertyType,
|
|
71
|
+
propertySetType,
|
|
72
|
+
typeObjectType,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function standardIfcElementMembers(types) {
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
name: "name",
|
|
79
|
+
kind: "function",
|
|
80
|
+
returnType: Types_js_1.Type.STRING,
|
|
81
|
+
argumentTypes: [],
|
|
82
|
+
documentation: {
|
|
83
|
+
key: "builtin.$element.name.summary",
|
|
84
|
+
fallback: "name(): name of the current IFC element",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "guid",
|
|
89
|
+
kind: "function",
|
|
90
|
+
returnType: Types_js_1.Type.STRING,
|
|
91
|
+
argumentTypes: [],
|
|
92
|
+
documentation: {
|
|
93
|
+
key: "builtin.$element.guid.summary",
|
|
94
|
+
fallback: "guid(): globally unique identifier of the current IFC element",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "ifcClass",
|
|
99
|
+
kind: "function",
|
|
100
|
+
returnType: Types_js_1.Type.STRING,
|
|
101
|
+
argumentTypes: [],
|
|
102
|
+
documentation: {
|
|
103
|
+
key: "builtin.$element.ifcClass.summary",
|
|
104
|
+
fallback: "ifcClass(): IFC class name of the current element",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "description",
|
|
109
|
+
kind: "function",
|
|
110
|
+
returnType: Types_js_1.Type.STRING,
|
|
111
|
+
argumentTypes: [],
|
|
112
|
+
documentation: {
|
|
113
|
+
key: "builtin.$element.description.summary",
|
|
114
|
+
fallback: "description(): description of the current IFC element",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "property",
|
|
119
|
+
kind: "function",
|
|
120
|
+
returnType: types.propertyType,
|
|
121
|
+
argumentTypes: [Types_js_1.Type.STRING],
|
|
122
|
+
documentation: {
|
|
123
|
+
key: "builtin.$element.property.summary",
|
|
124
|
+
fallback: "property(name): property of the current IFC element by name",
|
|
125
|
+
},
|
|
126
|
+
argumentDocumentation: [
|
|
127
|
+
memberArg("builtin.$element.property.arg.name.label", "name", "builtin.$element.property.arg.name.summary", "The name of the property to resolve"),
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "propertySet",
|
|
132
|
+
kind: "function",
|
|
133
|
+
returnType: types.propertySetType,
|
|
134
|
+
argumentTypes: [Types_js_1.Type.STRING],
|
|
135
|
+
documentation: {
|
|
136
|
+
key: "builtin.$element.propertySet.summary",
|
|
137
|
+
fallback: "propertySet(name): property set of the current IFC element by name",
|
|
138
|
+
},
|
|
139
|
+
argumentDocumentation: [
|
|
140
|
+
memberArg("builtin.$element.propertySet.arg.name.label", "name", "builtin.$element.propertySet.arg.name.summary", "The name of the property set to resolve"),
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "type",
|
|
145
|
+
kind: "function",
|
|
146
|
+
returnType: types.typeObjectType,
|
|
147
|
+
argumentTypes: [],
|
|
148
|
+
documentation: {
|
|
149
|
+
key: "builtin.$element.type.summary",
|
|
150
|
+
fallback: "type(): type object of the current IFC element",
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
function standardIfcPropertyMembers(types) {
|
|
156
|
+
return [
|
|
157
|
+
{
|
|
158
|
+
name: "name",
|
|
159
|
+
kind: "function",
|
|
160
|
+
returnType: Types_js_1.Type.STRING,
|
|
161
|
+
argumentTypes: [],
|
|
162
|
+
documentation: {
|
|
163
|
+
key: "builtin.$property.name.summary",
|
|
164
|
+
fallback: "name(): name of the current IFC property",
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "ifcClass",
|
|
169
|
+
kind: "function",
|
|
170
|
+
returnType: Types_js_1.Type.STRING,
|
|
171
|
+
argumentTypes: [],
|
|
172
|
+
documentation: {
|
|
173
|
+
key: "builtin.$property.ifcClass.summary",
|
|
174
|
+
fallback: "ifcClass(): IFC class name of the current property",
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "description",
|
|
179
|
+
kind: "function",
|
|
180
|
+
returnType: Types_js_1.Type.STRING,
|
|
181
|
+
argumentTypes: [],
|
|
182
|
+
documentation: {
|
|
183
|
+
key: "builtin.$property.description.summary",
|
|
184
|
+
fallback: "description(): description of the current IFC property",
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: "propertySet",
|
|
189
|
+
kind: "function",
|
|
190
|
+
returnType: types.propertySetType,
|
|
191
|
+
argumentTypes: [],
|
|
192
|
+
documentation: {
|
|
193
|
+
key: "builtin.$property.propertySet.summary",
|
|
194
|
+
fallback: "propertySet(): property set containing the current IFC property",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "value",
|
|
199
|
+
kind: "function",
|
|
200
|
+
returnType: Types_js_1.Types.or(Types_js_1.Type.STRING, Types_js_1.Type.NUMERIC, Types_js_1.Type.BOOLEAN, Types_js_1.Type.ARRAY),
|
|
201
|
+
argumentTypes: [],
|
|
202
|
+
documentation: {
|
|
203
|
+
key: "builtin.$property.value.summary",
|
|
204
|
+
fallback: "value(): value of the current IFC property",
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
function standardIfcPropertySetMembers(types) {
|
|
210
|
+
return [
|
|
211
|
+
{
|
|
212
|
+
name: "name",
|
|
213
|
+
kind: "function",
|
|
214
|
+
returnType: Types_js_1.Type.STRING,
|
|
215
|
+
argumentTypes: [],
|
|
216
|
+
documentation: {
|
|
217
|
+
key: "builtin.$propertySet.name.summary",
|
|
218
|
+
fallback: "name(): name of the current IFC property set",
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "guid",
|
|
223
|
+
kind: "function",
|
|
224
|
+
returnType: Types_js_1.Type.STRING,
|
|
225
|
+
argumentTypes: [],
|
|
226
|
+
documentation: {
|
|
227
|
+
key: "builtin.$propertySet.guid.summary",
|
|
228
|
+
fallback: "guid(): globally unique identifier of the current IFC property set",
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "description",
|
|
233
|
+
kind: "function",
|
|
234
|
+
returnType: Types_js_1.Type.STRING,
|
|
235
|
+
argumentTypes: [],
|
|
236
|
+
documentation: {
|
|
237
|
+
key: "builtin.$propertySet.description.summary",
|
|
238
|
+
fallback: "description(): description of the current IFC property set",
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "property",
|
|
243
|
+
kind: "function",
|
|
244
|
+
returnType: types.propertyType,
|
|
245
|
+
argumentTypes: [Types_js_1.Type.STRING],
|
|
246
|
+
documentation: {
|
|
247
|
+
key: "builtin.$propertySet.property.summary",
|
|
248
|
+
fallback: "property(name): property of the current IFC property set by name",
|
|
249
|
+
},
|
|
250
|
+
argumentDocumentation: [
|
|
251
|
+
memberArg("builtin.$propertySet.property.arg.name.label", "name", "builtin.$propertySet.property.arg.name.summary", "The name of the property to resolve"),
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
function standardIfcTypeObjectMembers(types) {
|
|
257
|
+
return [
|
|
258
|
+
{
|
|
259
|
+
name: "name",
|
|
260
|
+
kind: "function",
|
|
261
|
+
returnType: Types_js_1.Type.STRING,
|
|
262
|
+
argumentTypes: [],
|
|
263
|
+
documentation: {
|
|
264
|
+
key: "builtin.$typeObject.name.summary",
|
|
265
|
+
fallback: "name(): name of the current IFC type object",
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: "guid",
|
|
270
|
+
kind: "function",
|
|
271
|
+
returnType: Types_js_1.Type.STRING,
|
|
272
|
+
argumentTypes: [],
|
|
273
|
+
documentation: {
|
|
274
|
+
key: "builtin.$typeObject.guid.summary",
|
|
275
|
+
fallback: "guid(): globally unique identifier of the current IFC type object",
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: "description",
|
|
280
|
+
kind: "function",
|
|
281
|
+
returnType: Types_js_1.Type.STRING,
|
|
282
|
+
argumentTypes: [],
|
|
283
|
+
documentation: {
|
|
284
|
+
key: "builtin.$typeObject.description.summary",
|
|
285
|
+
fallback: "description(): description of the current IFC type object",
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: "property",
|
|
290
|
+
kind: "function",
|
|
291
|
+
returnType: types.propertyType,
|
|
292
|
+
argumentTypes: [Types_js_1.Type.STRING],
|
|
293
|
+
documentation: {
|
|
294
|
+
key: "builtin.$typeObject.property.summary",
|
|
295
|
+
fallback: "property(name): property of the current IFC type object by name",
|
|
296
|
+
},
|
|
297
|
+
argumentDocumentation: [
|
|
298
|
+
memberArg("builtin.$typeObject.property.arg.name.label", "name", "builtin.$typeObject.property.arg.name.summary", "The name of the property to resolve"),
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "propertySet",
|
|
303
|
+
kind: "function",
|
|
304
|
+
returnType: types.propertySetType,
|
|
305
|
+
argumentTypes: [Types_js_1.Type.STRING],
|
|
306
|
+
documentation: {
|
|
307
|
+
key: "builtin.$typeObject.propertySet.summary",
|
|
308
|
+
fallback: "propertySet(name): property set of the current IFC type object by name",
|
|
309
|
+
},
|
|
310
|
+
argumentDocumentation: [
|
|
311
|
+
memberArg("builtin.$typeObject.propertySet.arg.name.label", "name", "builtin.$typeObject.propertySet.arg.name.summary", "The name of the property set to resolve"),
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
];
|
|
315
|
+
}
|
|
316
|
+
const standardIfcObjectTypes = createStandardIfcObjectTypes();
|
|
317
|
+
class BuiltinVariableRegistry {
|
|
318
|
+
constructor(definitions = []) {
|
|
319
|
+
this.builtinVariables = new Map();
|
|
320
|
+
definitions.forEach((definition) => this.register(definition));
|
|
321
|
+
}
|
|
322
|
+
static getDefaultRegistry() {
|
|
323
|
+
return this.defaultRegistry;
|
|
324
|
+
}
|
|
325
|
+
static normalizeName(name) {
|
|
326
|
+
return normalizeBuiltinName(name);
|
|
327
|
+
}
|
|
328
|
+
static isBuiltinVariable(name) {
|
|
329
|
+
return this.defaultRegistry.isBuiltinVariable(name);
|
|
330
|
+
}
|
|
331
|
+
static isReservedName(name) {
|
|
332
|
+
return this.defaultRegistry.isReservedName(name);
|
|
333
|
+
}
|
|
334
|
+
static getDefinition(name) {
|
|
335
|
+
return this.defaultRegistry.getDefinition(name);
|
|
336
|
+
}
|
|
337
|
+
isBuiltinVariable(name) {
|
|
338
|
+
return this.builtinVariables.has(BuiltinVariableRegistry.normalizeName(name));
|
|
339
|
+
}
|
|
340
|
+
isReservedName(name) {
|
|
341
|
+
return this.isBuiltinVariable(name);
|
|
342
|
+
}
|
|
343
|
+
getDefinition(name) {
|
|
344
|
+
return this.builtinVariables.get(BuiltinVariableRegistry.normalizeName(name));
|
|
345
|
+
}
|
|
346
|
+
getDefinitions() {
|
|
347
|
+
return [...this.builtinVariables.values()];
|
|
348
|
+
}
|
|
349
|
+
register(definition) {
|
|
350
|
+
const normalizedName = BuiltinVariableRegistry.normalizeName(definition.name);
|
|
351
|
+
if (this.builtinVariables.has(normalizedName)) {
|
|
352
|
+
throw new IfcExpressionBuiltinConfigException_js_1.IfcExpressionBuiltinConfigException(`cannot register builtin variable with name '${definition.name}': name already in use`);
|
|
353
|
+
}
|
|
354
|
+
const members = this.registerMembers(definition);
|
|
355
|
+
const baseType = definition.type ??
|
|
356
|
+
(members.size > 0 ? Types_js_1.Type.CONTEXT_OBJECT_REF : Types_js_1.Type.ANY);
|
|
357
|
+
const resolvedType = members.size > 0
|
|
358
|
+
? new ContextObjectType_js_1.ContextObjectType(definition.name, baseType, members)
|
|
359
|
+
: baseType;
|
|
360
|
+
const createReferenceExpr = definition.createReferenceExpr ??
|
|
361
|
+
(() => new BuiltinRootReferenceExpr_js_1.BuiltinRootReferenceExpr(definition.name, resolvedType));
|
|
362
|
+
this.builtinVariables.set(normalizedName, {
|
|
363
|
+
name: definition.name,
|
|
364
|
+
type: resolvedType,
|
|
365
|
+
documentation: definition.documentation,
|
|
366
|
+
members,
|
|
367
|
+
createReferenceExpr,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
registerMembers(definition) {
|
|
371
|
+
const members = new Map();
|
|
372
|
+
definition.members?.forEach((member) => {
|
|
373
|
+
const normalizedMemberName = BuiltinVariableRegistry.normalizeName(member.name);
|
|
374
|
+
if (members.has(normalizedMemberName)) {
|
|
375
|
+
throw new IfcExpressionBuiltinConfigException_js_1.IfcExpressionBuiltinConfigException(`cannot register member '${member.name}' for builtin '${definition.name}': name already in use`);
|
|
376
|
+
}
|
|
377
|
+
members.set(normalizedMemberName, member);
|
|
378
|
+
});
|
|
379
|
+
return members;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
exports.BuiltinVariableRegistry = BuiltinVariableRegistry;
|
|
383
|
+
BuiltinVariableRegistry.defaultRegistry = new BuiltinVariableRegistry([
|
|
384
|
+
{
|
|
385
|
+
name: "element",
|
|
386
|
+
type: Types_js_1.Type.IFC_ELEMENT_REF,
|
|
387
|
+
documentation: {
|
|
388
|
+
key: "builtin.$element.summary",
|
|
389
|
+
fallback: "$element: IFC element from the evaluation context",
|
|
390
|
+
},
|
|
391
|
+
members: standardIfcElementMembers(standardIfcObjectTypes),
|
|
392
|
+
createReferenceExpr: () => new ElemObjectReferenceExpr_js_1.ElemObjectReferenceExpr(),
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "property",
|
|
396
|
+
type: Types_js_1.Type.IFC_PROPERTY_REF,
|
|
397
|
+
documentation: {
|
|
398
|
+
key: "builtin.$property.summary",
|
|
399
|
+
fallback: "$property: IFC property from the evaluation context",
|
|
400
|
+
},
|
|
401
|
+
members: standardIfcPropertyMembers(standardIfcObjectTypes),
|
|
402
|
+
createReferenceExpr: () => new PropObjectReferenceExpr_js_1.PropObjectReferenceExpr(),
|
|
403
|
+
},
|
|
404
|
+
]);
|
|
405
|
+
//# sourceMappingURL=BuiltinVariableRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/builtin/BuiltinVariableRegistry.ts"],"names":[],"mappings":";;;AAAA,uEAAiE;AACjE,4GAAsG;AAEtG,+CAA+C;AAE/C,qGAA+F;AAC/F,mGAA6F;AAC7F,mGAA6F;AA0B7F,SAAgB,2BAA2B,CACzC,UAA+C;IAE/C,OAAO,UAAU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OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACrC,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,aAAa,CAChE,MAAM,CAAC,IAAI,CACZ,CAAC;YACF,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE;gBACrC,MAAM,IAAI,4EAAmC,CAC3C,2BAA2B,MAAM,CAAC,IAAI,kBAAkB,UAAU,CAAC,IAAI,wBAAwB,CAChG,CAAC;aACH;YACD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;;AAzHH,0DA0HC;AAzHyB,uCAAe,GAAG,IAAI,uBAAuB,CAAC;IACpE;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,eAAI,CAAC,eAAe;QAC1B,aAAa,EAAE;YACb,GAAG,EAAE,0BAA0B;YAC/B,QAAQ,EAAE,mDAAmD;SAC9D;QACD,OAAO,EAAE,yBAAyB,CAAC,sBAAsB,CAAC;QAC1D,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI,oDAAuB,EAAE;KACzD;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,eAAI,CAAC,gBAAgB;QAC3B,aAAa,EAAE;YACb,GAAG,EAAE,2BAA2B;YAChC,QAAQ,EAAE,qDAAqD;SAChE;QACD,OAAO,EAAE,0BAA0B,CAAC,sBAAsB,CAAC;QAC3D,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI,oDAAuB,EAAE;KACzD;CACF,CAAC,CAAC","file":"builtin/BuiltinVariableRegistry.js","sourcesContent":["import { ContextObjectType } from \"../type/ContextObjectType.js\";\nimport { IfcExpressionBuiltinConfigException } from \"../error/IfcExpressionBuiltinConfigException.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type, Types } from \"../type/Types.js\";\nimport { Expr } from \"../expression/Expr.js\";\nimport { BuiltinRootReferenceExpr } from \"../expression/reference/BuiltinRootReferenceExpr.js\";\nimport { ElemObjectReferenceExpr } from \"../expression/reference/ElemObjectReferenceExpr.js\";\nimport { PropObjectReferenceExpr } from \"../expression/reference/PropObjectReferenceExpr.js\";\nimport {\n ArgumentDocumentation,\n LocalizedText,\n} from \"../documentation/Documentation.js\";\n\nexport type BuiltinPropertyDefinition = {\n name: string;\n kind: \"property\";\n valueType: ExprType;\n documentation?: LocalizedText;\n};\n\nexport type BuiltinFunctionDefinition = {\n name: string;\n kind: \"function\";\n returnType: ExprType;\n argumentTypes: Array<ExprType>;\n documentation?: LocalizedText;\n argumentDocumentation?: Array<ArgumentDocumentation>;\n};\n\nexport type BuiltinMemberDefinition =\n | BuiltinPropertyDefinition\n | BuiltinFunctionDefinition;\n\nexport function isBuiltinPropertyDefinition(\n definition: BuiltinMemberDefinition | undefined\n): definition is BuiltinPropertyDefinition {\n return definition?.kind === \"property\";\n}\n\nexport function isBuiltinFunctionDefinition(\n definition: BuiltinMemberDefinition | undefined\n): definition is BuiltinFunctionDefinition {\n return definition?.kind === \"function\";\n}\n\nexport type BuiltinVariableDefinition = {\n name: string;\n type?: ExprType;\n documentation?: LocalizedText;\n members?: Array<BuiltinMemberDefinition>;\n createReferenceExpr?: () => Expr<any>;\n};\n\nexport type RegisteredBuiltinVariableDefinition = {\n name: string;\n type: ExprType;\n documentation?: LocalizedText;\n members: Map<string, BuiltinMemberDefinition>;\n createReferenceExpr: () => Expr<any>;\n};\n\nfunction normalizeBuiltinName(name: string): string {\n return name?.replace(/^\\$/, \"\").toUpperCase();\n}\n\ntype StandardIfcObjectTypes = {\n elementType: ContextObjectType;\n propertyType: ContextObjectType;\n propertySetType: ContextObjectType;\n typeObjectType: ContextObjectType;\n};\n\nfunction memberArg(\n labelKey: string,\n labelFallback: string,\n summaryKey: string,\n summaryFallback: string\n): ArgumentDocumentation {\n return {\n label: { key: labelKey, fallback: labelFallback },\n documentation: { key: summaryKey, fallback: summaryFallback },\n };\n}\n\nfunction createStandardIfcObjectTypes(): StandardIfcObjectTypes {\n const elementMembers = new Map<string, BuiltinMemberDefinition>();\n const propertyMembers = new Map<string, BuiltinMemberDefinition>();\n const propertySetMembers = new Map<string, BuiltinMemberDefinition>();\n const typeObjectMembers = new Map<string, BuiltinMemberDefinition>();\n\n const propertyType = new ContextObjectType(\n Type.IFC_PROPERTY_REF.getName(),\n Type.IFC_PROPERTY_REF,\n propertyMembers\n );\n const propertySetType = new ContextObjectType(\n Type.IFC_PROPERTY_SET_REF.getName(),\n Type.IFC_PROPERTY_SET_REF,\n propertySetMembers\n );\n const typeObjectType = new ContextObjectType(\n Type.IFC_TYPE_OBJECT_REF.getName(),\n Type.IFC_TYPE_OBJECT_REF,\n typeObjectMembers\n );\n const elementType = new ContextObjectType(\n Type.IFC_ELEMENT_REF.getName(),\n Type.IFC_ELEMENT_REF,\n elementMembers\n );\n\n standardIfcElementMembers({\n elementType,\n propertyType,\n propertySetType,\n typeObjectType,\n }).forEach((member) => {\n elementMembers.set(normalizeBuiltinName(member.name), member);\n });\n standardIfcPropertyMembers({\n elementType,\n propertyType,\n propertySetType,\n typeObjectType,\n }).forEach((member) => {\n propertyMembers.set(normalizeBuiltinName(member.name), member);\n });\n standardIfcPropertySetMembers({\n elementType,\n propertyType,\n propertySetType,\n typeObjectType,\n }).forEach((member) => {\n propertySetMembers.set(normalizeBuiltinName(member.name), member);\n });\n standardIfcTypeObjectMembers({\n elementType,\n propertyType,\n propertySetType,\n typeObjectType,\n }).forEach((member) => {\n typeObjectMembers.set(normalizeBuiltinName(member.name), member);\n });\n\n return {\n elementType,\n propertyType,\n propertySetType,\n typeObjectType,\n };\n}\n\nfunction standardIfcElementMembers(\n types: StandardIfcObjectTypes\n): Array<BuiltinMemberDefinition> {\n return [\n {\n name: \"name\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$element.name.summary\",\n fallback: \"name(): name of the current IFC element\",\n },\n },\n {\n name: \"guid\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$element.guid.summary\",\n fallback:\n \"guid(): globally unique identifier of the current IFC element\",\n },\n },\n {\n name: \"ifcClass\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$element.ifcClass.summary\",\n fallback: \"ifcClass(): IFC class name of the current element\",\n },\n },\n {\n name: \"description\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$element.description.summary\",\n fallback: \"description(): description of the current IFC element\",\n },\n },\n {\n name: \"property\",\n kind: \"function\",\n returnType: types.propertyType,\n argumentTypes: [Type.STRING],\n documentation: {\n key: \"builtin.$element.property.summary\",\n fallback: \"property(name): property of the current IFC element by name\",\n },\n argumentDocumentation: [\n memberArg(\n \"builtin.$element.property.arg.name.label\",\n \"name\",\n \"builtin.$element.property.arg.name.summary\",\n \"The name of the property to resolve\"\n ),\n ],\n },\n {\n name: \"propertySet\",\n kind: \"function\",\n returnType: types.propertySetType,\n argumentTypes: [Type.STRING],\n documentation: {\n key: \"builtin.$element.propertySet.summary\",\n fallback:\n \"propertySet(name): property set of the current IFC element by name\",\n },\n argumentDocumentation: [\n memberArg(\n \"builtin.$element.propertySet.arg.name.label\",\n \"name\",\n \"builtin.$element.propertySet.arg.name.summary\",\n \"The name of the property set to resolve\"\n ),\n ],\n },\n {\n name: \"type\",\n kind: \"function\",\n returnType: types.typeObjectType,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$element.type.summary\",\n fallback: \"type(): type object of the current IFC element\",\n },\n },\n ];\n}\n\nfunction standardIfcPropertyMembers(\n types: StandardIfcObjectTypes\n): Array<BuiltinMemberDefinition> {\n return [\n {\n name: \"name\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$property.name.summary\",\n fallback: \"name(): name of the current IFC property\",\n },\n },\n {\n name: \"ifcClass\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$property.ifcClass.summary\",\n fallback: \"ifcClass(): IFC class name of the current property\",\n },\n },\n {\n name: \"description\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$property.description.summary\",\n fallback: \"description(): description of the current IFC property\",\n },\n },\n {\n name: \"propertySet\",\n kind: \"function\",\n returnType: types.propertySetType,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$property.propertySet.summary\",\n fallback:\n \"propertySet(): property set containing the current IFC property\",\n },\n },\n {\n name: \"value\",\n kind: \"function\",\n returnType: Types.or(Type.STRING, Type.NUMERIC, Type.BOOLEAN, Type.ARRAY),\n argumentTypes: [],\n documentation: {\n key: \"builtin.$property.value.summary\",\n fallback: \"value(): value of the current IFC property\",\n },\n },\n ];\n}\n\nfunction standardIfcPropertySetMembers(\n types: StandardIfcObjectTypes\n): Array<BuiltinMemberDefinition> {\n return [\n {\n name: \"name\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$propertySet.name.summary\",\n fallback: \"name(): name of the current IFC property set\",\n },\n },\n {\n name: \"guid\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$propertySet.guid.summary\",\n fallback:\n \"guid(): globally unique identifier of the current IFC property set\",\n },\n },\n {\n name: \"description\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$propertySet.description.summary\",\n fallback: \"description(): description of the current IFC property set\",\n },\n },\n {\n name: \"property\",\n kind: \"function\",\n returnType: types.propertyType,\n argumentTypes: [Type.STRING],\n documentation: {\n key: \"builtin.$propertySet.property.summary\",\n fallback:\n \"property(name): property of the current IFC property set by name\",\n },\n argumentDocumentation: [\n memberArg(\n \"builtin.$propertySet.property.arg.name.label\",\n \"name\",\n \"builtin.$propertySet.property.arg.name.summary\",\n \"The name of the property to resolve\"\n ),\n ],\n },\n ];\n}\n\nfunction standardIfcTypeObjectMembers(\n types: StandardIfcObjectTypes\n): Array<BuiltinMemberDefinition> {\n return [\n {\n name: \"name\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$typeObject.name.summary\",\n fallback: \"name(): name of the current IFC type object\",\n },\n },\n {\n name: \"guid\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$typeObject.guid.summary\",\n fallback:\n \"guid(): globally unique identifier of the current IFC type object\",\n },\n },\n {\n name: \"description\",\n kind: \"function\",\n returnType: Type.STRING,\n argumentTypes: [],\n documentation: {\n key: \"builtin.$typeObject.description.summary\",\n fallback: \"description(): description of the current IFC type object\",\n },\n },\n {\n name: \"property\",\n kind: \"function\",\n returnType: types.propertyType,\n argumentTypes: [Type.STRING],\n documentation: {\n key: \"builtin.$typeObject.property.summary\",\n fallback:\n \"property(name): property of the current IFC type object by name\",\n },\n argumentDocumentation: [\n memberArg(\n \"builtin.$typeObject.property.arg.name.label\",\n \"name\",\n \"builtin.$typeObject.property.arg.name.summary\",\n \"The name of the property to resolve\"\n ),\n ],\n },\n {\n name: \"propertySet\",\n kind: \"function\",\n returnType: types.propertySetType,\n argumentTypes: [Type.STRING],\n documentation: {\n key: \"builtin.$typeObject.propertySet.summary\",\n fallback:\n \"propertySet(name): property set of the current IFC type object by name\",\n },\n argumentDocumentation: [\n memberArg(\n \"builtin.$typeObject.propertySet.arg.name.label\",\n \"name\",\n \"builtin.$typeObject.propertySet.arg.name.summary\",\n \"The name of the property set to resolve\"\n ),\n ],\n },\n ];\n}\n\nconst standardIfcObjectTypes = createStandardIfcObjectTypes();\n\nexport class BuiltinVariableRegistry {\n private static readonly defaultRegistry = new BuiltinVariableRegistry([\n {\n name: \"element\",\n type: Type.IFC_ELEMENT_REF,\n documentation: {\n key: \"builtin.$element.summary\",\n fallback: \"$element: IFC element from the evaluation context\",\n },\n members: standardIfcElementMembers(standardIfcObjectTypes),\n createReferenceExpr: () => new ElemObjectReferenceExpr(),\n },\n {\n name: \"property\",\n type: Type.IFC_PROPERTY_REF,\n documentation: {\n key: \"builtin.$property.summary\",\n fallback: \"$property: IFC property from the evaluation context\",\n },\n members: standardIfcPropertyMembers(standardIfcObjectTypes),\n createReferenceExpr: () => new PropObjectReferenceExpr(),\n },\n ]);\n\n private readonly builtinVariables: Map<\n string,\n RegisteredBuiltinVariableDefinition\n >;\n\n constructor(definitions: Array<BuiltinVariableDefinition> = []) {\n this.builtinVariables = new Map();\n definitions.forEach((definition) => this.register(definition));\n }\n\n public static getDefaultRegistry() {\n return this.defaultRegistry;\n }\n\n public static normalizeName(name: string): string {\n return normalizeBuiltinName(name);\n }\n\n public static isBuiltinVariable(name: string): boolean {\n return this.defaultRegistry.isBuiltinVariable(name);\n }\n\n public static isReservedName(name: string): boolean {\n return this.defaultRegistry.isReservedName(name);\n }\n\n public static getDefinition(\n name: string\n ): RegisteredBuiltinVariableDefinition | undefined {\n return this.defaultRegistry.getDefinition(name);\n }\n\n public isBuiltinVariable(name: string): boolean {\n return this.builtinVariables.has(\n BuiltinVariableRegistry.normalizeName(name)\n );\n }\n\n public isReservedName(name: string): boolean {\n return this.isBuiltinVariable(name);\n }\n\n public getDefinition(\n name: string\n ): RegisteredBuiltinVariableDefinition | undefined {\n return this.builtinVariables.get(\n BuiltinVariableRegistry.normalizeName(name)\n );\n }\n\n public getDefinitions(): Array<RegisteredBuiltinVariableDefinition> {\n return [...this.builtinVariables.values()];\n }\n\n private register(definition: BuiltinVariableDefinition) {\n const normalizedName = BuiltinVariableRegistry.normalizeName(\n definition.name\n );\n if (this.builtinVariables.has(normalizedName)) {\n throw new IfcExpressionBuiltinConfigException(\n `cannot register builtin variable with name '${definition.name}': name already in use`\n );\n }\n const members = this.registerMembers(definition);\n const baseType =\n definition.type ??\n (members.size > 0 ? Type.CONTEXT_OBJECT_REF : Type.ANY);\n const resolvedType =\n members.size > 0\n ? new ContextObjectType(definition.name, baseType, members)\n : baseType;\n const createReferenceExpr =\n definition.createReferenceExpr ??\n (() => new BuiltinRootReferenceExpr(definition.name, resolvedType));\n this.builtinVariables.set(normalizedName, {\n name: definition.name,\n type: resolvedType,\n documentation: definition.documentation,\n members,\n createReferenceExpr,\n });\n }\n\n private registerMembers(definition: BuiltinVariableDefinition) {\n const members = new Map<string, BuiltinMemberDefinition>();\n definition.members?.forEach((member) => {\n const normalizedMemberName = BuiltinVariableRegistry.normalizeName(\n member.name\n );\n if (members.has(normalizedMemberName)) {\n throw new IfcExpressionBuiltinConfigException(\n `cannot register member '${member.name}' for builtin '${definition.name}': name already in use`\n );\n }\n members.set(normalizedMemberName, member);\n });\n return members;\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ExprCompiler = void 0;
|
|
7
|
-
const IfcExpressionVisitor_js_1 =
|
|
7
|
+
const IfcExpressionVisitor_js_1 = require("../gen/parser/IfcExpressionVisitor.js");
|
|
8
8
|
const NumericLiteralExpr_js_1 = require("../expression/numeric/NumericLiteralExpr.js");
|
|
9
9
|
const IfcExpressionUtils_js_1 = require("../util/IfcExpressionUtils.js");
|
|
10
10
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
@@ -12,8 +12,6 @@ const PlusExpr_js_1 = require("../expression/numeric/PlusExpr.js");
|
|
|
12
12
|
const MinusExpr_js_1 = require("../expression/numeric/MinusExpr.js");
|
|
13
13
|
const MultiplyExpr_js_1 = require("../expression/numeric/MultiplyExpr.js");
|
|
14
14
|
const DivideExpr_js_1 = require("../expression/numeric/DivideExpr.js");
|
|
15
|
-
const PropObjectReferenceExpr_js_1 = require("../expression/reference/PropObjectReferenceExpr.js");
|
|
16
|
-
const ElemObjectReferenceExpr_js_1 = require("../expression/reference/ElemObjectReferenceExpr.js");
|
|
17
15
|
const StringLiteralExpr_js_1 = require("../expression/string/StringLiteralExpr.js");
|
|
18
16
|
const ArrayExpr_js_1 = require("../expression/structure/ArrayExpr.js");
|
|
19
17
|
const FunctionExpr_js_1 = require("../expression/function/FunctionExpr.js");
|
|
@@ -38,19 +36,24 @@ const LessThanOrEqual_js_1 = require("../expression/comparison/LessThanOrEqual.j
|
|
|
38
36
|
const ExprManager_js_1 = require("./ExprManager.js");
|
|
39
37
|
const LogicalValue_js_1 = require("../value/LogicalValue.js");
|
|
40
38
|
const LogicalLiteralExpr_js_1 = require("../expression/boolean/LogicalLiteralExpr.js");
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const BuiltinVariableRegistry_js_1 = require("../builtin/BuiltinVariableRegistry.js");
|
|
40
|
+
const ContextObjectType_js_1 = require("../type/ContextObjectType.js");
|
|
41
|
+
const BuiltinPropertyAccessExpr_js_1 = require("../expression/reference/BuiltinPropertyAccessExpr.js");
|
|
42
|
+
const BuiltinFunctionCallExpr_js_1 = require("../expression/reference/BuiltinFunctionCallExpr.js");
|
|
43
|
+
class ExprCompiler extends IfcExpressionVisitor_js_1.IfcExpressionVisitor {
|
|
44
|
+
defaultResult() {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
constructor(typeManager, builtinVariableRegistry = BuiltinVariableRegistry_js_1.BuiltinVariableRegistry.getDefaultRegistry()) {
|
|
43
48
|
super();
|
|
44
49
|
this.methodCallTargetStack = [];
|
|
45
50
|
this.visitExpr = (ctx) => {
|
|
46
51
|
return this.visit(ctx.singleExpr());
|
|
47
52
|
};
|
|
48
53
|
this.visitVariableRef = (ctx) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
else if (ctx.IDENTIFIER().getText().toUpperCase() === "ELEMENT") {
|
|
53
|
-
return this.associateContextAndReturn(new ElemObjectReferenceExpr_js_1.ElemObjectReferenceExpr(), ctx);
|
|
54
|
+
const builtin = this.builtinVariableRegistry.getDefinition(ctx.IDENTIFIER().getText());
|
|
55
|
+
if (!(0, IfcExpressionUtils_js_1.isNullish)(builtin)) {
|
|
56
|
+
return this.associateContextAndReturn(builtin.createReferenceExpr(), ctx);
|
|
54
57
|
}
|
|
55
58
|
throw new Error(`Parsing error: No variable '${ctx.getText()}' found `);
|
|
56
59
|
};
|
|
@@ -94,21 +97,39 @@ class ExprCompiler extends IfcExpressionVisitor_js_1.default {
|
|
|
94
97
|
this.visitSEParenthesis = (ctx) => {
|
|
95
98
|
return this.associateContextAndReturn(new ParenthesisExpr_js_1.ParenthesisExpr(this.visit(ctx._sub)), ctx);
|
|
96
99
|
};
|
|
97
|
-
/*================================================
|
|
98
|
-
* MethodCallChain
|
|
99
|
-
*==============================================*/
|
|
100
100
|
this.visitMethodCallChainInner = (ctx) => {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.associateContextAndReturn(functionExpr, ctx.functionCall());
|
|
105
|
-
this.methodCallTargetStack.push(functionExpr);
|
|
106
|
-
return this.visit(ctx.methodCallChain());
|
|
101
|
+
const accessExpr = this.visit(ctx._target);
|
|
102
|
+
this.methodCallTargetStack.push(accessExpr);
|
|
103
|
+
return this.visit(ctx._call);
|
|
107
104
|
};
|
|
108
105
|
this.visitMethodCallChainEnd = (ctx) => {
|
|
109
|
-
return this.
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
return this.visit(ctx._call);
|
|
107
|
+
};
|
|
108
|
+
this.visitMethodFunctionCall = (ctx) => {
|
|
109
|
+
const targetExpr = this.methodCallTargetStack.pop();
|
|
110
|
+
const functionName = ctx.functionCall().IDENTIFIER().getText();
|
|
111
|
+
const args = (0, IfcExpressionUtils_js_1.isNullish)(ctx.functionCall().exprList())
|
|
112
|
+
? []
|
|
113
|
+
: this.collectFunctionArguments(ctx.functionCall().exprList());
|
|
114
|
+
const targetType = targetExpr.getType();
|
|
115
|
+
if (targetType instanceof ContextObjectType_js_1.ContextObjectType) {
|
|
116
|
+
const member = targetType.getMemberDefinition(functionName);
|
|
117
|
+
if ((0, BuiltinVariableRegistry_js_1.isBuiltinFunctionDefinition)(member)) {
|
|
118
|
+
return this.associateContextAndReturn(new BuiltinFunctionCallExpr_js_1.BuiltinFunctionCallExpr(targetExpr, member.name, args, member.returnType, targetType.getName()), ctx);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return this.associateContextAndReturn(new FunctionExpr_js_1.FunctionExpr(functionName, [targetExpr, ...args]), ctx.functionCall());
|
|
122
|
+
};
|
|
123
|
+
this.visitMethodPropertyAccess = (ctx) => {
|
|
124
|
+
const targetExpr = this.methodCallTargetStack.pop();
|
|
125
|
+
const targetType = targetExpr.getType();
|
|
126
|
+
if (targetType instanceof ContextObjectType_js_1.ContextObjectType) {
|
|
127
|
+
const member = targetType.getMemberDefinition(ctx.IDENTIFIER().getText());
|
|
128
|
+
if ((0, BuiltinVariableRegistry_js_1.isBuiltinPropertyDefinition)(member)) {
|
|
129
|
+
return this.associateContextAndReturn(new BuiltinPropertyAccessExpr_js_1.BuiltinPropertyAccessExpr(targetExpr, member.name, member.valueType, targetType.getName()), ctx);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
throw new Error(`Parsing error: No property '${ctx.getText()}' found for type '${targetType.getName()}'`);
|
|
112
133
|
};
|
|
113
134
|
this.visitSEAddSub = (ctx) => {
|
|
114
135
|
this.typeManager.requireTypesOverlap(ctx._left, ctx._right);
|
|
@@ -131,17 +152,11 @@ class ExprCompiler extends IfcExpressionVisitor_js_1.default {
|
|
|
131
152
|
ExprCompiler.failNode(ctx);
|
|
132
153
|
}
|
|
133
154
|
};
|
|
134
|
-
/*================================================
|
|
135
|
-
* StringExpr
|
|
136
|
-
*===============================================*/
|
|
137
155
|
this.visitStringLiteral = (ctx) => {
|
|
138
156
|
const quotedString = ctx.QUOTED_STRING().getText();
|
|
139
157
|
const text = quotedString.substring(1, quotedString.length - 1);
|
|
140
158
|
return this.associateContextAndReturn(new StringLiteralExpr_js_1.StringLiteralExpr(text), ctx);
|
|
141
159
|
};
|
|
142
|
-
/*================================================
|
|
143
|
-
* NumExpr
|
|
144
|
-
*===============================================*/
|
|
145
160
|
this.visitNumLiteral = (ctx) => {
|
|
146
161
|
let val = ctx.INT();
|
|
147
162
|
if ((0, IfcExpressionUtils_js_1.isPresent)(val)) {
|
|
@@ -162,9 +177,6 @@ class ExprCompiler extends IfcExpressionVisitor_js_1.default {
|
|
|
162
177
|
this.visitSEUnaryMinus = (ctx) => {
|
|
163
178
|
return this.associateContextAndReturn(new UnaryMinusExpr_js_1.UnaryMinusExpr(this.visit(ctx.singleExpr())), ctx);
|
|
164
179
|
};
|
|
165
|
-
/*================================================
|
|
166
|
-
* BooleanExpr
|
|
167
|
-
*===============================================*/
|
|
168
180
|
this.visitSEBooleanBinaryOp = (ctx) => {
|
|
169
181
|
switch (ctx._op.text) {
|
|
170
182
|
case "&&":
|
|
@@ -180,15 +192,11 @@ class ExprCompiler extends IfcExpressionVisitor_js_1.default {
|
|
|
180
192
|
return this.associateContextAndReturn(new BooleanLiteralExpr_js_1.BooleanLiteralExpr(ctx.BOOLEAN().getText().toUpperCase() === "TRUE"), ctx);
|
|
181
193
|
};
|
|
182
194
|
this.visitLogicalLiteral = (ctx) => {
|
|
183
|
-
// the only literal we recognize is 'UNKNOWN' (true and false are boolean literals)
|
|
184
195
|
return this.associateContextAndReturn(new LogicalLiteralExpr_js_1.LogicalLiteralExpr(LogicalValue_js_1.LogicalValue.UNKNOWN_VALUE), ctx);
|
|
185
196
|
};
|
|
186
197
|
this.visitSENot = (ctx) => {
|
|
187
198
|
return this.associateContextAndReturn(new NotExpr_js_1.NotExpr(this.visit(ctx.singleExpr())), ctx);
|
|
188
199
|
};
|
|
189
|
-
/*================================================
|
|
190
|
-
* ArrayExpr
|
|
191
|
-
*===============================================*/
|
|
192
200
|
this.visitArrayExpr = (ctx) => {
|
|
193
201
|
return this.associateContextAndReturn(new ArrayExpr_js_1.ArrayExpr(this.collectArrayElements(ctx.arrayElementList())), ctx);
|
|
194
202
|
};
|
|
@@ -205,9 +213,6 @@ class ExprCompiler extends IfcExpressionVisitor_js_1.default {
|
|
|
205
213
|
}
|
|
206
214
|
return [];
|
|
207
215
|
};
|
|
208
|
-
/*================================================
|
|
209
|
-
* FuncExpr
|
|
210
|
-
*===============================================*/
|
|
211
216
|
this.visitFunctionCall = (ctx) => {
|
|
212
217
|
const args = (0, IfcExpressionUtils_js_1.isNullish)(ctx.exprList())
|
|
213
218
|
? []
|
|
@@ -232,13 +237,11 @@ class ExprCompiler extends IfcExpressionVisitor_js_1.default {
|
|
|
232
237
|
};
|
|
233
238
|
this.typeManager = typeManager;
|
|
234
239
|
this.exprManager = new ExprManager_js_1.ExprManager();
|
|
240
|
+
this.builtinVariableRegistry = builtinVariableRegistry;
|
|
235
241
|
}
|
|
236
242
|
getExprManager() {
|
|
237
243
|
return this.exprManager;
|
|
238
244
|
}
|
|
239
|
-
/*================================================
|
|
240
|
-
* VariableRef
|
|
241
|
-
*==============================================*/
|
|
242
245
|
associateContextAndReturn(expr, ctx) {
|
|
243
246
|
this.exprManager.registerExprWithContext(expr, ctx);
|
|
244
247
|
return expr;
|