UNPKG

44.6 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.havocBinding = havocBinding;
7exports.mightBecomeAnObject = mightBecomeAnObject;
8exports.Reference = exports.LexicalEnvironment = exports.GlobalEnvironmentRecord = exports.FunctionEnvironmentRecord = exports.ObjectEnvironmentRecord = exports.DeclarativeEnvironmentRecord = exports.EnvironmentRecord = void 0;
9
10var t = _interopRequireWildcard(require("@babel/types"));
11
12var _completions = require("./completions.js");
13
14var _errors = require("./errors.js");
15
16var _options = require("./options.js");
17
18var _realm = require("./realm.js");
19
20var _index = require("./values/index.js");
21
22var _generator = _interopRequireDefault(require("@babel/generator"));
23
24var _parse = _interopRequireDefault(require("./utils/parse.js"));
25
26var _invariant = _interopRequireDefault(require("./invariant.js"));
27
28var _traverseFast = _interopRequireDefault(require("./utils/traverse-fast.js"));
29
30var _index2 = require("./methods/index.js");
31
32var _singletons = require("./singletons.js");
33
34var _index3 = require("./domains/index.js");
35
36var _PrimitiveValue = _interopRequireDefault(require("./values/PrimitiveValue.js"));
37
38var _generator2 = require("./utils/generator.js");
39
40function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
42function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
43
44function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
45
46const sourceMap = require("source-map");
47
48function deriveGetBinding(realm, binding) {
49 let types = _index3.TypesDomain.topVal;
50 let values = _index3.ValuesDomain.topVal;
51 (0, _invariant.default)(realm.generator !== undefined);
52 return realm.generator.deriveAbstract(types, values, [], (0, _generator2.createOperationDescriptor)("GET_BINDING", {
53 binding
54 }));
55}
56
57function havocBinding(binding) {
58 let realm = binding.environment.realm;
59 let value = binding.value;
60
61 if (!binding.hasLeaked) {
62 realm.recordModifiedBinding(binding).hasLeaked = true;
63
64 if (value !== undefined) {
65 let realmGenerator = realm.generator;
66 if (realmGenerator !== undefined && value !== realm.intrinsics.undefined) realmGenerator.emitBindingAssignment(binding, value);
67
68 if (binding.mutable === true) {
69 // For mutable, i.e. non-const bindings, the actual value is no longer directly available.
70 // Thus, we reset the value to undefined to prevent any use of the last known value.
71 binding.value = undefined;
72 }
73 }
74 }
75} // ECMA262 8.1.1
76
77
78class EnvironmentRecord {
79 constructor(realm) {
80 (0, _invariant.default)(realm, "expected realm");
81 this.realm = realm;
82 this.isReadOnly = false;
83 this.id = EnvironmentRecord.nextId++;
84 }
85
86 HasBinding(N) {
87 (0, _invariant.default)(false, "abstract method; please override");
88 }
89
90 CreateMutableBinding(N, D, isGlobal) {
91 (0, _invariant.default)(false, "abstract method; please override");
92 }
93
94 CreateImmutableBinding(N, S, isGlobal, skipRecord) {
95 (0, _invariant.default)(false, "abstract method; please override");
96 }
97
98 InitializeBinding(N, V, skipRecord) {
99 (0, _invariant.default)(false, "abstract method; please override");
100 }
101
102 SetMutableBinding(N, V, S) {
103 (0, _invariant.default)(false, "abstract method; please override");
104 }
105
106 GetBindingValue(N, S) {
107 (0, _invariant.default)(false, "abstract method; please override");
108 }
109
110 DeleteBinding(N) {
111 (0, _invariant.default)(false, "abstract method; please override");
112 }
113
114 HasThisBinding() {
115 (0, _invariant.default)(false, "abstract method; please override");
116 }
117
118 GetThisBinding() {
119 (0, _invariant.default)(false, "abstract method; please override");
120 }
121
122 HasSuperBinding() {
123 (0, _invariant.default)(false, "abstract method; please override");
124 }
125
126 WithBaseObject() {
127 (0, _invariant.default)(false, "abstract method; please override");
128 }
129
130 BindThisValue(V) {
131 (0, _invariant.default)(false, "abstract method; please override");
132 }
133
134}
135
136exports.EnvironmentRecord = EnvironmentRecord;
137
138_defineProperty(EnvironmentRecord, "nextId", 0);
139
140// ECMA262 8.1.1.1
141class DeclarativeEnvironmentRecord extends EnvironmentRecord {
142 constructor(realm) {
143 super(realm);
144 this.bindings = Object.create(null);
145 this.frozen = false;
146 }
147
148 // ECMA262 8.1.1.1.1
149 HasBinding(N) {
150 // 1. Let envRec be the declarative Environment Record for which the method was invoked.
151 let envRec = this; // 2. If envRec has a binding for the name that is the value of N, return true.
152
153 if (envRec.bindings[N]) return true; // 3. Return false.
154
155 return false;
156 } // ECMA262 8.1.1.1.2
157
158
159 CreateMutableBinding(N, D, isGlobal = false) {
160 (0, _invariant.default)(!this.frozen);
161 let realm = this.realm; // 1. Let envRec be the declarative Environment Record for which the method was invoked.
162
163 let envRec = this; // 2. Assert: envRec does not already have a binding for N.
164
165 (0, _invariant.default)(!envRec.bindings[N], `shouldn't have the binding ${N}`); // 3. Create a mutable binding in envRec for N and record that it is uninitialized. If D is true, record that the newly created binding may be deleted by a subsequent DeleteBinding call.
166
167 this.bindings[N] = realm.recordModifiedBinding({
168 initialized: false,
169 mutable: true,
170 deletable: D,
171 environment: envRec,
172 name: N,
173 isGlobal: isGlobal,
174 mightHaveBeenCaptured: false,
175 hasLeaked: false
176 }); // 4. Return NormalCompletion(empty).
177
178 return realm.intrinsics.undefined;
179 } // ECMA262 8.1.1.1.3
180
181
182 CreateImmutableBinding(N, S, isGlobal = false, skipRecord = false) {
183 (0, _invariant.default)(!this.frozen);
184 let realm = this.realm; // 1. Let envRec be the declarative Environment Record for which the method was invoked.
185
186 let envRec = this; // 2. Assert: envRec does not already have a binding for N.
187
188 (0, _invariant.default)(!envRec.bindings[N], `shouldn't have the binding ${N}`); // 3. Create an immutable binding in envRec for N and record that it is uninitialized. If S is true, record that the newly created binding is a strict binding.
189
190 let binding = {
191 initialized: false,
192 strict: S,
193 deletable: false,
194 environment: envRec,
195 name: N,
196 isGlobal: isGlobal,
197 mightHaveBeenCaptured: false,
198 hasLeaked: false
199 };
200 this.bindings[N] = skipRecord ? binding : realm.recordModifiedBinding(binding); // 4. Return NormalCompletion(empty).
201
202 return realm.intrinsics.undefined;
203 } // ECMA262 8.1.1.1.4
204
205
206 InitializeBinding(N, V, skipRecord = false) {
207 // 1. Let envRec be the declarative Environment Record for which the method was invoked.
208 let envRec = this;
209 let binding = envRec.bindings[N]; // 2. Assert: envRec must have an uninitialized binding for N.
210
211 (0, _invariant.default)(binding && binding.initialized !== true, `shouldn't have the binding ${N}`); // 3. Set the bound value for N in envRec to V.
212
213 if (!skipRecord) this.realm.recordModifiedBinding(binding, V).value = V;else binding.value = V; // 4. Record that the binding for N in envRec has been initialized.
214
215 binding.initialized = true; // 5. Return NormalCompletion(empty).
216
217 return this.realm.intrinsics.empty;
218 } // ECMA262 8.1.1.1.5
219
220
221 SetMutableBinding(N, V, _S) {
222 let S = _S; // We can mutate frozen bindings because of captured bindings.
223
224 let realm = this.realm; // 1. Let envRec be the declarative Environment Record for which the method was invoked.
225
226 let envRec = this;
227 let binding = envRec.bindings[N]; // 2. If envRec does not have a binding for N, then
228
229 if (!binding) {
230 // a. If S is true, throw a ReferenceError exception.
231 if (S) {
232 throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError, `${N} not found`);
233 } // b. Perform envRec.CreateMutableBinding(N, true).
234
235
236 envRec.CreateMutableBinding(N, true); // c. Perform envRec.InitializeBinding(N, V).
237
238 envRec.InitializeBinding(N, V); // d. Return NormalCompletion(empty).
239
240 return this.realm.intrinsics.empty;
241 } // 3. If the binding for N in envRec is a strict binding, let S be true.
242
243
244 if (binding.strict === true) S = true; // 4. If the binding for N in envRec has not yet been initialized, throw a ReferenceError exception.
245
246 if (binding.initialized !== true) {
247 throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError, `${N} has not yet been initialized`);
248 } else if (binding.mutable) {
249 // 5. Else if the binding for N in envRec is a mutable binding, change its bound value to V.
250 if (binding.hasLeaked) {
251 _singletons.Havoc.value(realm, V);
252
253 (0, _invariant.default)(realm.generator);
254 realm.generator.emitBindingAssignment(binding, V);
255 } else {
256 realm.recordModifiedBinding(binding, V).value = V;
257 }
258 } else {
259 // 6. Else,
260 // a. Assert: This is an attempt to change the value of an immutable binding.
261 // b. If S is true, throw a TypeError exception.
262 if (S) {
263 throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, "attempt to change immutable binding");
264 }
265 } // 7. Return NormalCompletion(empty).
266
267
268 return this.realm.intrinsics.empty;
269 } // ECMA262 8.1.1.1.6
270
271
272 GetBindingValue(N, S) {
273 let realm = this.realm; // 1. Let envRec be the declarative Environment Record for which the method was invoked.
274
275 let envRec = this;
276 let binding = envRec.bindings[N]; // 2. Assert: envRec has a binding for N.
277
278 (0, _invariant.default)(binding, "expected binding"); // 3. If the binding for N in envRec is an uninitialized binding, throw a ReferenceError exception.
279
280 if (!binding.initialized) {
281 throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError);
282 } // 4. Return the value currently bound to N in envRec.
283
284
285 if (binding.hasLeaked && binding.mutable) {
286 return deriveGetBinding(realm, binding);
287 }
288
289 (0, _invariant.default)(binding.value);
290 return binding.value;
291 } // ECMA262 8.1.1.1.7
292
293
294 DeleteBinding(N) {
295 (0, _invariant.default)(!this.frozen); // 1. Let envRec be the declarative Environment Record for which the method was invoked.
296
297 let envRec = this; // 2. Assert: envRec has a binding for the name that is the value of N.
298
299 (0, _invariant.default)(envRec.bindings[N], "expected binding to exist"); // 3. If the binding for N in envRec cannot be deleted, return false.
300
301 if (!envRec.bindings[N].deletable) return false; // 4. Remove the binding for N from envRec.
302
303 this.realm.recordModifiedBinding(envRec.bindings[N]).value = undefined;
304 delete envRec.bindings[N]; // 5. Return true.
305
306 return true;
307 } // ECMA262 8.1.1.1.8
308
309
310 HasThisBinding() {
311 // 1. Return false.
312 return false;
313 } // ECMA262 8.1.1.1.9
314
315
316 HasSuperBinding() {
317 // 1. Return false.
318 return false;
319 } // ECMA262 8.1.1.1.10
320
321
322 WithBaseObject() {
323 // 1. Return undefined.
324 return this.realm.intrinsics.undefined;
325 }
326
327} // ECMA262 8.1.1.2
328
329
330exports.DeclarativeEnvironmentRecord = DeclarativeEnvironmentRecord;
331
332class ObjectEnvironmentRecord extends EnvironmentRecord {
333 constructor(realm, obj) {
334 super(realm);
335 this.object = obj;
336 } // ECMA262 8.1.1.2.1
337
338
339 HasBinding(N) {
340 let realm = this.realm; // 1. Let envRec be the object Environment Record for which the method was invoked.
341
342 let envRec = this; // 2. Let bindings be the binding object for envRec.
343
344 let bindings = this.object; // 3. Let foundBinding be ? HasProperty(bindings, N).
345
346 let foundBinding = (0, _index2.HasProperty)(realm, bindings, N); // 4. If foundBinding is false, return false.
347
348 if (!foundBinding) return false; // 5. If the withEnvironment flag of envRec is false, return true.
349
350 if (!envRec.withEnvironment) return true; // 6. Let unscopables be ? Get(bindings, @@unscopables).
351
352 let unscopables = (0, _index2.Get)(realm, bindings, realm.intrinsics.SymbolUnscopables); // 7. If Type(unscopables) is Object, then
353
354 if (unscopables instanceof _index.ObjectValue || unscopables instanceof _index.AbstractObjectValue) {
355 // a. Let blocked be ToBoolean(? Get(unscopables, N)).
356 let blocked = _singletons.To.ToBooleanPartial(realm, (0, _index2.Get)(realm, unscopables, N)); // b. If blocked is true, return false.
357
358
359 if (blocked) return false;
360 }
361
362 unscopables.throwIfNotConcrete(); // 8. Return true.
363
364 return true;
365 } // ECMA262 8.1.1.2.2
366
367
368 CreateMutableBinding(N, D) {
369 let realm = this.realm; // 1. Let envRec be the object Environment Record for which the method was invoked.
370
371 let envRec = this; // 2. Let bindings be the binding object for envRec.
372
373 let bindings = envRec.object; // 3. If D is true, let configValue be true; otherwise let configValue be false.
374
375 let configValue = D ? true : false; // 4. Return ? DefinePropertyOrThrow(bindings, N, PropertyDescriptor{[[Value]]: undefined, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: configValue}).
376
377 return new _index.BooleanValue(realm, _singletons.Properties.DefinePropertyOrThrow(realm, bindings, N, {
378 value: realm.intrinsics.undefined,
379 writable: true,
380 enumerable: true,
381 configurable: configValue
382 }));
383 } // ECMA262 8.1.1.2.3
384
385
386 CreateImmutableBinding(N, S) {
387 // The concrete Environment Record method CreateImmutableBinding is never used within this specification in association with object Environment Records.
388 (0, _invariant.default)(false);
389 } // ECMA262 8.1.1.2.4
390
391
392 InitializeBinding(N, V) {
393 // 1. Let envRec be the object Environment Record for which the method was invoked.
394 let envRec = this; // 2. Assert: envRec must have an uninitialized binding for N.
395 // 3. Record that the binding for N in envRec has been initialized.
396 // 4. Return ? envRec.SetMutableBinding(N, V, false).
397
398 return envRec.SetMutableBinding(N, V, false);
399 } // ECMA262 8.1.1.2.5
400
401
402 SetMutableBinding(N, V, S) {
403 let realm = this.realm; // 1. Let envRec be the object Environment Record for which the method was invoked.
404
405 let envRec = this; // 2. Let bindings be the binding object for envRec.
406
407 let bindings = envRec.object; // 3. Return ? Set(bindings, N, V, S).
408
409 return new _index.BooleanValue(realm, _singletons.Properties.Set(realm, bindings, N, V, S));
410 } // ECMA262 8.1.1.2.6
411
412
413 GetBindingValue(N, S) {
414 let realm = this.realm; // 1. Let envRec be the object Environment Record for which the method was invoked.
415
416 let envRec = this; // 2. Let bindings be the binding object for envRec.
417
418 let bindings = envRec.object; // 3. Let value be ? HasProperty(bindings, N).
419
420 let value = (0, _index2.HasProperty)(realm, bindings, N); // 4. If value is false, then
421
422 if (!value) {
423 // a. If S is false, return the value undefined; otherwise throw a ReferenceError exception.
424 if (!S) {
425 return realm.intrinsics.undefined;
426 } else {
427 throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError);
428 }
429 } // 5. Return ? Get(bindings, N).
430
431
432 return (0, _index2.Get)(realm, bindings, N);
433 } // ECMA262 8.1.1.2.7
434
435
436 DeleteBinding(N) {
437 // 1. Let envRec be the object Environment Record for which the method was invoked.
438 let envRec = this; // 2. Let bindings be the binding object for envRec.
439
440 let bindings = envRec.object; // 3. Return ? bindings.[[Delete]](N).
441
442 return bindings.$Delete(N);
443 } // ECMA262 8.1.1.2.8
444
445
446 HasThisBinding() {
447 // 1. Return false.
448 return false;
449 } // ECMA262 8.1.1.2.9
450
451
452 HasSuperBinding() {
453 // 1. Return false.
454 return false;
455 } // ECMA262 8.1.1.2.10
456
457
458 WithBaseObject() {
459 // 1. Let envRec be the object Environment Record for which the method was invoked.
460 let envRec = this; // 2. If the withEnvironment flag of envRec is true, return the binding object for envRec.
461
462 if (envRec.withEnvironment) return envRec.object; // 3. Otherwise, return undefined.
463
464 return this.realm.intrinsics.undefined;
465 }
466
467} // ECMA262 8.1.1.3
468
469
470exports.ObjectEnvironmentRecord = ObjectEnvironmentRecord;
471
472class FunctionEnvironmentRecord extends DeclarativeEnvironmentRecord {
473 // ECMA262 8.1.1.3.1
474 BindThisValue(V) {
475 let realm = this.realm; // 1. Let envRec be the function Environment Record for which the method was invoked.
476
477 let envRec = this; // 2. Assert: envRec.[[ThisBindingStatus]] is not "lexical".
478
479 (0, _invariant.default)(envRec.$ThisBindingStatus !== "lexical", "this binding status shouldn't be lexical"); // 3. If envRec.[[ThisBindingStatus]] is "initialized", throw a ReferenceError exception.
480
481 if (envRec.$ThisBindingStatus === "initialized") {
482 throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError);
483 } // 4. Set envRec.[[ThisValue]] to V.
484
485
486 envRec.$ThisValue = V; // 5. Set envRec.[[ThisBindingStatus]] to "initialized".
487
488 envRec.$ThisBindingStatus = "initialized"; // 6. Return V.
489
490 return V;
491 } // ECMA262 8.1.1.3.2
492
493
494 HasThisBinding() {
495 // 1. Let envRec be the function Environment Record for which the method was invoked.
496 let envRec = this; // 2. If envRec.[[ThisBindingStatus]] is "lexical", return false; otherwise, return true.
497
498 return envRec.$ThisBindingStatus === "lexical" ? false : true;
499 } // ECMA262 8.1.1.3.3
500
501
502 HasSuperBinding() {
503 // 1. Let envRec be the function Environment Record for which the method was invoked.
504 let envRec = this; // 2. If envRec.[[ThisBindingStatus]] is "lexical", return false.
505
506 if (envRec.$ThisBindingStatus === "lexical") return false; // 3. If envRec.[[HomeObject]] has the value undefined, return false; otherwise, return true.
507
508 if (envRec.$HomeObject === undefined) {
509 return false;
510 } else {
511 return true;
512 }
513 } // ECMA262 8.1.1.3.4
514
515
516 GetThisBinding() {
517 let realm = this.realm; // 1. Let envRec be the function Environment Record for which the method was invoked.
518
519 let envRec = this; // 2. Assert: envRec.[[ThisBindingStatus]] is not "lexical".
520
521 (0, _invariant.default)(envRec.$ThisBindingStatus !== "lexical", "this binding status shouldn't be lexical"); // 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError exception.
522
523 if (envRec.$ThisBindingStatus === "uninitialized") {
524 throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError);
525 } // 4. Return envRec.[[ThisValue]].
526
527
528 return envRec.$ThisValue;
529 } // ECMA262 8.1.1.3.5
530
531
532 GetSuperBase() {
533 // 1. Let envRec be the function Environment Record for which the method was invoked.
534 let envRec = this; // 2. Let home be the value of envRec.[[HomeObject]].
535
536 let home = envRec.$HomeObject; // 3. If home has the value undefined, return undefined.
537
538 if (home === undefined) return this.realm.intrinsics.undefined; // 4. Assert: Type(home) is Object.
539
540 (0, _invariant.default)(home instanceof _index.ObjectValue, "expected object value"); // 5. Return ? home.[[GetPrototypeOf]]().
541
542 return home.$GetPrototypeOf();
543 }
544
545} // ECMA262 8.1.1.4
546
547
548exports.FunctionEnvironmentRecord = FunctionEnvironmentRecord;
549
550class GlobalEnvironmentRecord extends EnvironmentRecord {
551 // ECMA262 8.1.1.4.1
552 HasBinding(N) {
553 // 1. Let envRec be the global Environment Record for which the method was invoked.
554 let envRec = this; // 2. Let DclRec be envRec.[[DeclarativeRecord]].
555
556 let DclRec = envRec.$DeclarativeRecord; // 3. If DclRec.HasBinding(N) is true, return true.
557
558 if (DclRec.HasBinding(N)) return true; // 4. Let ObjRec be envRec.[[ObjectRecord]].
559
560 let ObjRec = envRec.$ObjectRecord; // 5. Return ? ObjRec.HasBinding(N).
561
562 return ObjRec.HasBinding(N);
563 } // ECMA262 8.1.1.4.2
564
565
566 CreateMutableBinding(N, D) {
567 let realm = this.realm; // 1. Let envRec be the global Environment Record for which the method was invoked.
568
569 let envRec = this; // 2. Let DclRec be envRec.[[DeclarativeRecord]].
570
571 let DclRec = envRec.$DeclarativeRecord; // 3. If DclRec.HasBinding(N) is true, throw a TypeError exception.
572
573 if (DclRec.HasBinding(N)) {
574 throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
575 } // 4. Return DclRec.CreateMutableBinding(N, D).
576
577
578 return DclRec.CreateMutableBinding(N, D, true);
579 } // ECMA262 8.1.1.4.3
580
581
582 CreateImmutableBinding(N, S) {
583 let realm = this.realm; // 1. Let envRec be the global Environment Record for which the method was invoked.
584
585 let envRec = this; // 2. Let DclRec be envRec.[[DeclarativeRecord]].
586
587 let DclRec = envRec.$DeclarativeRecord; // 3. If DclRec.HasBinding(N) is true, throw a TypeError exception.
588
589 if (DclRec.HasBinding(N)) {
590 throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
591 } // 4. Return DclRec.CreateImmutableBinding(N, S).
592
593
594 return DclRec.CreateImmutableBinding(N, S, true);
595 } // ECMA262 8.1.1.4.4
596
597
598 InitializeBinding(N, V) {
599 // 1. Let envRec be the global Environment Record for which the method was invoked.
600 let envRec = this; // 2. Let DclRec be envRec.[[DeclarativeRecord]].
601
602 let DclRec = envRec.$DeclarativeRecord; // 3. If DclRec.HasBinding(N) is true, then
603
604 if (DclRec.HasBinding(N)) {
605 // a. Return DclRec.InitializeBinding(N, V).
606 return DclRec.InitializeBinding(N, V);
607 } // 4. Assert: If the binding exists, it must be in the object Environment Record.
608 // 5. Let ObjRec be envRec.[[ObjectRecord]].
609
610
611 let ObjRec = envRec.$ObjectRecord; // 6. Return ? ObjRec.InitializeBinding(N, V).
612
613 return ObjRec.InitializeBinding(N, V);
614 } // ECMA262 8.1.1.4.5
615
616
617 SetMutableBinding(N, V, S) {
618 // 1. Let envRec be the global Environment Record for which the method was invoked.
619 let envRec = this; // 2. Let DclRec be envRec.[[DeclarativeRecord]].
620
621 let DclRec = envRec.$DeclarativeRecord; // 3. If DclRec.HasBinding(N) is true, then
622
623 if (DclRec.HasBinding(N)) {
624 // a. Return DclRec.SetMutableBinding(N, V, S).
625 return DclRec.SetMutableBinding(N, V, S);
626 } // 4. Let ObjRec be envRec.[[ObjectRecord]].
627
628
629 let ObjRec = envRec.$ObjectRecord; // 5. Return ? ObjRec.SetMutableBinding(N, V, S).
630
631 return ObjRec.SetMutableBinding(N, V, S);
632 } // ECMA262 8.1.1.4.6
633
634
635 GetBindingValue(N, S) {
636 // 1. Let envRec be the global Environment Record for which the method was invoked.
637 let envRec = this; // 2. Let DclRec be envRec.[[DeclarativeRecord]].
638
639 let DclRec = envRec.$DeclarativeRecord; // 3. If DclRec.HasBinding(N) is true, then
640
641 if (DclRec.HasBinding(N)) {
642 // a. Return DclRec.GetBindingValue(N, S).
643 return DclRec.GetBindingValue(N, S);
644 } // 4. Let ObjRec be envRec.[[ObjectRecord]].
645
646
647 let ObjRec = envRec.$ObjectRecord; // 5. Return ? ObjRec.GetBindingValue(N, S).
648
649 return ObjRec.GetBindingValue(N, S);
650 } // ECMA262 8.1.1.4.7
651
652
653 DeleteBinding(N) {
654 let realm = this.realm; // 1. Let envRec be the global Environment Record for which the method was invoked.
655
656 let envRec = this; // 2. Let DclRec be envRec.[[DeclarativeRecord]].
657
658 let DclRec = envRec.$DeclarativeRecord; // 3. If DclRec.HasBinding(N) is true, then
659
660 if (DclRec.HasBinding(N)) {
661 // a. Return DclRec.DeleteBinding(N).
662 return DclRec.DeleteBinding(N);
663 } // 4. Let ObjRec be envRec.[[ObjectRecord]].
664
665
666 let ObjRec = envRec.$ObjectRecord; // 5. Let globalObject be the binding object for ObjRec.
667
668 let globalObject = ObjRec.object; // 6. Let existingProp be ? HasOwnProperty(globalObject, N).
669
670 let existingProp = (0, _index2.HasOwnProperty)(realm, globalObject, N); // 7. If existingProp is true, then
671
672 if (existingProp) {
673 // a. Let status be ? ObjRec.DeleteBinding(N).
674 let status = ObjRec.DeleteBinding(N); // b. If status is true, then
675
676 if (status) {
677 // i. Let varNames be envRec.[[VarNames]].
678 let varNames = envRec.$VarNames; // ii. If N is an element of varNames, remove that element from the varNames.
679
680 if (varNames.indexOf(N) >= 0) {
681 varNames.splice(varNames.indexOf(N), 1);
682 }
683 } // c. Return status.
684
685
686 return status;
687 } // 8. Return true.
688
689
690 return true;
691 } // ECMA262 8.1.1.4.8
692
693
694 HasThisBinding() {
695 // 1. Return true.
696 return true;
697 } // ECMA262 8.1.1.4.9
698
699
700 HasSuperBinding() {
701 // 1. Return true.
702 return true;
703 } // ECMA262 8.1.1.4.10
704
705
706 WithBaseObject() {
707 // 1. Return undefined.
708 return this.realm.intrinsics.undefined;
709 } // ECMA262 8.1.1.4.11
710
711
712 GetThisBinding() {
713 // 1. Let envRec be the global Environment Record for which the method was invoked.
714 let envRec = this;
715 (0, _invariant.default)(envRec.$GlobalThisValue); // 2. Return envRec.[[GlobalThisValue]].
716
717 return envRec.$GlobalThisValue;
718 } // ECMA262 8.1.1.4.12
719
720
721 HasVarDeclaration(N) {
722 // 1. Let envRec be the global Environment Record for which the method was invoked.
723 let envRec = this; // 2. Let varDeclaredNames be envRec.[[VarNames]].
724
725 let varDeclaredNames = envRec.$VarNames; // 3. If varDeclaredNames contains the value of N, return true.
726
727 if (varDeclaredNames.indexOf(N) >= 0) return true; // 4. Return false.
728
729 return false;
730 } // ECMA262 8.1.1.4.13
731
732
733 HasLexicalDeclaration(N) {
734 // 1. Let envRec be the global Environment Record for which the method was invoked.
735 let envRec = this; // 2. Let DclRec be envRec.[[DeclarativeRecord]].
736
737 let DclRec = envRec.$DeclarativeRecord; // 3. Return DclRec.HasBinding(N).
738
739 return DclRec.HasBinding(N);
740 } // ECMA262 8.1.1.4.14
741
742
743 HasRestrictedGlobalProperty(N) {
744 // 1. Let envRec be the global Environment Record for which the method was invoked.
745 let envRec = this; // 2. Let ObjRec be envRec.[[ObjectRecord]].
746
747 let ObjRec = envRec.$ObjectRecord; // 3. Let globalObject be the binding object for ObjRec.
748
749 let globalObject = ObjRec.object; // 4. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
750
751 let existingProp = globalObject.$GetOwnProperty(N); // 5. If existingProp is undefined, return false.
752
753 if (!existingProp) return false;
754
755 _singletons.Properties.ThrowIfMightHaveBeenDeleted(existingProp.value); // 6. If existingProp.[[Configurable]] is true, return false.
756
757
758 if (existingProp.configurable) return false; // 7. Return true.
759
760 return true;
761 } // ECMA262 8.1.1.4.15
762
763
764 CanDeclareGlobalVar(N) {
765 let realm = this.realm; // 1. Let envRec be the global Environment Record for which the method was invoked.
766
767 let envRec = this; // 2. Let ObjRec be envRec.[[ObjectRecord]].
768
769 let ObjRec = envRec.$ObjectRecord; // 3. Let globalObject be the binding object for ObjRec.
770
771 let globalObject = ObjRec.object; // 4. Let hasProperty be ? HasOwnProperty(globalObject, N).
772
773 let hasProperty = (0, _index2.HasOwnProperty)(realm, globalObject, N); // 5. If hasProperty is true, return true.
774
775 if (hasProperty) return true; // 6. Return ? IsExtensible(globalObject).
776
777 return (0, _index2.IsExtensible)(realm, globalObject);
778 } // ECMA262 8.1.1.4.16
779
780
781 CanDeclareGlobalFunction(N) {
782 let realm = this.realm; // 1. Let envRec be the global Environment Record for which the method was invoked.
783
784 let envRec = this; // 2. Let ObjRec be envRec.[[ObjectRecord]].
785
786 let ObjRec = envRec.$ObjectRecord; // 3. Let globalObject be the binding object for ObjRec.
787
788 let globalObject = ObjRec.object; // 4. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
789
790 let existingProp = globalObject.$GetOwnProperty(N); // 5. If existingProp is undefined, return ? IsExtensible(globalObject).
791
792 if (!existingProp) return (0, _index2.IsExtensible)(realm, globalObject);
793
794 _singletons.Properties.ThrowIfMightHaveBeenDeleted(existingProp.value); // 6. If existingProp.[[Configurable]] is true, return true.
795
796
797 if (existingProp.configurable) return true; // 7. If IsDataDescriptor(existingProp) is true and existingProp has attribute values {[[Writable]]: true, [[Enumerable]]: true}, return true.
798
799 if ((0, _index2.IsDataDescriptor)(realm, existingProp) && existingProp.writable && existingProp.enumerable) {
800 return true;
801 } // 8. Return false.
802
803
804 return false;
805 } // ECMA262 8.1.1.4.17
806
807
808 CreateGlobalVarBinding(N, D) {
809 let realm = this.realm; // 1. Let envRec be the global Environment Record for which the method was invoked.
810
811 let envRec = this; // 2. Let ObjRec be envRec.[[ObjectRecord]].
812
813 let ObjRec = envRec.$ObjectRecord; // 3. Let globalObject be the binding object for ObjRec.
814
815 let globalObject = ObjRec.object; // 4. Let hasProperty be ? HasOwnProperty(globalObject, N).
816
817 let hasProperty = (0, _index2.HasOwnProperty)(realm, globalObject, N); // 5. Let extensible be ? IsExtensible(globalObject).
818
819 let extensible = (0, _index2.IsExtensible)(realm, globalObject); // 6. If hasProperty is false and extensible is true, then
820
821 if (!hasProperty && extensible) {
822 // a. Perform ? ObjRec.CreateMutableBinding(N, D).
823 ObjRec.CreateMutableBinding(N, D); // b. Perform ? ObjRec.InitializeBinding(N, undefined).
824
825 ObjRec.InitializeBinding(N, this.realm.intrinsics.undefined);
826 } // 7. Let varDeclaredNames be envRec.[[VarNames]].
827
828
829 let varDeclaredNames = envRec.$VarNames; // 8. If varDeclaredNames does not contain the value of N, then
830
831 if (varDeclaredNames.indexOf(N) < 0) {
832 // a. Append N to varDeclaredNames.
833 varDeclaredNames.push(N);
834 } // 9. Return NormalCompletion(empty).
835
836 } // ECMA262 8.1.1.4.18
837
838
839 CreateGlobalFunctionBinding(N, V, D) {
840 // 1. Let envRec be the global Environment Record for which the method was invoked.
841 let envRec = this; // 2. Let ObjRec be envRec.[[ObjectRecord]].
842
843 let ObjRec = envRec.$ObjectRecord; // 3. Let globalObject be the binding object for ObjRec.
844
845 let globalObject = ObjRec.object; // 4. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
846
847 let existingProp = globalObject.$GetOwnProperty(N); // 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then
848
849 let desc;
850
851 if (!existingProp || existingProp.configurable) {
852 // a. Let desc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: D}.
853 desc = {
854 value: V,
855 writable: true,
856 enumerable: true,
857 configurable: D
858 };
859 } else {
860 // 6. Else,
861 _singletons.Properties.ThrowIfMightHaveBeenDeleted(existingProp.value); // a. Let desc be the PropertyDescriptor{[[Value]]: V }.
862
863
864 desc = {
865 value: V
866 };
867 } // 7. Perform ? DefinePropertyOrThrow(globalObject, N, desc).
868
869
870 _singletons.Properties.DefinePropertyOrThrow(this.realm, globalObject, N, desc); // 8. Record that the binding for N in ObjRec has been initialized.
871 // 9. Perform ? Set(globalObject, N, V, false).
872
873
874 _singletons.Properties.Set(this.realm, globalObject, N, V, false); // 10. Let varDeclaredNames be envRec.[[VarNames]].
875
876
877 let varDeclaredNames = envRec.$VarNames; // 11. If varDeclaredNames does not contain the value of N, then
878
879 if (varDeclaredNames.indexOf(N) < 0) {
880 // a. Append N to varDeclaredNames.
881 varDeclaredNames.push(N);
882 } // 12. Return NormalCompletion(empty).
883
884 }
885
886} // ECMA262 8.1
887
888
889exports.GlobalEnvironmentRecord = GlobalEnvironmentRecord;
890let uid = 0;
891
892class LexicalEnvironment {
893 constructor(realm) {
894 (0, _invariant.default)(realm, "expected realm");
895 this.realm = realm;
896 this.destroyed = false;
897 this._uid = uid++;
898 } // For debugging it is convenient to have an ID for each of these.
899
900
901 destroy() {
902 this.destroyed = true; // Once the containing environment is destroyed, we can no longer add or remove entries from the environmentRecord
903 // (but we can update existing values).
904
905 if (this.environmentRecord instanceof DeclarativeEnvironmentRecord) {
906 this.environmentRecord.frozen = true;
907 }
908 }
909
910 assignToGlobal(globalAst, rvalue) {
911 let globalValue = this.evaluate(globalAst, false);
912
913 _singletons.Properties.PutValue(this.realm, globalValue, rvalue);
914 }
915
916 partiallyEvaluateCompletionDeref(ast, strictCode, metadata) {
917 let [result, partial_ast, partial_io] = this.partiallyEvaluateCompletion(ast, strictCode, metadata);
918
919 if (result instanceof Reference) {
920 result = _singletons.Environment.GetValue(this.realm, result);
921 }
922
923 return [result, partial_ast, partial_io];
924 }
925
926 partiallyEvaluateCompletion(ast, strictCode, metadata) {
927 try {
928 return this.partiallyEvaluate(ast, strictCode, metadata);
929 } catch (err) {
930 if (err instanceof _completions.Completion) return [err, ast, []];
931 if (err instanceof Error) // rethrowing Error should preserve stack trace
932 throw err; // let's wrap into a proper Error to create stack trace
933
934 throw new _errors.FatalError(err);
935 }
936 }
937
938 evaluateCompletionDeref(ast, strictCode, metadata) {
939 let result = this.evaluateCompletion(ast, strictCode, metadata);
940 if (result instanceof Reference) result = _singletons.Environment.GetValue(this.realm, result);
941 return result;
942 }
943
944 evaluateCompletion(ast, strictCode, metadata) {
945 try {
946 return this.evaluate(ast, strictCode, metadata);
947 } catch (err) {
948 if (err instanceof _completions.AbruptCompletion) return err;
949 if (err instanceof Error) // rethrowing Error should preserve stack trace
950 throw err; // let's wrap into a proper Error to create stack trace
951
952 throw new _errors.FatalError(err);
953 }
954 }
955
956 evaluateAbstractCompletion(ast, strictCode, metadata) {
957 try {
958 return this.evaluateAbstract(ast, strictCode, metadata);
959 } catch (err) {
960 if (err instanceof _completions.Completion) return err;
961 if (err instanceof Error) // rethrowing Error should preserve stack trace
962 throw err; // let's wrap into a proper Error to create stack trace
963
964 if (err instanceof Object) throw new _errors.FatalError(err.constructor.name + ": " + err);
965 throw new _errors.FatalError(err);
966 }
967 }
968
969 concatenateAndParse(sources, sourceType = "script") {
970 let asts = [];
971 let code = {};
972 let directives = [];
973
974 for (let source of sources) {
975 try {
976 let node = this.realm.statistics.parsing.measure(() => (0, _parse.default)(this.realm, source.fileContents, source.filePath, sourceType));
977 let sourceMapContents = source.sourceMapContents;
978
979 if (sourceMapContents && sourceMapContents.length > 0) {
980 this.realm.statistics.fixupSourceLocations.measure(() => this.fixup_source_locations(node, sourceMapContents));
981 }
982
983 this.realm.statistics.fixupFilenames.measure(() => this.fixup_filenames(node));
984 asts = asts.concat(node.program.body);
985 code[source.filePath] = source.fileContents;
986 directives = directives.concat(node.program.directives);
987 } catch (e) {
988 if (e instanceof _completions.ThrowCompletion) {
989 let error = e.value;
990
991 if (error instanceof _index.ObjectValue) {
992 let message = error._SafeGetDataPropertyValue("message");
993
994 if (message instanceof _index.StringValue) {
995 message.value = `Syntax error: ${message.value}`;
996 e.location.source = source.filePath; // the position was not located properly on the
997 // syntax errors happen on one given position, so start position = end position
998
999 e.location.start = {
1000 line: e.location.line,
1001 column: e.location.column
1002 };
1003 e.location.end = {
1004 line: e.location.line,
1005 column: e.location.column
1006 };
1007 let diagnostic = new _errors.CompilerDiagnostic(message.value, e.location, "PP1004", "FatalError");
1008 this.realm.handleError(diagnostic);
1009 throw new _errors.FatalError(message.value);
1010 }
1011 }
1012 }
1013
1014 throw e;
1015 }
1016 }
1017
1018 return [t.file(t.program(asts, directives)), code];
1019 }
1020
1021 executeSources(sources, sourceType = "script", onParse = undefined) {
1022 let context = new _realm.ExecutionContext();
1023 context.lexicalEnvironment = this;
1024 context.variableEnvironment = this;
1025 context.realm = this.realm;
1026 this.realm.pushContext(context);
1027 let res, code;
1028
1029 try {
1030 let ast;
1031 [ast, code] = this.concatenateAndParse(sources, sourceType);
1032 if (onParse) onParse(ast);
1033 res = this.realm.statistics.evaluation.measure(() => this.evaluateCompletion(ast, false));
1034 } finally {
1035 this.realm.popContext(context);
1036 this.realm.onDestroyScope(context.lexicalEnvironment);
1037 if (!this.destroyed) this.realm.onDestroyScope(this);
1038 (0, _invariant.default)(this.realm.activeLexicalEnvironments.size === 0, `expected 0 active lexical environments, got ${this.realm.activeLexicalEnvironments.size}`);
1039 }
1040
1041 if (res instanceof _completions.AbruptCompletion) return [res, code];
1042 return [_singletons.Environment.GetValue(this.realm, res), code];
1043 }
1044
1045 executePartialEvaluator(sources, options = _options.defaultOptions, sourceType = "script") {
1046 let [ast, code] = this.concatenateAndParse(sources, sourceType);
1047 let context = new _realm.ExecutionContext();
1048 context.lexicalEnvironment = this;
1049 context.variableEnvironment = this;
1050 context.realm = this.realm;
1051 this.realm.pushContext(context);
1052 let partialAST;
1053
1054 try {
1055 [, partialAST] = this.partiallyEvaluateCompletionDeref(ast, false);
1056 } finally {
1057 this.realm.popContext(context);
1058 this.realm.onDestroyScope(context.lexicalEnvironment);
1059 if (!this.destroyed) this.realm.onDestroyScope(this);
1060 (0, _invariant.default)(this.realm.activeLexicalEnvironments.size === 0, `expected 0 active lexical environments, got ${this.realm.activeLexicalEnvironments.size}`);
1061 }
1062
1063 (0, _invariant.default)(partialAST.type === "File");
1064 let fileAst = partialAST;
1065 let prog = t.program(fileAst.program.body, ast.program.directives);
1066 this.fixup_filenames(prog); // The type signature for generate is not complete, hence the any
1067
1068 return (0, _generator.default)(prog, {
1069 sourceMaps: options.sourceMaps
1070 }, code);
1071 }
1072
1073 execute(code, filename, map = "", sourceType = "script", onParse = undefined) {
1074 let context = new _realm.ExecutionContext();
1075 context.lexicalEnvironment = this;
1076 context.variableEnvironment = this;
1077 context.realm = this.realm;
1078 this.realm.pushContext(context);
1079 let ast, res;
1080
1081 try {
1082 try {
1083 ast = (0, _parse.default)(this.realm, code, filename, sourceType);
1084 } catch (e) {
1085 if (e instanceof _completions.ThrowCompletion) return e;
1086 throw e;
1087 }
1088
1089 if (onParse) onParse(ast);
1090 if (map.length > 0) this.fixup_source_locations(ast, map);
1091 this.fixup_filenames(ast);
1092 res = this.evaluateCompletion(ast, false);
1093 } finally {
1094 this.realm.popContext(context); // Avoid destroying "this" scope as execute may be called many times.
1095
1096 if (context.lexicalEnvironment !== this) this.realm.onDestroyScope(context.lexicalEnvironment);
1097 (0, _invariant.default)(this.realm.activeLexicalEnvironments.size === 1, `expected 1 active lexical environment, got ${this.realm.activeLexicalEnvironments.size}`);
1098 }
1099
1100 if (res instanceof _completions.AbruptCompletion) return res;
1101 return _singletons.Environment.GetValue(this.realm, res);
1102 }
1103
1104 fixup_source_locations(ast, map) {
1105 const smc = new sourceMap.SourceMapConsumer(map);
1106 (0, _traverseFast.default)(ast, node => {
1107 let loc = node.loc;
1108 if (!loc) return false;
1109 fixup(loc, loc.start);
1110 fixup(loc, loc.end);
1111 fixup_comments(node.leadingComments);
1112 fixup_comments(node.innerComments);
1113 fixup_comments(node.trailingComments);
1114 return false;
1115
1116 function fixup(new_loc, new_pos) {
1117 let old_pos = smc.originalPositionFor({
1118 line: new_pos.line,
1119 column: new_pos.column
1120 });
1121 if (old_pos.source === null) return;
1122 new_pos.line = old_pos.line;
1123 new_pos.column = old_pos.column;
1124 new_loc.source = old_pos.source;
1125 }
1126
1127 function fixup_comments(comments) {
1128 if (!comments) return;
1129
1130 for (let c of comments) {
1131 let cloc = c.loc;
1132 if (!cloc) continue;
1133 fixup(cloc, cloc.start);
1134 fixup(cloc, cloc.end);
1135 }
1136 }
1137 });
1138 }
1139
1140 fixup_filenames(ast) {
1141 (0, _traverseFast.default)(ast, node => {
1142 let loc = node.loc;
1143
1144 if (!loc || !loc.source) {
1145 node.leadingComments = null;
1146 node.innerComments = null;
1147 node.trailingComments = null;
1148 node.loc = null;
1149 } else {
1150 let filename = loc.source;
1151 loc.filename = filename;
1152 fixup_comments(node.leadingComments, filename);
1153 fixup_comments(node.innerComments, filename);
1154 fixup_comments(node.trailingComments, filename);
1155 }
1156
1157 return false;
1158
1159 function fixup_comments(comments, filename) {
1160 if (!comments) return;
1161
1162 for (let c of comments) {
1163 if (c.loc) {
1164 c.loc.filename = filename;
1165 c.loc.source = filename;
1166 }
1167 }
1168 }
1169 });
1170 }
1171
1172 evaluate(ast, strictCode, metadata) {
1173 if (this.realm.debuggerInstance) {
1174 this.realm.debuggerInstance.checkForActions(ast);
1175 }
1176
1177 let res = this.evaluateAbstract(ast, strictCode, metadata);
1178 (0, _invariant.default)(res instanceof _index.Value || res instanceof Reference, ast.type);
1179 return res;
1180 }
1181
1182 evaluateAbstract(ast, strictCode, metadata) {
1183 this.realm.currentLocation = ast.loc;
1184 this.realm.testTimeout();
1185 let evaluator = this.realm.evaluators[ast.type];
1186
1187 if (evaluator) {
1188 this.realm.statistics.evaluatedNodes++;
1189 let result = evaluator(ast, strictCode, this, this.realm, metadata);
1190 return result;
1191 }
1192
1193 throw new TypeError(`Unsupported node type ${ast.type}`);
1194 }
1195
1196 evaluateDeref(ast, strictCode, metadata) {
1197 let result = this.evaluate(ast, strictCode, metadata);
1198 if (result instanceof Reference) result = _singletons.Environment.GetValue(this.realm, result);
1199 return result;
1200 }
1201
1202 partiallyEvaluate(ast, strictCode, metadata) {
1203 let partialEvaluator = this.realm.partialEvaluators[ast.type];
1204
1205 if (partialEvaluator) {
1206 return partialEvaluator(ast, strictCode, this, this.realm, metadata);
1207 }
1208
1209 let err = new TypeError(`Unsupported node type ${ast.type}`);
1210 throw err;
1211 }
1212
1213} // ECMA262 6.2.3
1214// A Reference is a resolved name or property binding. A Reference consists of three components, the base value,
1215// the referenced name and the Boolean valued strict reference flag. The base value is either undefined, an Object,
1216// a Boolean, a String, a Symbol, a Number, or an Environment Record. A base value of undefined indicates that the
1217// Reference could not be resolved to a binding. The referenced name is a String or Symbol value.
1218
1219
1220exports.LexicalEnvironment = LexicalEnvironment;
1221
1222function mightBecomeAnObject(base) {
1223 let type = base.getType(); // The top Value type might be able to become an object. We let it
1224 // pass and error later if it can't.
1225
1226 return type === _index.Value || type === _PrimitiveValue.default || type === _index.BooleanValue || type === _index.StringValue || type === _index.SymbolValue || type === _index.NumberValue || type === _index.IntegralValue;
1227}
1228
1229class Reference {
1230 constructor(base, refName, strict, thisValue) {
1231 (0, _invariant.default)(base instanceof _index.AbstractObjectValue || base === undefined || base instanceof _index.ObjectValue || base instanceof EnvironmentRecord || mightBecomeAnObject(base));
1232 this.base = base;
1233 this.referencedName = refName;
1234 (0, _invariant.default)(!(refName instanceof _index.AbstractValue) || !(refName.mightNotBeString() && refName.mightNotBeNumber() && !refName.isSimpleObject()) || refName.$Realm.isInPureScope());
1235 this.strict = strict;
1236 this.thisValue = thisValue;
1237 (0, _invariant.default)(thisValue === undefined || !(base instanceof EnvironmentRecord));
1238 }
1239
1240}
1241
1242exports.Reference = Reference;
1243//# sourceMappingURL=environment.js.map
\No newline at end of file