greybel-interpreter 0.1.6 → 0.2.0
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/dist/context.js +9 -7
- package/dist/cps.d.ts +1 -1
- package/dist/cps.js +665 -287
- package/dist/custom-types/list.js +2 -2
- package/dist/custom-types/map.js +2 -2
- package/dist/custom-types/string.js +1 -1
- package/dist/expressions/assign.d.ts +2 -1
- package/dist/expressions/assign.js +23 -5
- package/dist/expressions/binary-negated-expression.d.ts +2 -1
- package/dist/expressions/binary-negated-expression.js +21 -5
- package/dist/expressions/call.d.ts +2 -1
- package/dist/expressions/call.js +67 -36
- package/dist/expressions/list.d.ts +2 -1
- package/dist/expressions/list.js +22 -7
- package/dist/expressions/logical-and-binary.d.ts +2 -1
- package/dist/expressions/logical-and-binary.js +25 -5
- package/dist/expressions/map.d.ts +2 -1
- package/dist/expressions/map.js +35 -10
- package/dist/expressions/path.d.ts +2 -1
- package/dist/expressions/path.js +95 -41
- package/dist/interpreter.d.ts +1 -1
- package/dist/interpreter.js +80 -23
- package/dist/resource.d.ts +4 -4
- package/dist/resource.js +4 -4
- package/package.json +1 -1
|
@@ -195,7 +195,7 @@ var CustomList = /** @class */ (function (_super) {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
else if (path.length === 1 && CustomList.intrinsics.has(currentValue)) {
|
|
198
|
-
return [2 /*return*/, CustomList.intrinsics.get(currentValue)];
|
|
198
|
+
return [2 /*return*/, CustomList.intrinsics.get(currentValue).bind(null, me)];
|
|
199
199
|
}
|
|
200
200
|
else {
|
|
201
201
|
throw new Error("Cannot get path ".concat(path.join('.')));
|
|
@@ -228,7 +228,7 @@ var CustomList = /** @class */ (function (_super) {
|
|
|
228
228
|
}
|
|
229
229
|
else if (path.length === 1 && CustomList.intrinsics.has(current)) {
|
|
230
230
|
return [2 /*return*/, {
|
|
231
|
-
origin: CustomList.intrinsics.get(current),
|
|
231
|
+
origin: CustomList.intrinsics.get(current).bind(null, me),
|
|
232
232
|
context: me
|
|
233
233
|
}];
|
|
234
234
|
}
|
package/dist/custom-types/map.js
CHANGED
|
@@ -180,7 +180,7 @@ var CustomMap = /** @class */ (function (_super) {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
else if (path.length === 1 && CustomMap.intrinsics.has(currentValue)) {
|
|
183
|
-
return [2 /*return*/, CustomMap.intrinsics.get(currentValue)];
|
|
183
|
+
return [2 /*return*/, CustomMap.intrinsics.get(currentValue).bind(null, me)];
|
|
184
184
|
}
|
|
185
185
|
else {
|
|
186
186
|
throw new Error("Cannot get path ".concat(path.join('.')));
|
|
@@ -212,7 +212,7 @@ var CustomMap = /** @class */ (function (_super) {
|
|
|
212
212
|
}
|
|
213
213
|
else if (path.length === 1 && CustomMap.intrinsics.has(current)) {
|
|
214
214
|
return [2 /*return*/, {
|
|
215
|
-
origin: CustomMap.intrinsics.get(current),
|
|
215
|
+
origin: CustomMap.intrinsics.get(current).bind(null, me),
|
|
216
216
|
context: me
|
|
217
217
|
}];
|
|
218
218
|
}
|
|
@@ -120,7 +120,7 @@ var CustomString = /** @class */ (function (_super) {
|
|
|
120
120
|
return me.value.length === 0 ? null : me.value;
|
|
121
121
|
};
|
|
122
122
|
CustomString.prototype.toString = function () {
|
|
123
|
-
return
|
|
123
|
+
return this.value;
|
|
124
124
|
};
|
|
125
125
|
CustomString.prototype.fork = function () {
|
|
126
126
|
return new CustomString(this.value);
|
|
@@ -7,6 +7,7 @@ export declare class ExpressionSegment {
|
|
|
7
7
|
constructor(left: any, right: any);
|
|
8
8
|
}
|
|
9
9
|
export default class AssignExpression extends Expression {
|
|
10
|
-
constructor(ast: ASTAssignmentStatement
|
|
10
|
+
constructor(ast: ASTAssignmentStatement);
|
|
11
|
+
prepare(visit: Function): Promise<AssignExpression>;
|
|
11
12
|
get(operationContext: OperationContext, parentExpr: any): Promise<any>;
|
|
12
13
|
}
|
|
@@ -67,16 +67,34 @@ var ExpressionSegment = /** @class */ (function () {
|
|
|
67
67
|
exports.ExpressionSegment = ExpressionSegment;
|
|
68
68
|
var AssignExpression = /** @class */ (function (_super) {
|
|
69
69
|
__extends(AssignExpression, _super);
|
|
70
|
-
function AssignExpression(ast
|
|
70
|
+
function AssignExpression(ast) {
|
|
71
71
|
var _this = _super.call(this) || this;
|
|
72
72
|
var me = _this;
|
|
73
|
-
var buildExpression = function (node) {
|
|
74
|
-
return new ExpressionSegment(visit(node.variable), visit(node.init));
|
|
75
|
-
};
|
|
76
73
|
me.ast = ast;
|
|
77
|
-
me.expr =
|
|
74
|
+
me.expr = null;
|
|
78
75
|
return _this;
|
|
79
76
|
}
|
|
77
|
+
AssignExpression.prototype.prepare = function (visit) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var me, node, _a, _b, _c;
|
|
80
|
+
return __generator(this, function (_d) {
|
|
81
|
+
switch (_d.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
me = this;
|
|
84
|
+
node = me.ast;
|
|
85
|
+
_a = me;
|
|
86
|
+
_b = ExpressionSegment.bind;
|
|
87
|
+
return [4 /*yield*/, visit(node.variable)];
|
|
88
|
+
case 1:
|
|
89
|
+
_c = [void 0, _d.sent()];
|
|
90
|
+
return [4 /*yield*/, visit(node.init)];
|
|
91
|
+
case 2:
|
|
92
|
+
_a.expr = new (_b.apply(ExpressionSegment, _c.concat([_d.sent()])))();
|
|
93
|
+
return [2 /*return*/, me];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
80
98
|
AssignExpression.prototype.get = function (operationContext, parentExpr) {
|
|
81
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
82
100
|
var me, evaluate;
|
|
@@ -13,6 +13,7 @@ export declare class ExpressionSegment {
|
|
|
13
13
|
}
|
|
14
14
|
export default class BinaryNegatedExpression extends Expression {
|
|
15
15
|
expr: ExpressionSegment;
|
|
16
|
-
constructor(ast: ASTUnaryExpression
|
|
16
|
+
constructor(ast: ASTUnaryExpression);
|
|
17
|
+
prepare(visit: Function): Promise<BinaryNegatedExpression>;
|
|
17
18
|
get(operationContext: OperationContext): any;
|
|
18
19
|
}
|
|
@@ -75,16 +75,32 @@ var ExpressionSegment = /** @class */ (function () {
|
|
|
75
75
|
exports.ExpressionSegment = ExpressionSegment;
|
|
76
76
|
var BinaryNegatedExpression = /** @class */ (function (_super) {
|
|
77
77
|
__extends(BinaryNegatedExpression, _super);
|
|
78
|
-
function BinaryNegatedExpression(ast
|
|
78
|
+
function BinaryNegatedExpression(ast) {
|
|
79
79
|
var _this = _super.call(this) || this;
|
|
80
80
|
var me = _this;
|
|
81
|
-
var buildExpression = function (node) {
|
|
82
|
-
return new ExpressionSegment(node.operator, visit(node.argument));
|
|
83
|
-
};
|
|
84
81
|
me.ast = ast;
|
|
85
|
-
me.expr =
|
|
82
|
+
me.expr = null;
|
|
86
83
|
return _this;
|
|
87
84
|
}
|
|
85
|
+
BinaryNegatedExpression.prototype.prepare = function (visit) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var me, node, _a, _b, _c;
|
|
88
|
+
return __generator(this, function (_d) {
|
|
89
|
+
switch (_d.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
me = this;
|
|
92
|
+
node = me.ast;
|
|
93
|
+
_a = me;
|
|
94
|
+
_b = ExpressionSegment.bind;
|
|
95
|
+
_c = [void 0, node.operator];
|
|
96
|
+
return [4 /*yield*/, visit(node.argument)];
|
|
97
|
+
case 1:
|
|
98
|
+
_a.expr = new (_b.apply(ExpressionSegment, _c.concat([_d.sent()])))();
|
|
99
|
+
return [2 /*return*/, me];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
88
104
|
BinaryNegatedExpression.prototype.get = function (operationContext) {
|
|
89
105
|
var me = this;
|
|
90
106
|
var evaluate = function (node) {
|
|
@@ -8,6 +8,7 @@ export declare class ExpressionSegment {
|
|
|
8
8
|
}
|
|
9
9
|
export default class CallExpression extends Expression {
|
|
10
10
|
expr: ExpressionSegment;
|
|
11
|
-
constructor(ast: any
|
|
11
|
+
constructor(ast: any);
|
|
12
|
+
prepare(visit: Function): Promise<CallExpression>;
|
|
12
13
|
get(operationContext: OperationContext, parentExpr: any): Promise<any>;
|
|
13
14
|
}
|
package/dist/expressions/call.js
CHANGED
|
@@ -105,66 +105,97 @@ var ExpressionSegment = /** @class */ (function () {
|
|
|
105
105
|
exports.ExpressionSegment = ExpressionSegment;
|
|
106
106
|
var CallExpression = /** @class */ (function (_super) {
|
|
107
107
|
__extends(CallExpression, _super);
|
|
108
|
-
function CallExpression(ast
|
|
108
|
+
function CallExpression(ast) {
|
|
109
109
|
var _this = _super.call(this) || this;
|
|
110
110
|
var me = _this;
|
|
111
|
-
var buildExpression = function (node) {
|
|
112
|
-
if (greyscript_core_1.ASTType.CallStatement === node.type) {
|
|
113
|
-
return buildExpression(node.expression);
|
|
114
|
-
}
|
|
115
|
-
return new ExpressionSegment(visit(node.base), node.arguments.map(function (item) { return visit(item); }));
|
|
116
|
-
};
|
|
117
111
|
me.ast = ast;
|
|
118
|
-
me.expr =
|
|
112
|
+
me.expr = null;
|
|
119
113
|
return _this;
|
|
120
114
|
}
|
|
115
|
+
CallExpression.prototype.prepare = function (visit) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
+
var me, buildExpression, _a;
|
|
118
|
+
return __generator(this, function (_b) {
|
|
119
|
+
switch (_b.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
me = this;
|
|
122
|
+
buildExpression = function (node) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
return __generator(this, function (_c) {
|
|
126
|
+
switch (_c.label) {
|
|
127
|
+
case 0:
|
|
128
|
+
if (greyscript_core_1.ASTType.CallStatement === node.type) {
|
|
129
|
+
return [2 /*return*/, buildExpression(node.expression)];
|
|
130
|
+
}
|
|
131
|
+
_a = ExpressionSegment.bind;
|
|
132
|
+
return [4 /*yield*/, visit(node.base)];
|
|
133
|
+
case 1:
|
|
134
|
+
_b = [void 0, _c.sent()];
|
|
135
|
+
return [4 /*yield*/, Promise.all(node.arguments.map(function (item) { return visit(item); }))];
|
|
136
|
+
case 2: return [2 /*return*/, new (_a.apply(ExpressionSegment, _b.concat([_c.sent()])))()];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
_a = me;
|
|
142
|
+
return [4 /*yield*/, buildExpression(me.ast)];
|
|
143
|
+
case 1:
|
|
144
|
+
_a.expr = _b.sent();
|
|
145
|
+
return [2 /*return*/, me];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
};
|
|
121
150
|
CallExpression.prototype.get = function (operationContext, parentExpr) {
|
|
122
151
|
var me = this;
|
|
123
152
|
var opc = operationContext.fork(context_1.ContextType.CALL, context_1.ContextState.TEMPORARY);
|
|
124
153
|
var evaluate = function (node) {
|
|
125
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
var args, pathExpr, callable_1, callable,
|
|
127
|
-
var
|
|
128
|
-
return __generator(this, function (
|
|
129
|
-
switch (
|
|
155
|
+
var args, pathExpr, callable_1, _a, callable, _b;
|
|
156
|
+
var _c, _d, _e;
|
|
157
|
+
return __generator(this, function (_f) {
|
|
158
|
+
switch (_f.label) {
|
|
130
159
|
case 0:
|
|
131
160
|
if (node instanceof expression_1.Expression) {
|
|
132
161
|
return [2 /*return*/, node.get(opc)];
|
|
133
162
|
}
|
|
134
163
|
return [4 /*yield*/, node.resolveArgs(operationContext)];
|
|
135
164
|
case 1:
|
|
136
|
-
args =
|
|
165
|
+
args = _f.sent();
|
|
137
166
|
return [4 /*yield*/, node.path.get(opc, me.expr)];
|
|
138
167
|
case 2:
|
|
139
|
-
pathExpr =
|
|
168
|
+
pathExpr = _f.sent();
|
|
140
169
|
operationContext.debugger.debug('CallExpression', 'pathExpr', pathExpr);
|
|
141
|
-
if (!pathExpr.handle) return [3 /*break*/,
|
|
142
|
-
if (!(0, typer_1.isCustomMap)(pathExpr.handle)) return [3 /*break*/,
|
|
170
|
+
if (!pathExpr.handle) return [3 /*break*/, 8];
|
|
171
|
+
if (!(0, typer_1.isCustomMap)(pathExpr.handle)) return [3 /*break*/, 7];
|
|
143
172
|
return [4 /*yield*/, pathExpr.handle.getCallable(pathExpr.path)];
|
|
144
173
|
case 3:
|
|
145
|
-
callable_1 =
|
|
146
|
-
if (callable_1.origin instanceof operation_1.Operation)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
_e.label = 4;
|
|
155
|
-
case 4: return [2 /*return*/, (0, typer_1.cast)((_c = pathExpr.handle).callMethod.apply(_c, __spreadArray([pathExpr.path], __read(args), false)))];
|
|
156
|
-
case 5: return [4 /*yield*/, opc.getCallable(pathExpr.path)];
|
|
174
|
+
callable_1 = _f.sent();
|
|
175
|
+
if (!(callable_1.origin instanceof operation_1.Operation)) return [3 /*break*/, 4];
|
|
176
|
+
opc.setMemory('args', args);
|
|
177
|
+
return [2 /*return*/, callable_1.origin.run(opc)];
|
|
178
|
+
case 4:
|
|
179
|
+
if (!(callable_1.origin instanceof Function)) return [3 /*break*/, 6];
|
|
180
|
+
_a = typer_1.cast;
|
|
181
|
+
return [4 /*yield*/, (_c = callable_1.origin).call.apply(_c, __spreadArray([pathExpr.handle], __read(args), false))];
|
|
182
|
+
case 5: return [2 /*return*/, _a.apply(void 0, [_f.sent()])];
|
|
157
183
|
case 6:
|
|
158
|
-
|
|
184
|
+
operationContext.debugger.raise('Unexpected handle call', me, callable_1);
|
|
185
|
+
_f.label = 7;
|
|
186
|
+
case 7: return [2 /*return*/, (0, typer_1.cast)((_d = pathExpr.handle).callMethod.apply(_d, __spreadArray([pathExpr.path], __read(args), false)))];
|
|
187
|
+
case 8: return [4 /*yield*/, opc.getCallable(pathExpr.path)];
|
|
188
|
+
case 9:
|
|
189
|
+
callable = _f.sent();
|
|
159
190
|
opc.setMemory('args', args);
|
|
160
|
-
if (!(callable.origin instanceof operation_1.Operation)) return [3 /*break*/,
|
|
191
|
+
if (!(callable.origin instanceof operation_1.Operation)) return [3 /*break*/, 10];
|
|
161
192
|
return [2 /*return*/, callable.origin.run(opc)];
|
|
162
|
-
case
|
|
163
|
-
if (!(callable.origin instanceof Function)) return [3 /*break*/,
|
|
164
|
-
|
|
165
|
-
return [4 /*yield*/, (
|
|
166
|
-
case
|
|
167
|
-
case
|
|
193
|
+
case 10:
|
|
194
|
+
if (!(callable.origin instanceof Function)) return [3 /*break*/, 12];
|
|
195
|
+
_b = typer_1.cast;
|
|
196
|
+
return [4 /*yield*/, (_e = callable.origin).call.apply(_e, __spreadArray([callable.context], __read(args), false))];
|
|
197
|
+
case 11: return [2 /*return*/, _b.apply(void 0, [_f.sent()])];
|
|
198
|
+
case 12: return [2 /*return*/, (0, typer_1.cast)(callable.origin)];
|
|
168
199
|
}
|
|
169
200
|
});
|
|
170
201
|
});
|
|
@@ -8,6 +8,7 @@ export declare class ExpressionSegment {
|
|
|
8
8
|
}
|
|
9
9
|
export default class ListExpression extends Expression {
|
|
10
10
|
expr: ExpressionSegment;
|
|
11
|
-
constructor(ast: ASTListConstructorExpression
|
|
11
|
+
constructor(ast: ASTListConstructorExpression);
|
|
12
|
+
prepare(visit: Function): Promise<ListExpression>;
|
|
12
13
|
get(operationContext: OperationContext, parentExpr: any): Promise<CustomList>;
|
|
13
14
|
}
|
package/dist/expressions/list.js
CHANGED
|
@@ -67,18 +67,33 @@ var ExpressionSegment = /** @class */ (function () {
|
|
|
67
67
|
exports.ExpressionSegment = ExpressionSegment;
|
|
68
68
|
var ListExpression = /** @class */ (function (_super) {
|
|
69
69
|
__extends(ListExpression, _super);
|
|
70
|
-
function ListExpression(ast
|
|
70
|
+
function ListExpression(ast) {
|
|
71
71
|
var _this = _super.call(this) || this;
|
|
72
72
|
var me = _this;
|
|
73
|
-
var buildExpression = function (node) {
|
|
74
|
-
return new ExpressionSegment(node.fields.map(function (item) {
|
|
75
|
-
return visit(item.value);
|
|
76
|
-
}));
|
|
77
|
-
};
|
|
78
73
|
me.ast = ast;
|
|
79
|
-
me.expr =
|
|
74
|
+
me.expr = null;
|
|
80
75
|
return _this;
|
|
81
76
|
}
|
|
77
|
+
ListExpression.prototype.prepare = function (visit) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var me, node, _a, _b;
|
|
80
|
+
return __generator(this, function (_c) {
|
|
81
|
+
switch (_c.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
me = this;
|
|
84
|
+
node = me.ast;
|
|
85
|
+
_a = me;
|
|
86
|
+
_b = ExpressionSegment.bind;
|
|
87
|
+
return [4 /*yield*/, Promise.all(node.fields.map(function (item) {
|
|
88
|
+
return visit(item.value);
|
|
89
|
+
}))];
|
|
90
|
+
case 1:
|
|
91
|
+
_a.expr = new (_b.apply(ExpressionSegment, [void 0, _c.sent()]))();
|
|
92
|
+
return [2 /*return*/, me];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
82
97
|
ListExpression.prototype.get = function (operationContext, parentExpr) {
|
|
83
98
|
var me = this;
|
|
84
99
|
var evaluate = function (node) {
|
|
@@ -17,6 +17,7 @@ export declare class ExpressionSegment {
|
|
|
17
17
|
}
|
|
18
18
|
export default class LogicalAndBinaryExpression extends Expression {
|
|
19
19
|
expr: ExpressionSegment;
|
|
20
|
-
constructor(ast: ASTEvaluationExpression
|
|
20
|
+
constructor(ast: ASTEvaluationExpression);
|
|
21
|
+
prepare(visit: Function): Promise<LogicalAndBinaryExpression>;
|
|
21
22
|
get(operationContext: OperationContext): Promise<any>;
|
|
22
23
|
}
|
|
@@ -123,16 +123,36 @@ var ExpressionSegment = /** @class */ (function () {
|
|
|
123
123
|
exports.ExpressionSegment = ExpressionSegment;
|
|
124
124
|
var LogicalAndBinaryExpression = /** @class */ (function (_super) {
|
|
125
125
|
__extends(LogicalAndBinaryExpression, _super);
|
|
126
|
-
function LogicalAndBinaryExpression(ast
|
|
126
|
+
function LogicalAndBinaryExpression(ast) {
|
|
127
127
|
var _this = _super.call(this) || this;
|
|
128
128
|
var me = _this;
|
|
129
|
-
var buildExpression = function (node) {
|
|
130
|
-
return new ExpressionSegment(node.type, node.operator, visit(node.left), visit(node.right));
|
|
131
|
-
};
|
|
132
129
|
me.ast = ast;
|
|
133
|
-
me.expr =
|
|
130
|
+
me.expr = null;
|
|
134
131
|
return _this;
|
|
135
132
|
}
|
|
133
|
+
LogicalAndBinaryExpression.prototype.prepare = function (visit) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
+
var me, node, _a, _b, _c;
|
|
136
|
+
return __generator(this, function (_d) {
|
|
137
|
+
switch (_d.label) {
|
|
138
|
+
case 0:
|
|
139
|
+
me = this;
|
|
140
|
+
node = me.ast;
|
|
141
|
+
_a = me;
|
|
142
|
+
_b = ExpressionSegment.bind;
|
|
143
|
+
_c = [void 0, node.type,
|
|
144
|
+
node.operator];
|
|
145
|
+
return [4 /*yield*/, visit(node.left)];
|
|
146
|
+
case 1:
|
|
147
|
+
_c = _c.concat([_d.sent()]);
|
|
148
|
+
return [4 /*yield*/, visit(node.right)];
|
|
149
|
+
case 2:
|
|
150
|
+
_a.expr = new (_b.apply(ExpressionSegment, _c.concat([_d.sent()])))();
|
|
151
|
+
return [2 /*return*/, me];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
136
156
|
LogicalAndBinaryExpression.prototype.get = function (operationContext) {
|
|
137
157
|
var _this = this;
|
|
138
158
|
var me = this;
|
|
@@ -13,6 +13,7 @@ export declare class ExpressionSegment {
|
|
|
13
13
|
}
|
|
14
14
|
export default class MapExpression extends Expression {
|
|
15
15
|
expr: ExpressionSegment;
|
|
16
|
-
constructor(ast: ASTMapConstructorExpression
|
|
16
|
+
constructor(ast: ASTMapConstructorExpression);
|
|
17
|
+
prepare(visit: Function): Promise<MapExpression>;
|
|
17
18
|
get(operationContext: OperationContext, parentExpr: any): Promise<CustomMap>;
|
|
18
19
|
}
|
package/dist/expressions/map.js
CHANGED
|
@@ -87,21 +87,46 @@ var ExpressionSegment = /** @class */ (function () {
|
|
|
87
87
|
exports.ExpressionSegment = ExpressionSegment;
|
|
88
88
|
var MapExpression = /** @class */ (function (_super) {
|
|
89
89
|
__extends(MapExpression, _super);
|
|
90
|
-
function MapExpression(ast
|
|
90
|
+
function MapExpression(ast) {
|
|
91
91
|
var _this = _super.call(this) || this;
|
|
92
92
|
var me = _this;
|
|
93
|
-
var buildExpression = function (node) {
|
|
94
|
-
return new ExpressionSegment(node.fields.map(function (item) {
|
|
95
|
-
return {
|
|
96
|
-
key: visit(item.key),
|
|
97
|
-
value: visit(item.value)
|
|
98
|
-
};
|
|
99
|
-
}));
|
|
100
|
-
};
|
|
101
93
|
me.ast = ast;
|
|
102
|
-
me.expr =
|
|
94
|
+
me.expr = null;
|
|
103
95
|
return _this;
|
|
104
96
|
}
|
|
97
|
+
MapExpression.prototype.prepare = function (visit) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
var me, node, _a, _b;
|
|
100
|
+
var _this = this;
|
|
101
|
+
return __generator(this, function (_c) {
|
|
102
|
+
switch (_c.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
me = this;
|
|
105
|
+
node = me.ast;
|
|
106
|
+
_a = me;
|
|
107
|
+
_b = ExpressionSegment.bind;
|
|
108
|
+
return [4 /*yield*/, Promise.all(node.fields.map(function (item) { return __awaiter(_this, void 0, void 0, function () {
|
|
109
|
+
var _a;
|
|
110
|
+
return __generator(this, function (_b) {
|
|
111
|
+
switch (_b.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
_a = {};
|
|
114
|
+
return [4 /*yield*/, visit(item.key)];
|
|
115
|
+
case 1:
|
|
116
|
+
_a.key = _b.sent();
|
|
117
|
+
return [4 /*yield*/, visit(item.value)];
|
|
118
|
+
case 2: return [2 /*return*/, (_a.value = _b.sent(),
|
|
119
|
+
_a)];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}); }))];
|
|
123
|
+
case 1:
|
|
124
|
+
_a.expr = new (_b.apply(ExpressionSegment, [void 0, _c.sent()]))();
|
|
125
|
+
return [2 /*return*/, me];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
105
130
|
MapExpression.prototype.get = function (operationContext, parentExpr) {
|
|
106
131
|
var me = this;
|
|
107
132
|
var evaluate = function (values) {
|
|
@@ -25,6 +25,7 @@ export declare class ExpressionSegment {
|
|
|
25
25
|
}
|
|
26
26
|
export default class PathExpression extends Expression {
|
|
27
27
|
expr: ExpressionSegment;
|
|
28
|
-
constructor(ast: ASTBase
|
|
28
|
+
constructor(ast: ASTBase);
|
|
29
|
+
prepare(visit: Function): Promise<PathExpression>;
|
|
29
30
|
get(operationContext: OperationContext, parentExpr: any): Promise<any>;
|
|
30
31
|
}
|