greybel-interpreter 0.3.8 → 0.3.9
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 +4 -5
- package/dist/context.js +11 -4
- package/dist/operations/body.js +17 -22
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import CustomMap from './custom-types/map';
|
|
2
|
-
import { Operation } from './types/operation';
|
|
3
|
-
import { Expression } from './types/expression';
|
|
4
2
|
import { Callable } from './types/custom-type';
|
|
5
|
-
import {
|
|
3
|
+
import { ASTBase } from 'greybel-core';
|
|
6
4
|
import CPS from './cps';
|
|
7
5
|
export declare enum ContextType {
|
|
8
6
|
API = "API",
|
|
@@ -36,7 +34,7 @@ export declare class Debugger {
|
|
|
36
34
|
getBreakpoint(operationContext: OperationContext): boolean;
|
|
37
35
|
next(): Debugger;
|
|
38
36
|
resume(): Promise<void>;
|
|
39
|
-
interact(operationContext: OperationContext, item:
|
|
37
|
+
interact(operationContext: OperationContext, item: ASTBase): void;
|
|
40
38
|
run(code: string): Promise<void>;
|
|
41
39
|
}
|
|
42
40
|
export interface OperationContextProcessState {
|
|
@@ -60,7 +58,7 @@ export interface OperationContextForkOptions {
|
|
|
60
58
|
}
|
|
61
59
|
export declare class OperationContext {
|
|
62
60
|
target: string;
|
|
63
|
-
|
|
61
|
+
stackItem: ASTBase | null;
|
|
64
62
|
debugger: Debugger;
|
|
65
63
|
previous: OperationContext | null;
|
|
66
64
|
type: ContextType;
|
|
@@ -74,6 +72,7 @@ export declare class OperationContext {
|
|
|
74
72
|
locals: Scope | null;
|
|
75
73
|
globals: Scope | null;
|
|
76
74
|
constructor(options: OperationContextOptions);
|
|
75
|
+
step(item: ASTBase): Promise<void>;
|
|
77
76
|
exit(): Promise<OperationContext>;
|
|
78
77
|
setPending(pending: boolean): OperationContext;
|
|
79
78
|
isExit(): boolean;
|
package/dist/context.js
CHANGED
|
@@ -292,10 +292,7 @@ var OperationContext = /** @class */ (function () {
|
|
|
292
292
|
function OperationContext(options) {
|
|
293
293
|
var me = this;
|
|
294
294
|
me.target = options.target || 'unknown';
|
|
295
|
-
me.
|
|
296
|
-
line: 0,
|
|
297
|
-
character: 0
|
|
298
|
-
};
|
|
295
|
+
me.stackItem = null;
|
|
299
296
|
me.previous = options.previous || null;
|
|
300
297
|
me.type = options.type || ContextType.API;
|
|
301
298
|
me.state = options.state || ContextState.DEFAULT;
|
|
@@ -312,6 +309,16 @@ var OperationContext = /** @class */ (function () {
|
|
|
312
309
|
me.globals = me.lookupGlobals();
|
|
313
310
|
me.locals = me.lookupLocals();
|
|
314
311
|
}
|
|
312
|
+
OperationContext.prototype.step = function (item) {
|
|
313
|
+
var me = this;
|
|
314
|
+
var dbgr = me.debugger;
|
|
315
|
+
me.stackItem = item;
|
|
316
|
+
if (dbgr.getBreakpoint(me)) {
|
|
317
|
+
dbgr.interact(me, item);
|
|
318
|
+
return dbgr.resume();
|
|
319
|
+
}
|
|
320
|
+
return Promise.resolve();
|
|
321
|
+
};
|
|
315
322
|
OperationContext.prototype.exit = function () {
|
|
316
323
|
var me = this;
|
|
317
324
|
var state = me.processState;
|
package/dist/operations/body.js
CHANGED
|
@@ -94,48 +94,43 @@ var BodyOperation = /** @class */ (function (_super) {
|
|
|
94
94
|
}
|
|
95
95
|
_d.label = 1;
|
|
96
96
|
case 1:
|
|
97
|
-
_d.trys.push([1, 11, 12
|
|
97
|
+
_d.trys.push([1, 10, 11, 12]);
|
|
98
98
|
_a = __values(me.stack), _b = _a.next();
|
|
99
99
|
_d.label = 2;
|
|
100
100
|
case 2:
|
|
101
|
-
if (!!_b.done) return [3 /*break*/,
|
|
101
|
+
if (!!_b.done) return [3 /*break*/, 9];
|
|
102
102
|
entity = _b.value;
|
|
103
|
-
operationContext.
|
|
104
|
-
if (!dbgr.getBreakpoint(operationContext)) return [3 /*break*/, 4];
|
|
105
|
-
dbgr.interact(operationContext, entity);
|
|
106
|
-
return [4 /*yield*/, dbgr.resume()];
|
|
103
|
+
return [4 /*yield*/, operationContext.step(entity.ast)];
|
|
107
104
|
case 3:
|
|
108
105
|
_d.sent();
|
|
109
|
-
|
|
110
|
-
case 4:
|
|
111
|
-
if (!(entity instanceof expression_1.Expression)) return [3 /*break*/, 6];
|
|
106
|
+
if (!(entity instanceof expression_1.Expression)) return [3 /*break*/, 5];
|
|
112
107
|
return [4 /*yield*/, entity.get(operationContext)];
|
|
113
|
-
case
|
|
108
|
+
case 4:
|
|
114
109
|
_d.sent();
|
|
115
|
-
return [3 /*break*/,
|
|
116
|
-
case
|
|
117
|
-
case
|
|
110
|
+
return [3 /*break*/, 7];
|
|
111
|
+
case 5: return [4 /*yield*/, entity.run(operationContext)];
|
|
112
|
+
case 6:
|
|
118
113
|
_d.sent();
|
|
114
|
+
_d.label = 7;
|
|
115
|
+
case 7:
|
|
116
|
+
if (isEOL() || operationContext.isExit())
|
|
117
|
+
return [3 /*break*/, 9];
|
|
119
118
|
_d.label = 8;
|
|
120
119
|
case 8:
|
|
121
|
-
if (isEOL() || operationContext.isExit())
|
|
122
|
-
return [3 /*break*/, 10];
|
|
123
|
-
_d.label = 9;
|
|
124
|
-
case 9:
|
|
125
120
|
_b = _a.next();
|
|
126
121
|
return [3 /*break*/, 2];
|
|
127
|
-
case
|
|
128
|
-
case
|
|
122
|
+
case 9: return [3 /*break*/, 12];
|
|
123
|
+
case 10:
|
|
129
124
|
e_1_1 = _d.sent();
|
|
130
125
|
e_1 = { error: e_1_1 };
|
|
131
|
-
return [3 /*break*/,
|
|
132
|
-
case
|
|
126
|
+
return [3 /*break*/, 12];
|
|
127
|
+
case 11:
|
|
133
128
|
try {
|
|
134
129
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
135
130
|
}
|
|
136
131
|
finally { if (e_1) throw e_1.error; }
|
|
137
132
|
return [7 /*endfinally*/];
|
|
138
|
-
case
|
|
133
|
+
case 12: return [2 /*return*/];
|
|
139
134
|
}
|
|
140
135
|
});
|
|
141
136
|
});
|