greybel-interpreter 0.3.0 → 0.3.1
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.d.ts +5 -0
- package/dist/context.js +29 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/interpreter.d.ts +10 -6
- package/dist/interpreter.js +106 -48
- package/dist/operations/body.js +1 -1
- package/package.json +1 -1
- package/dist/operations/top.d.ts +0 -12
- package/dist/operations/top.js +0 -86
package/dist/context.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare class Debugger {
|
|
|
40
40
|
}
|
|
41
41
|
export interface OperationContextProcessState {
|
|
42
42
|
exit: boolean;
|
|
43
|
+
pending: boolean;
|
|
43
44
|
}
|
|
44
45
|
export interface OperationContextOptions {
|
|
45
46
|
target?: string;
|
|
@@ -72,6 +73,10 @@ export declare class OperationContext {
|
|
|
72
73
|
locals: Scope | null;
|
|
73
74
|
globals: Scope | null;
|
|
74
75
|
constructor(options: OperationContextOptions);
|
|
76
|
+
exit(): Promise<OperationContext>;
|
|
77
|
+
setPending(pending: boolean): OperationContext;
|
|
78
|
+
isExit(): boolean;
|
|
79
|
+
isPending(): boolean;
|
|
75
80
|
lookupType(validate: (type: ContextType) => boolean): Scope;
|
|
76
81
|
lookupAPI(): Scope;
|
|
77
82
|
lookupGlobals(): Scope;
|
package/dist/context.js
CHANGED
|
@@ -302,12 +302,40 @@ var OperationContext = /** @class */ (function () {
|
|
|
302
302
|
me.debugger = options.debugger || new Debugger();
|
|
303
303
|
me.cps = options.cps;
|
|
304
304
|
me.processState = options.processState || {
|
|
305
|
-
exit: false
|
|
305
|
+
exit: false,
|
|
306
|
+
pending: false
|
|
306
307
|
};
|
|
307
308
|
me.api = me.lookupAPI();
|
|
308
309
|
me.globals = me.lookupGlobals();
|
|
309
310
|
me.locals = me.lookupLocals();
|
|
310
311
|
}
|
|
312
|
+
OperationContext.prototype.exit = function () {
|
|
313
|
+
var me = this;
|
|
314
|
+
var state = me.processState;
|
|
315
|
+
if (state.pending) {
|
|
316
|
+
state.exit = true;
|
|
317
|
+
return new Promise(function (resolve) {
|
|
318
|
+
setImmediate(function () {
|
|
319
|
+
if (!state.pending) {
|
|
320
|
+
state.exit = false;
|
|
321
|
+
resolve(me);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
return Promise.reject(new Error('No running process found.'));
|
|
327
|
+
};
|
|
328
|
+
OperationContext.prototype.setPending = function (pending) {
|
|
329
|
+
var me = this;
|
|
330
|
+
me.processState.pending = pending;
|
|
331
|
+
return me;
|
|
332
|
+
};
|
|
333
|
+
OperationContext.prototype.isExit = function () {
|
|
334
|
+
return this.processState.exit;
|
|
335
|
+
};
|
|
336
|
+
OperationContext.prototype.isPending = function () {
|
|
337
|
+
return this.processState.exit;
|
|
338
|
+
};
|
|
311
339
|
OperationContext.prototype.lookupType = function (validate) {
|
|
312
340
|
var me = this;
|
|
313
341
|
if (validate(me.type)) {
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export { default as ElseOperation } from './operations/else';
|
|
|
19
19
|
export { default as ContinueOperation } from './operations/continue';
|
|
20
20
|
export { default as BreakOperation } from './operations/break';
|
|
21
21
|
export { default as BodyOperation } from './operations/body';
|
|
22
|
-
export { default as TopOperation } from './operations/top';
|
|
23
22
|
export { default as DebuggerOperation } from './operations/debugger';
|
|
24
23
|
export { default as CustomBoolean } from './custom-types/boolean';
|
|
25
24
|
export { default as CustomNumber } from './custom-types/number';
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.toCustomValue = exports.isCustomNumber = exports.isCustomString = exports.isCustomList = exports.isCustomMap = exports.isCustomValue = exports.Interpreter = exports.CPSMap = exports.CPS = exports.CustomList = exports.CustomMap = exports.CustomNil = exports.CustomString = exports.CustomNumber = exports.CustomBoolean = exports.DebuggerOperation = exports.
|
|
16
|
+
exports.toCustomValue = exports.isCustomNumber = exports.isCustomString = exports.isCustomList = exports.isCustomMap = exports.isCustomValue = exports.Interpreter = exports.CPSMap = exports.CPS = exports.CustomList = exports.CustomMap = exports.CustomNil = exports.CustomString = exports.CustomNumber = exports.CustomBoolean = exports.DebuggerOperation = exports.BodyOperation = exports.BreakOperation = exports.ContinueOperation = exports.ElseOperation = exports.ElseIfOperation = exports.IfOperation = exports.IfStatementOperation = exports.NotOperation = exports.NewOperation = exports.ReturnOperation = exports.FunctionOperation = exports.ForOperation = exports.WhileOperation = exports.ArgumentOperation = exports.BinaryNegatedExpression = exports.PathExpression = exports.MapExpression = exports.LogicalAndBinaryExpression = exports.ListExpression = exports.CallExpression = exports.AssignExpression = void 0;
|
|
17
17
|
var assign_1 = require("./expressions/assign");
|
|
18
18
|
Object.defineProperty(exports, "AssignExpression", { enumerable: true, get: function () { return __importDefault(assign_1).default; } });
|
|
19
19
|
var call_1 = require("./expressions/call");
|
|
@@ -56,8 +56,6 @@ var break_1 = require("./operations/break");
|
|
|
56
56
|
Object.defineProperty(exports, "BreakOperation", { enumerable: true, get: function () { return __importDefault(break_1).default; } });
|
|
57
57
|
var body_1 = require("./operations/body");
|
|
58
58
|
Object.defineProperty(exports, "BodyOperation", { enumerable: true, get: function () { return __importDefault(body_1).default; } });
|
|
59
|
-
var top_1 = require("./operations/top");
|
|
60
|
-
Object.defineProperty(exports, "TopOperation", { enumerable: true, get: function () { return __importDefault(top_1).default; } });
|
|
61
59
|
var debugger_1 = require("./operations/debugger");
|
|
62
60
|
Object.defineProperty(exports, "DebuggerOperation", { enumerable: true, get: function () { return __importDefault(debugger_1).default; } });
|
|
63
61
|
var boolean_1 = require("./custom-types/boolean");
|
package/dist/interpreter.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import CPS from './cps';
|
|
1
3
|
import { OperationContext, Debugger } from './context';
|
|
2
4
|
import { ResourceHandler } from './resource';
|
|
5
|
+
import EventEmitter from 'events';
|
|
3
6
|
export interface InterpreterOptions {
|
|
4
7
|
target?: string;
|
|
5
|
-
code?: string;
|
|
6
8
|
api?: Map<string, any>;
|
|
7
9
|
params?: any[];
|
|
8
10
|
resourceHandler?: ResourceHandler;
|
|
9
11
|
debugger?: Debugger;
|
|
10
12
|
}
|
|
11
|
-
export default class Interpreter {
|
|
13
|
+
export default class Interpreter extends EventEmitter {
|
|
12
14
|
target: string;
|
|
13
|
-
code: string | null;
|
|
14
15
|
api: Map<string, any>;
|
|
15
16
|
params: any[];
|
|
16
17
|
resourceHandler: ResourceHandler;
|
|
17
18
|
debugger: Debugger;
|
|
18
|
-
|
|
19
|
+
apiContext: OperationContext;
|
|
20
|
+
globalContext: OperationContext;
|
|
21
|
+
cps: CPS;
|
|
19
22
|
constructor(options: InterpreterOptions);
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
inject(code: string): Promise<Interpreter>;
|
|
24
|
+
digest(customCode?: string): Promise<Interpreter>;
|
|
25
|
+
exit(): Promise<OperationContext>;
|
|
22
26
|
}
|
package/dist/interpreter.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -43,80 +58,123 @@ var cps_1 = __importDefault(require("./cps"));
|
|
|
43
58
|
var context_1 = require("./context");
|
|
44
59
|
var greybel_core_1 = require("greybel-core");
|
|
45
60
|
var resource_1 = require("./resource");
|
|
46
|
-
var top_1 = __importDefault(require("./operations/top"));
|
|
47
61
|
var typer_1 = require("./typer");
|
|
62
|
+
var events_1 = __importDefault(require("events"));
|
|
48
63
|
;
|
|
49
|
-
var Interpreter = /** @class */ (function () {
|
|
64
|
+
var Interpreter = /** @class */ (function (_super) {
|
|
65
|
+
__extends(Interpreter, _super);
|
|
50
66
|
function Interpreter(options) {
|
|
51
|
-
var
|
|
67
|
+
var _this = _super.call(this) || this;
|
|
68
|
+
var me = _this;
|
|
52
69
|
me.resourceHandler = options.resourceHandler || new resource_1.ResourceProvider().getHandler();
|
|
53
70
|
me.debugger = options.debugger || new context_1.Debugger();
|
|
54
71
|
me.api = options.api || new Map();
|
|
55
72
|
me.params = options.params || [];
|
|
56
|
-
me.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
me.
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
me.target
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
me.target = options.target || 'unknown';
|
|
74
|
+
me.cps = new cps_1.default({
|
|
75
|
+
target: me.target,
|
|
76
|
+
resourceHandler: me.resourceHandler
|
|
77
|
+
});
|
|
78
|
+
me.apiContext = new context_1.OperationContext({
|
|
79
|
+
target: me.target,
|
|
80
|
+
isProtected: true,
|
|
81
|
+
debugger: me.debugger,
|
|
82
|
+
cps: me.cps
|
|
83
|
+
});
|
|
84
|
+
me.globalContext = me.apiContext.fork({
|
|
85
|
+
type: context_1.ContextType.GLOBAL,
|
|
86
|
+
state: context_1.ContextState.DEFAULT
|
|
87
|
+
});
|
|
88
|
+
return _this;
|
|
65
89
|
}
|
|
66
|
-
Interpreter.prototype.
|
|
90
|
+
Interpreter.prototype.inject = function (code) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var me, parser, chunk, body, err_1;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
me = this;
|
|
97
|
+
parser = new greybel_core_1.Parser(code);
|
|
98
|
+
chunk = parser.parseChunk();
|
|
99
|
+
return [4 /*yield*/, me.cps.visit(chunk)];
|
|
100
|
+
case 1:
|
|
101
|
+
body = _a.sent();
|
|
102
|
+
_a.label = 2;
|
|
103
|
+
case 2:
|
|
104
|
+
_a.trys.push([2, 4, , 5]);
|
|
105
|
+
return [4 /*yield*/, body.run(me.globalContext)];
|
|
106
|
+
case 3:
|
|
107
|
+
_a.sent();
|
|
108
|
+
return [3 /*break*/, 5];
|
|
109
|
+
case 4:
|
|
110
|
+
err_1 = _a.sent();
|
|
111
|
+
me.debugger.raise(err_1);
|
|
112
|
+
return [3 /*break*/, 5];
|
|
113
|
+
case 5: return [2 /*return*/, me];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
Interpreter.prototype.digest = function (customCode) {
|
|
67
119
|
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
-
var me, code, _a, parser, chunk,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
switch (_e.label) {
|
|
120
|
+
var me, code, _a, parser, chunk, body, process_1, err_2;
|
|
121
|
+
return __generator(this, function (_b) {
|
|
122
|
+
switch (_b.label) {
|
|
72
123
|
case 0:
|
|
73
124
|
me = this;
|
|
74
|
-
|
|
125
|
+
if (me.apiContext.isPending()) {
|
|
126
|
+
return [2 /*return*/, Promise.reject(new Error('Process already running.'))];
|
|
127
|
+
}
|
|
128
|
+
_a = customCode;
|
|
75
129
|
if (_a) return [3 /*break*/, 2];
|
|
76
130
|
return [4 /*yield*/, me.resourceHandler.get(me.target)];
|
|
77
131
|
case 1:
|
|
78
|
-
_a = (
|
|
79
|
-
|
|
132
|
+
_a = (_b.sent());
|
|
133
|
+
_b.label = 2;
|
|
80
134
|
case 2:
|
|
81
135
|
code = _a;
|
|
82
136
|
parser = new greybel_core_1.Parser(code);
|
|
83
137
|
chunk = parser.parseChunk();
|
|
84
|
-
|
|
85
|
-
target: me.target,
|
|
86
|
-
resourceHandler: me.resourceHandler
|
|
87
|
-
});
|
|
88
|
-
mainContext = new context_1.OperationContext({
|
|
89
|
-
target: me.target,
|
|
90
|
-
isProtected: true,
|
|
91
|
-
debugger: me.debugger,
|
|
92
|
-
cps: cps
|
|
93
|
-
});
|
|
94
|
-
_b = top_1.default.bind;
|
|
95
|
-
_c = [void 0, null];
|
|
96
|
-
_d = {};
|
|
97
|
-
return [4 /*yield*/, cps.visit(chunk)];
|
|
138
|
+
return [4 /*yield*/, me.cps.visit(chunk)];
|
|
98
139
|
case 3:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
140
|
+
body = _b.sent();
|
|
141
|
+
me.apiContext.extend(me.api);
|
|
142
|
+
me.globalContext.scope.value.set('params', (0, typer_1.cast)(me.params));
|
|
143
|
+
me.emit('setup', me);
|
|
144
|
+
_b.label = 4;
|
|
145
|
+
case 4:
|
|
146
|
+
_b.trys.push([4, 6, 7, 8]);
|
|
147
|
+
me.apiContext.setPending(true);
|
|
148
|
+
process_1 = body.run(me.globalContext);
|
|
149
|
+
me.emit('start');
|
|
150
|
+
return [4 /*yield*/, process_1];
|
|
151
|
+
case 5:
|
|
152
|
+
_b.sent();
|
|
153
|
+
return [3 /*break*/, 8];
|
|
154
|
+
case 6:
|
|
155
|
+
err_2 = _b.sent();
|
|
156
|
+
me.debugger.raise(err_2);
|
|
157
|
+
return [3 /*break*/, 8];
|
|
158
|
+
case 7:
|
|
159
|
+
me.apiContext.setPending(false);
|
|
160
|
+
setImmediate(function () {
|
|
161
|
+
me.emit('exit', me);
|
|
162
|
+
});
|
|
163
|
+
return [7 /*endfinally*/];
|
|
164
|
+
case 8: return [2 /*return*/, me];
|
|
109
165
|
}
|
|
110
166
|
});
|
|
111
167
|
});
|
|
112
168
|
};
|
|
113
169
|
Interpreter.prototype.exit = function () {
|
|
114
170
|
var me = this;
|
|
115
|
-
|
|
116
|
-
|
|
171
|
+
try {
|
|
172
|
+
return me.apiContext.exit();
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
me.debugger.raise(err);
|
|
117
176
|
}
|
|
118
|
-
me.context.processState.exit = true;
|
|
119
177
|
};
|
|
120
178
|
return Interpreter;
|
|
121
|
-
}());
|
|
179
|
+
}(events_1.default));
|
|
122
180
|
exports.default = Interpreter;
|
package/dist/operations/body.js
CHANGED
|
@@ -118,7 +118,7 @@ var BodyOperation = /** @class */ (function (_super) {
|
|
|
118
118
|
_d.sent();
|
|
119
119
|
_d.label = 8;
|
|
120
120
|
case 8:
|
|
121
|
-
if (isEOL() || operationContext.
|
|
121
|
+
if (isEOL() || operationContext.isExit())
|
|
122
122
|
return [3 /*break*/, 10];
|
|
123
123
|
_d.label = 9;
|
|
124
124
|
case 9:
|
package/package.json
CHANGED
package/dist/operations/top.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Operation } from '../types/operation';
|
|
2
|
-
import { OperationContext } from '../context';
|
|
3
|
-
import { ASTBase } from 'greybel-core';
|
|
4
|
-
import BodyOperation from './body';
|
|
5
|
-
export interface ReturnOperationOptions {
|
|
6
|
-
body: BodyOperation;
|
|
7
|
-
}
|
|
8
|
-
export default class TopOperation extends Operation {
|
|
9
|
-
body: BodyOperation;
|
|
10
|
-
constructor(ast: ASTBase, options: ReturnOperationOptions);
|
|
11
|
-
run(operationContext: OperationContext): Promise<void>;
|
|
12
|
-
}
|
package/dist/operations/top.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
var operation_1 = require("../types/operation");
|
|
55
|
-
var context_1 = require("../context");
|
|
56
|
-
var TopOperation = /** @class */ (function (_super) {
|
|
57
|
-
__extends(TopOperation, _super);
|
|
58
|
-
function TopOperation(ast, options) {
|
|
59
|
-
var _this = _super.call(this) || this;
|
|
60
|
-
var me = _this;
|
|
61
|
-
me.ast = ast;
|
|
62
|
-
me.body = options.body;
|
|
63
|
-
return _this;
|
|
64
|
-
}
|
|
65
|
-
TopOperation.prototype.run = function (operationContext) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var me, opc;
|
|
68
|
-
return __generator(this, function (_a) {
|
|
69
|
-
switch (_a.label) {
|
|
70
|
-
case 0:
|
|
71
|
-
me = this;
|
|
72
|
-
opc = operationContext.fork({
|
|
73
|
-
type: context_1.ContextType.GLOBAL,
|
|
74
|
-
state: context_1.ContextState.DEFAULT
|
|
75
|
-
});
|
|
76
|
-
return [4 /*yield*/, me.body.run(opc)];
|
|
77
|
-
case 1:
|
|
78
|
-
_a.sent();
|
|
79
|
-
return [2 /*return*/];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
return TopOperation;
|
|
85
|
-
}(operation_1.Operation));
|
|
86
|
-
exports.default = TopOperation;
|