greybel-interpreter 1.4.4 → 1.4.6
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 +3 -2
- package/dist/context.js +113 -190
- package/dist/cps.js +135 -188
- package/dist/handler/error.js +6 -29
- package/dist/handler/output.js +15 -38
- package/dist/handler/resource.js +16 -39
- package/dist/handler-container.js +6 -8
- package/dist/index.d.ts +4 -3
- package/dist/index.js +10 -9
- package/dist/interpreter.d.ts +5 -4
- package/dist/interpreter.js +109 -203
- package/dist/operations/assign.d.ts +1 -1
- package/dist/operations/assign.js +28 -93
- package/dist/operations/block.d.ts +1 -1
- package/dist/operations/block.js +33 -89
- package/dist/operations/break.d.ts +1 -1
- package/dist/operations/break.js +11 -29
- package/dist/operations/call.d.ts +1 -1
- package/dist/operations/call.js +31 -106
- package/dist/operations/chunk.d.ts +1 -1
- package/dist/operations/chunk.js +15 -67
- package/dist/operations/continue.d.ts +1 -1
- package/dist/operations/continue.js +11 -29
- package/dist/operations/debugger-statement.d.ts +1 -1
- package/dist/operations/debugger-statement.js +11 -29
- package/dist/operations/evaluate.d.ts +1 -1
- package/dist/operations/evaluate.js +143 -247
- package/dist/operations/for.d.ts +1 -1
- package/dist/operations/for.js +62 -133
- package/dist/operations/function-reference.d.ts +1 -1
- package/dist/operations/function-reference.js +25 -84
- package/dist/operations/function.d.ts +1 -1
- package/dist/operations/function.js +49 -177
- package/dist/operations/if-statement.d.ts +1 -1
- package/dist/operations/if-statement.js +58 -154
- package/dist/operations/import.d.ts +1 -1
- package/dist/operations/import.js +35 -97
- package/dist/operations/include.d.ts +1 -1
- package/dist/operations/include.js +19 -73
- package/dist/operations/list.d.ts +1 -1
- package/dist/operations/list.js +24 -93
- package/dist/operations/literal.d.ts +1 -1
- package/dist/operations/literal.js +15 -33
- package/dist/operations/map.d.ts +1 -1
- package/dist/operations/map.js +26 -153
- package/dist/operations/negated-binary.d.ts +1 -1
- package/dist/operations/negated-binary.js +24 -91
- package/dist/operations/new-instance.d.ts +1 -1
- package/dist/operations/new-instance.js +21 -82
- package/dist/operations/noop.d.ts +1 -1
- package/dist/operations/noop.js +10 -27
- package/dist/operations/not.d.ts +1 -1
- package/dist/operations/not.js +17 -78
- package/dist/operations/operation.d.ts +2 -2
- package/dist/operations/operation.js +3 -5
- package/dist/operations/reference.d.ts +1 -1
- package/dist/operations/reference.js +10 -28
- package/dist/operations/resolve.d.ts +1 -1
- package/dist/operations/resolve.js +161 -281
- package/dist/operations/return.d.ts +1 -1
- package/dist/operations/return.js +27 -89
- package/dist/operations/while.d.ts +1 -1
- package/dist/operations/while.js +45 -116
- package/dist/types/base.d.ts +9 -0
- package/dist/types/base.js +5 -0
- package/dist/types/boolean.d.ts +3 -1
- package/dist/types/boolean.js +24 -36
- package/dist/types/default.d.ts +6 -9
- package/dist/types/default.js +11 -17
- package/dist/types/function.d.ts +1 -1
- package/dist/types/function.js +60 -130
- package/dist/types/interface.d.ts +2 -1
- package/dist/types/interface.js +44 -64
- package/dist/types/list.d.ts +4 -6
- package/dist/types/list.js +77 -128
- package/dist/types/map.d.ts +11 -15
- package/dist/types/map.js +101 -267
- package/dist/types/nil.d.ts +2 -1
- package/dist/types/nil.js +23 -36
- package/dist/types/number.d.ts +16 -2
- package/dist/types/number.js +60 -37
- package/dist/types/string.d.ts +4 -6
- package/dist/types/string.js +66 -90
- package/dist/types/{generics.d.ts → with-intrinsics.d.ts} +6 -9
- package/dist/types/with-intrinsics.js +19 -0
- package/dist/utils/deep-equal.js +9 -34
- package/dist/utils/object-value.d.ts +7 -0
- package/dist/utils/object-value.js +42 -0
- package/dist/utils/path.js +16 -43
- package/package.json +3 -3
- package/dist/intrinsics-container.d.ts +0 -7
- package/dist/intrinsics-container.js +0 -19
- package/dist/types/generics.js +0 -40
package/dist/context.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { ASTBase } from 'greyscript-core';
|
|
|
2
2
|
import CPS from './cps';
|
|
3
3
|
import HandlerContainer from './handler-container';
|
|
4
4
|
import Operation from './operations/operation';
|
|
5
|
-
import
|
|
5
|
+
import CustomValue from './types/base';
|
|
6
6
|
import CustomMap from './types/map';
|
|
7
7
|
import CustomNil from './types/nil';
|
|
8
|
+
import ObjectValue from './utils/object-value';
|
|
8
9
|
import Path from './utils/path';
|
|
9
10
|
export declare enum ContextType {
|
|
10
11
|
Api = 0,
|
|
@@ -102,7 +103,7 @@ export default class OperationContext {
|
|
|
102
103
|
lookupApi(): OperationContext;
|
|
103
104
|
lookupGlobals(): OperationContext;
|
|
104
105
|
lookupLocals(): OperationContext;
|
|
105
|
-
extend(map:
|
|
106
|
+
extend(map: ObjectValue): OperationContext;
|
|
106
107
|
set(path: Path<CustomValue> | CustomValue, value: CustomValue): void;
|
|
107
108
|
get(path: Path<CustomValue> | CustomValue): CustomValue;
|
|
108
109
|
fork(options: ContextForkOptions): OperationContext;
|
package/dist/context.js
CHANGED
|
@@ -1,54 +1,14 @@
|
|
|
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
|
-
})();
|
|
17
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
18
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
-
if (!m) return o;
|
|
20
|
-
var i = m.call(o), r, ar = [], e;
|
|
21
|
-
try {
|
|
22
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
23
|
-
}
|
|
24
|
-
catch (error) { e = { error: error }; }
|
|
25
|
-
finally {
|
|
26
|
-
try {
|
|
27
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28
|
-
}
|
|
29
|
-
finally { if (e) throw e.error; }
|
|
30
|
-
}
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
34
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
35
|
-
if (ar || !(i in from)) {
|
|
36
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
37
|
-
ar[i] = from[i];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
41
|
-
};
|
|
42
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
4
|
};
|
|
45
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
6
|
exports.FunctionState = exports.LoopState = exports.ProcessState = exports.Debugger = exports.Scope = exports.ContextState = exports.ContextType = void 0;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
7
|
+
const handler_container_1 = __importDefault(require("./handler-container"));
|
|
8
|
+
const base_1 = __importDefault(require("./types/base"));
|
|
9
|
+
const default_1 = __importDefault(require("./types/default"));
|
|
10
|
+
const map_1 = __importDefault(require("./types/map"));
|
|
11
|
+
const path_1 = __importDefault(require("./utils/path"));
|
|
52
12
|
var ContextType;
|
|
53
13
|
(function (ContextType) {
|
|
54
14
|
ContextType[ContextType["Api"] = 0] = "Api";
|
|
@@ -64,84 +24,72 @@ var ContextState;
|
|
|
64
24
|
ContextState[ContextState["Temporary"] = 0] = "Temporary";
|
|
65
25
|
ContextState[ContextState["Default"] = 1] = "Default";
|
|
66
26
|
})(ContextState = exports.ContextState || (exports.ContextState = {}));
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
_this.context = context;
|
|
72
|
-
return _this;
|
|
27
|
+
class Scope extends map_1.default {
|
|
28
|
+
constructor(context) {
|
|
29
|
+
super();
|
|
30
|
+
this.context = context;
|
|
73
31
|
}
|
|
74
|
-
|
|
75
|
-
if (path instanceof
|
|
32
|
+
get(path) {
|
|
33
|
+
if (path instanceof base_1.default) {
|
|
76
34
|
return this.get(new path_1.default([path]));
|
|
77
35
|
}
|
|
78
36
|
if (path.count() === 0) {
|
|
79
37
|
return this;
|
|
80
38
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
else if (this.has(path)) {
|
|
87
|
-
return _super.prototype.get.call(this, path);
|
|
39
|
+
const traversalPath = path.clone();
|
|
40
|
+
const current = traversalPath.next();
|
|
41
|
+
if (this.has(path)) {
|
|
42
|
+
return super.get(path);
|
|
88
43
|
}
|
|
89
44
|
else if (this.context.api.scope.has(path)) {
|
|
90
45
|
return this.context.api.scope.get(path);
|
|
91
46
|
}
|
|
92
|
-
else if (path.count() === 1 &&
|
|
93
|
-
map_1.default.getIntrinsics().
|
|
94
|
-
return map_1.default.getIntrinsics().get(current.toString());
|
|
47
|
+
else if (path.count() === 1 && map_1.default.getIntrinsics().has(current)) {
|
|
48
|
+
return map_1.default.getIntrinsics().get(current);
|
|
95
49
|
}
|
|
96
50
|
else if (this.context.previous !== null) {
|
|
97
51
|
return this.context.previous.get(path);
|
|
98
52
|
}
|
|
99
|
-
throw new Error(
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
}(map_1.default));
|
|
53
|
+
throw new Error(`Unknown path ${path.toString()}.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
103
56
|
exports.Scope = Scope;
|
|
104
|
-
|
|
105
|
-
|
|
57
|
+
class Debugger {
|
|
58
|
+
constructor() {
|
|
106
59
|
this.breakpoint = false;
|
|
107
60
|
this.nextStep = false;
|
|
108
61
|
/* eslint-disable no-use-before-define */
|
|
109
62
|
this.lastContext = null;
|
|
110
63
|
}
|
|
111
|
-
|
|
64
|
+
getLastContext() {
|
|
112
65
|
return this.lastContext;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
117
|
-
segments[_i] = arguments[_i];
|
|
118
|
-
}
|
|
119
|
-
console.debug.apply(console, __spreadArray([], __read(segments), false));
|
|
66
|
+
}
|
|
67
|
+
debug(...segments) {
|
|
68
|
+
console.debug(...segments);
|
|
120
69
|
return default_1.default.Void;
|
|
121
|
-
}
|
|
122
|
-
|
|
70
|
+
}
|
|
71
|
+
setBreakpoint(breakpoint) {
|
|
123
72
|
this.breakpoint = breakpoint;
|
|
124
73
|
return this;
|
|
125
|
-
}
|
|
126
|
-
|
|
74
|
+
}
|
|
75
|
+
getBreakpoint(_ctx) {
|
|
127
76
|
return this.breakpoint;
|
|
128
|
-
}
|
|
129
|
-
|
|
77
|
+
}
|
|
78
|
+
next() {
|
|
130
79
|
this.nextStep = true;
|
|
131
80
|
return this;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
var _this = this;
|
|
81
|
+
}
|
|
82
|
+
resume() {
|
|
135
83
|
if (!this.breakpoint) {
|
|
136
84
|
return Promise.resolve();
|
|
137
85
|
}
|
|
138
|
-
return new Promise(
|
|
139
|
-
|
|
140
|
-
if (!
|
|
86
|
+
return new Promise((resolve) => {
|
|
87
|
+
const check = () => {
|
|
88
|
+
if (!this.breakpoint) {
|
|
141
89
|
resolve();
|
|
142
90
|
}
|
|
143
|
-
else if (
|
|
144
|
-
|
|
91
|
+
else if (this.nextStep) {
|
|
92
|
+
this.nextStep = false;
|
|
145
93
|
resolve();
|
|
146
94
|
}
|
|
147
95
|
else {
|
|
@@ -150,45 +98,40 @@ var Debugger = /** @class */ (function () {
|
|
|
150
98
|
};
|
|
151
99
|
check();
|
|
152
100
|
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
101
|
+
}
|
|
102
|
+
interact(ctx, _ast, _op) {
|
|
103
|
+
const me = this;
|
|
156
104
|
console.warn('Debugger is not setup.');
|
|
157
105
|
console.info(ctx);
|
|
158
106
|
me.breakpoint = false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
}());
|
|
107
|
+
}
|
|
108
|
+
}
|
|
162
109
|
exports.Debugger = Debugger;
|
|
163
|
-
|
|
164
|
-
|
|
110
|
+
class ProcessState {
|
|
111
|
+
constructor() {
|
|
165
112
|
this.isExit = false;
|
|
166
113
|
this.isPending = false;
|
|
167
114
|
/* eslint-disable no-use-before-define */
|
|
168
115
|
this.last = null;
|
|
169
116
|
}
|
|
170
|
-
|
|
171
|
-
}());
|
|
117
|
+
}
|
|
172
118
|
exports.ProcessState = ProcessState;
|
|
173
|
-
|
|
174
|
-
|
|
119
|
+
class LoopState {
|
|
120
|
+
constructor() {
|
|
175
121
|
this.isBreak = false;
|
|
176
122
|
this.isContinue = false;
|
|
177
123
|
}
|
|
178
|
-
|
|
179
|
-
}());
|
|
124
|
+
}
|
|
180
125
|
exports.LoopState = LoopState;
|
|
181
|
-
|
|
182
|
-
|
|
126
|
+
class FunctionState {
|
|
127
|
+
constructor() {
|
|
183
128
|
this.value = default_1.default.Void;
|
|
184
129
|
this.isReturn = false;
|
|
185
130
|
}
|
|
186
|
-
|
|
187
|
-
}());
|
|
131
|
+
}
|
|
188
132
|
exports.FunctionState = FunctionState;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (options === void 0) { options = {}; }
|
|
133
|
+
class OperationContext {
|
|
134
|
+
constructor(options = {}) {
|
|
192
135
|
this.target = options.target || 'unknown';
|
|
193
136
|
this.stackItem = null;
|
|
194
137
|
this.previous = options.previous || null;
|
|
@@ -205,7 +148,7 @@ var OperationContext = /** @class */ (function () {
|
|
|
205
148
|
this.globals = this.lookupGlobals();
|
|
206
149
|
this.locals = this.lookupLocals() || this;
|
|
207
150
|
}
|
|
208
|
-
|
|
151
|
+
step(op) {
|
|
209
152
|
if (!this.injected) {
|
|
210
153
|
this.stackItem = op.item;
|
|
211
154
|
this.target = op.target || this.target;
|
|
@@ -216,33 +159,33 @@ var OperationContext = /** @class */ (function () {
|
|
|
216
159
|
}
|
|
217
160
|
}
|
|
218
161
|
return Promise.resolve();
|
|
219
|
-
}
|
|
220
|
-
|
|
162
|
+
}
|
|
163
|
+
setLastActive(ctx) {
|
|
221
164
|
if (!ctx.injected) {
|
|
222
165
|
this.processState.last = ctx;
|
|
223
166
|
}
|
|
224
167
|
return this;
|
|
225
|
-
}
|
|
226
|
-
|
|
168
|
+
}
|
|
169
|
+
getLastActive() {
|
|
227
170
|
return this.processState.last;
|
|
228
|
-
}
|
|
229
|
-
|
|
171
|
+
}
|
|
172
|
+
isExit() {
|
|
230
173
|
return this.processState.isExit;
|
|
231
|
-
}
|
|
232
|
-
|
|
174
|
+
}
|
|
175
|
+
isPending() {
|
|
233
176
|
return this.processState.isPending;
|
|
234
|
-
}
|
|
235
|
-
|
|
177
|
+
}
|
|
178
|
+
setPending(pending) {
|
|
236
179
|
this.processState.isPending = pending;
|
|
237
180
|
return this;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
181
|
+
}
|
|
182
|
+
lookupAllOfType(validate) {
|
|
183
|
+
const me = this;
|
|
184
|
+
const result = [];
|
|
242
185
|
if (validate(me.type)) {
|
|
243
186
|
result.push(me);
|
|
244
187
|
}
|
|
245
|
-
|
|
188
|
+
let current = me.previous;
|
|
246
189
|
while (current) {
|
|
247
190
|
if (validate(current.type)) {
|
|
248
191
|
result.push(current);
|
|
@@ -250,16 +193,15 @@ var OperationContext = /** @class */ (function () {
|
|
|
250
193
|
current = current.previous;
|
|
251
194
|
}
|
|
252
195
|
return result;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
var _this = this;
|
|
196
|
+
}
|
|
197
|
+
exit() {
|
|
256
198
|
if (this.processState.isPending) {
|
|
257
199
|
this.processState.isExit = true;
|
|
258
|
-
return new Promise(
|
|
259
|
-
|
|
260
|
-
if (!
|
|
261
|
-
|
|
262
|
-
resolve(
|
|
200
|
+
return new Promise((resolve) => {
|
|
201
|
+
const check = () => {
|
|
202
|
+
if (!this.processState.isPending) {
|
|
203
|
+
this.processState.isExit = false;
|
|
204
|
+
resolve(this);
|
|
263
205
|
}
|
|
264
206
|
else {
|
|
265
207
|
setTimeout(check);
|
|
@@ -269,12 +211,12 @@ var OperationContext = /** @class */ (function () {
|
|
|
269
211
|
});
|
|
270
212
|
}
|
|
271
213
|
return Promise.reject(new Error('No running process found.'));
|
|
272
|
-
}
|
|
273
|
-
|
|
214
|
+
}
|
|
215
|
+
lookupType(allowedTypes) {
|
|
274
216
|
if (allowedTypes.includes(this.type)) {
|
|
275
217
|
return this;
|
|
276
218
|
}
|
|
277
|
-
|
|
219
|
+
let current = this.previous;
|
|
278
220
|
while (current !== null) {
|
|
279
221
|
if (allowedTypes.includes(current.type)) {
|
|
280
222
|
return current;
|
|
@@ -282,22 +224,20 @@ var OperationContext = /** @class */ (function () {
|
|
|
282
224
|
current = current.previous;
|
|
283
225
|
}
|
|
284
226
|
return null;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return this.lookupAllOfType(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
};
|
|
291
|
-
OperationContext.prototype.lookupApi = function () {
|
|
227
|
+
}
|
|
228
|
+
lookupAllScopes() {
|
|
229
|
+
return this.lookupAllOfType((type) => [ContextType.Global, ContextType.Function].includes(type));
|
|
230
|
+
}
|
|
231
|
+
lookupApi() {
|
|
292
232
|
return this.lookupType(OperationContext.lookupApiType);
|
|
293
|
-
}
|
|
294
|
-
|
|
233
|
+
}
|
|
234
|
+
lookupGlobals() {
|
|
295
235
|
return this.lookupType(OperationContext.lookupGlobalsType);
|
|
296
|
-
}
|
|
297
|
-
|
|
236
|
+
}
|
|
237
|
+
lookupLocals() {
|
|
298
238
|
return this.lookupType(OperationContext.lookupLocalsType);
|
|
299
|
-
}
|
|
300
|
-
|
|
239
|
+
}
|
|
240
|
+
extend(map) {
|
|
301
241
|
var _a;
|
|
302
242
|
if (this.state === ContextState.Temporary) {
|
|
303
243
|
(_a = this.previous) === null || _a === void 0 ? void 0 : _a.extend(map);
|
|
@@ -306,51 +246,35 @@ var OperationContext = /** @class */ (function () {
|
|
|
306
246
|
this.scope.extend(map);
|
|
307
247
|
}
|
|
308
248
|
return this;
|
|
309
|
-
}
|
|
310
|
-
|
|
249
|
+
}
|
|
250
|
+
set(path, value) {
|
|
311
251
|
var _a;
|
|
312
|
-
if (path instanceof
|
|
252
|
+
if (path instanceof base_1.default) {
|
|
313
253
|
this.set(new path_1.default([path]), value);
|
|
314
254
|
return;
|
|
315
255
|
}
|
|
316
|
-
|
|
317
|
-
var current = traversalPath.next();
|
|
318
|
-
if (current.value === 'locals') {
|
|
319
|
-
this.locals.set(traversalPath, value);
|
|
320
|
-
}
|
|
321
|
-
else if (current.value === 'globals') {
|
|
322
|
-
this.globals.set(traversalPath, value);
|
|
323
|
-
}
|
|
324
|
-
else if (this.state === ContextState.Temporary) {
|
|
256
|
+
if (this.state === ContextState.Temporary) {
|
|
325
257
|
(_a = this.previous) === null || _a === void 0 ? void 0 : _a.set(path, value);
|
|
326
258
|
}
|
|
327
259
|
else {
|
|
328
260
|
this.locals.scope.set(path, value);
|
|
329
261
|
}
|
|
330
|
-
}
|
|
331
|
-
|
|
262
|
+
}
|
|
263
|
+
get(path) {
|
|
332
264
|
var _a;
|
|
333
|
-
if (path instanceof
|
|
265
|
+
if (path instanceof base_1.default) {
|
|
334
266
|
return this.get(new path_1.default([path]));
|
|
335
267
|
}
|
|
336
268
|
if (path.count() === 0) {
|
|
337
269
|
return this.scope;
|
|
338
270
|
}
|
|
339
|
-
|
|
340
|
-
var current = traversalPath.next();
|
|
341
|
-
if (current.value === 'locals') {
|
|
342
|
-
return this.locals.get(traversalPath);
|
|
343
|
-
}
|
|
344
|
-
else if (current.value === 'globals') {
|
|
345
|
-
return this.globals.get(traversalPath);
|
|
346
|
-
}
|
|
347
|
-
else if (this.state === ContextState.Temporary) {
|
|
271
|
+
if (this.state === ContextState.Temporary) {
|
|
348
272
|
return (_a = this.previous) === null || _a === void 0 ? void 0 : _a.get(path);
|
|
349
273
|
}
|
|
350
274
|
return this.locals.scope.get(path);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
275
|
+
}
|
|
276
|
+
fork(options) {
|
|
277
|
+
const newContext = new OperationContext({
|
|
354
278
|
target: options.target || this.target,
|
|
355
279
|
previous: this,
|
|
356
280
|
type: options.type,
|
|
@@ -369,15 +293,14 @@ var OperationContext = /** @class */ (function () {
|
|
|
369
293
|
newContext.functionState = this.functionState;
|
|
370
294
|
}
|
|
371
295
|
return newContext;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
OperationContext.lookupGlobalsType = [
|
|
375
|
-
ContextType.Global
|
|
376
|
-
];
|
|
377
|
-
OperationContext.lookupLocalsType = [
|
|
378
|
-
ContextType.Global,
|
|
379
|
-
ContextType.Function
|
|
380
|
-
];
|
|
381
|
-
return OperationContext;
|
|
382
|
-
}());
|
|
296
|
+
}
|
|
297
|
+
}
|
|
383
298
|
exports.default = OperationContext;
|
|
299
|
+
OperationContext.lookupApiType = [ContextType.Api];
|
|
300
|
+
OperationContext.lookupGlobalsType = [
|
|
301
|
+
ContextType.Global
|
|
302
|
+
];
|
|
303
|
+
OperationContext.lookupLocalsType = [
|
|
304
|
+
ContextType.Global,
|
|
305
|
+
ContextType.Function
|
|
306
|
+
];
|