-
Notifications
You must be signed in to change notification settings - Fork 1
/
spec.emu
1511 lines (1468 loc) · 58.1 KB
/
spec.emu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="./spec.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="./spec.js"></script>
<pre class="metadata">
title: ECMAScript Module Phase Imports
stage: 2
contributors: Luca Casonato, Guy Bedford
</pre>
<emu-clause id="sec-ecmascript-data-types-and-values" aoid="Type">
<h1>ECMAScript Data Types and Values</h1>
<emu-clause id="sec-ecmascript-language-types">
<h1>ECMAScript Language Types</h1>
<emu-clause id="sec-object-type">
<h1>Object Type</h1>
<emu-clause id="sec-well-known-intrinsic-objects">
<h1>Well-Known Intrinsic Objects</h1>
<p>Well-known intrinsics are built-in objects that are explicitly referenced by the algorithms of this specification and which usually have realm-specific identities. Unless otherwise specified each intrinsic object actually corresponds to a set of similar objects, one per realm.</p>
<p>Within this specification a reference such as %name% means the intrinsic object, associated with the current realm, corresponding to the name. A reference such as %name.a.b% means, as if the *"b"* property of the value of the *"a"* property of the intrinsic object %name% was accessed prior to any ECMAScript code being evaluated. Determination of the current realm and its intrinsics is described in <emu-xref href="#sec-execution-contexts"></emu-xref>. The well-known intrinsics are listed in <emu-xref href="#table-well-known-intrinsic-objects"></emu-xref>.</p>
<emu-table id="table-well-known-intrinsic-objects" caption="Well-Known Intrinsic Objects" oldids="table-7">
<table>
<tr>
<th>
Intrinsic Name
</th>
<th>
Global Name
</th>
<th>
ECMAScript Language Association
</th>
</tr>
<tr>
<td>
%AbstractModuleSource%
</td>
<td>
</td>
<td>
The %AbstractModuleSource% constructor (<emu-xref href="#sec-%abstractmodulesource%-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%AggregateError%
</td>
<td>
`AggregateError`
</td>
<td>
The `AggregateError` constructor (<emu-xref href="#sec-aggregate-error-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Array%
</td>
<td>
`Array`
</td>
<td>
The Array constructor (<emu-xref href="#sec-array-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%ArrayBuffer%
</td>
<td>
`ArrayBuffer`
</td>
<td>
The ArrayBuffer constructor (<emu-xref href="#sec-arraybuffer-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%ArrayIteratorPrototype%
</td>
<td>
</td>
<td>
The prototype of Array iterator objects (<emu-xref href="#sec-array-iterator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%AsyncFromSyncIteratorPrototype%
</td>
<td>
</td>
<td>
The prototype of async-from-sync iterator objects (<emu-xref href="#sec-async-from-sync-iterator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%AsyncFunction%
</td>
<td>
</td>
<td>
The constructor of async function objects (<emu-xref href="#sec-async-function-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%AsyncGeneratorFunction%
</td>
<td>
</td>
<td>
The constructor of async generator function objects (<emu-xref href="#sec-asyncgeneratorfunction-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%AsyncGeneratorPrototype%
</td>
<td>
</td>
<td>
The prototype of async generator objects (<emu-xref href="#sec-asyncgenerator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%AsyncIteratorPrototype%
</td>
<td>
</td>
<td>
An object that all standard built-in async iterator objects indirectly inherit from
</td>
</tr>
<tr>
<td>
%Atomics%
</td>
<td>
`Atomics`
</td>
<td>
The `Atomics` object (<emu-xref href="#sec-atomics-object"></emu-xref>)
</td>
</tr>
<tr>
<td>
%BigInt%
</td>
<td>
`BigInt`
</td>
<td>
The BigInt constructor (<emu-xref href="#sec-bigint-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%BigInt64Array%
</td>
<td>
`BigInt64Array`
</td>
<td>
The BigInt64Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%BigUint64Array%
</td>
<td>
`BigUint64Array`
</td>
<td>
The BigUint64Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Boolean%
</td>
<td>
`Boolean`
</td>
<td>
The Boolean constructor (<emu-xref href="#sec-boolean-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%DataView%
</td>
<td>
`DataView`
</td>
<td>
The DataView constructor (<emu-xref href="#sec-dataview-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Date%
</td>
<td>
`Date`
</td>
<td>
The Date constructor (<emu-xref href="#sec-date-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%decodeURI%
</td>
<td>
`decodeURI`
</td>
<td>
The `decodeURI` function (<emu-xref href="#sec-decodeuri-encodeduri"></emu-xref>)
</td>
</tr>
<tr>
<td>
%decodeURIComponent%
</td>
<td>
`decodeURIComponent`
</td>
<td>
The `decodeURIComponent` function (<emu-xref href="#sec-decodeuricomponent-encodeduricomponent"></emu-xref>)
</td>
</tr>
<tr>
<td>
%encodeURI%
</td>
<td>
`encodeURI`
</td>
<td>
The `encodeURI` function (<emu-xref href="#sec-encodeuri-uri"></emu-xref>)
</td>
</tr>
<tr>
<td>
%encodeURIComponent%
</td>
<td>
`encodeURIComponent`
</td>
<td>
The `encodeURIComponent` function (<emu-xref href="#sec-encodeuricomponent-uricomponent"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Error%
</td>
<td>
`Error`
</td>
<td>
The Error constructor (<emu-xref href="#sec-error-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%eval%
</td>
<td>
`eval`
</td>
<td>
The `eval` function (<emu-xref href="#sec-eval-x"></emu-xref>)
</td>
</tr>
<tr>
<td>
%EvalError%
</td>
<td>
`EvalError`
</td>
<td>
The EvalError constructor (<emu-xref href="#sec-native-error-types-used-in-this-standard-evalerror"></emu-xref>)
</td>
</tr>
<tr>
<td>
%FinalizationRegistry%
</td>
<td>
`FinalizationRegistry`
</td>
<td>
The FinalizationRegistry constructor (<emu-xref href="#sec-finalization-registry-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Float32Array%
</td>
<td>
`Float32Array`
</td>
<td>
The Float32Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Float64Array%
</td>
<td>
`Float64Array`
</td>
<td>
The Float64Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%ForInIteratorPrototype%
</td>
<td>
</td>
<td>
The prototype of For-In iterator objects (<emu-xref href="#sec-for-in-iterator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Function%
</td>
<td>
`Function`
</td>
<td>
The Function constructor (<emu-xref href="#sec-function-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%GeneratorFunction%
</td>
<td>
</td>
<td>
The constructor of generator function objects (<emu-xref href="#sec-generatorfunction-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%GeneratorPrototype%
</td>
<td>
</td>
<td>
The prototype of generator objects (<emu-xref href="#sec-generator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Int8Array%
</td>
<td>
`Int8Array`
</td>
<td>
The Int8Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Int16Array%
</td>
<td>
`Int16Array`
</td>
<td>
The Int16Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Int32Array%
</td>
<td>
`Int32Array`
</td>
<td>
The Int32Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%isFinite%
</td>
<td>
`isFinite`
</td>
<td>
The `isFinite` function (<emu-xref href="#sec-isfinite-number"></emu-xref>)
</td>
</tr>
<tr>
<td>
%isNaN%
</td>
<td>
`isNaN`
</td>
<td>
The `isNaN` function (<emu-xref href="#sec-isnan-number"></emu-xref>)
</td>
</tr>
<tr>
<td>
%IteratorPrototype%
</td>
<td>
</td>
<td>
An object that all standard built-in iterator objects indirectly inherit from
</td>
</tr>
<tr>
<td>
%JSON%
</td>
<td>
`JSON`
</td>
<td>
The `JSON` object (<emu-xref href="#sec-json-object"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Map%
</td>
<td>
`Map`
</td>
<td>
The Map constructor (<emu-xref href="#sec-map-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%MapIteratorPrototype%
</td>
<td>
</td>
<td>
The prototype of Map iterator objects (<emu-xref href="#sec-map-iterator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Math%
</td>
<td>
`Math`
</td>
<td>
The `Math` object (<emu-xref href="#sec-math-object"></emu-xref>)
</td>
</tr>
<tr>
<td>
<ins>%ModuleSource%</ins>
</td>
<td>
<ins>`ModuleSource`</ins>
</td>
<td>
<ins>A `ModuleSource` object (<emu-xref href="#sec-module-source-object"></emu-xref>)</ins>
</td>
</tr>
<tr>
<td>
%Number%
</td>
<td>
`Number`
</td>
<td>
The Number constructor (<emu-xref href="#sec-number-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Object%
</td>
<td>
`Object`
</td>
<td>
The Object constructor (<emu-xref href="#sec-object-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%parseFloat%
</td>
<td>
`parseFloat`
</td>
<td>
The `parseFloat` function (<emu-xref href="#sec-parsefloat-string"></emu-xref>)
</td>
</tr>
<tr>
<td>
%parseInt%
</td>
<td>
`parseInt`
</td>
<td>
The `parseInt` function (<emu-xref href="#sec-parseint-string-radix"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Promise%
</td>
<td>
`Promise`
</td>
<td>
The Promise constructor (<emu-xref href="#sec-promise-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Proxy%
</td>
<td>
`Proxy`
</td>
<td>
The Proxy constructor (<emu-xref href="#sec-proxy-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%RangeError%
</td>
<td>
`RangeError`
</td>
<td>
The RangeError constructor (<emu-xref href="#sec-native-error-types-used-in-this-standard-rangeerror"></emu-xref>)
</td>
</tr>
<tr>
<td>
%ReferenceError%
</td>
<td>
`ReferenceError`
</td>
<td>
The ReferenceError constructor (<emu-xref href="#sec-native-error-types-used-in-this-standard-referenceerror"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Reflect%
</td>
<td>
`Reflect`
</td>
<td>
The `Reflect` object (<emu-xref href="#sec-reflect-object"></emu-xref>)
</td>
</tr>
<tr>
<td>
%RegExp%
</td>
<td>
`RegExp`
</td>
<td>
The RegExp constructor (<emu-xref href="#sec-regexp-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%RegExpStringIteratorPrototype%
</td>
<td>
</td>
<td>
The prototype of RegExp String Iterator objects (<emu-xref href="#sec-regexp-string-iterator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Set%
</td>
<td>
`Set`
</td>
<td>
The Set constructor (<emu-xref href="#sec-set-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%SetIteratorPrototype%
</td>
<td>
</td>
<td>
The prototype of Set iterator objects (<emu-xref href="#sec-set-iterator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%SharedArrayBuffer%
</td>
<td>
`SharedArrayBuffer`
</td>
<td>
The SharedArrayBuffer constructor (<emu-xref href="#sec-sharedarraybuffer-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%String%
</td>
<td>
`String`
</td>
<td>
The String constructor (<emu-xref href="#sec-string-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%StringIteratorPrototype%
</td>
<td>
</td>
<td>
The prototype of String iterator objects (<emu-xref href="#sec-string-iterator-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Symbol%
</td>
<td>
`Symbol`
</td>
<td>
The Symbol constructor (<emu-xref href="#sec-symbol-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%SyntaxError%
</td>
<td>
`SyntaxError`
</td>
<td>
The SyntaxError constructor (<emu-xref href="#sec-native-error-types-used-in-this-standard-syntaxerror"></emu-xref>)
</td>
</tr>
<tr>
<td>
%ThrowTypeError%
</td>
<td>
</td>
<td>
A function object that unconditionally throws a new instance of %TypeError%
</td>
</tr>
<tr>
<td>
%TypedArray%
</td>
<td>
</td>
<td>
The super class of all typed Array constructors (<emu-xref href="#sec-%typedarray%-intrinsic-object"></emu-xref>)
</td>
</tr>
<tr>
<td>
%TypeError%
</td>
<td>
`TypeError`
</td>
<td>
The TypeError constructor (<emu-xref href="#sec-native-error-types-used-in-this-standard-typeerror"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Uint8Array%
</td>
<td>
`Uint8Array`
</td>
<td>
The Uint8Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Uint8ClampedArray%
</td>
<td>
`Uint8ClampedArray`
</td>
<td>
The Uint8ClampedArray constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Uint16Array%
</td>
<td>
`Uint16Array`
</td>
<td>
The Uint16Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%Uint32Array%
</td>
<td>
`Uint32Array`
</td>
<td>
The Uint32Array constructor (<emu-xref href="#sec-typedarray-objects"></emu-xref>)
</td>
</tr>
<tr>
<td>
%URIError%
</td>
<td>
`URIError`
</td>
<td>
The URIError constructor (<emu-xref href="#sec-native-error-types-used-in-this-standard-urierror"></emu-xref>)
</td>
</tr>
<tr>
<td>
%WeakMap%
</td>
<td>
`WeakMap`
</td>
<td>
The WeakMap constructor (<emu-xref href="#sec-weakmap-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%WeakRef%
</td>
<td>
`WeakRef`
</td>
<td>
The WeakRef constructor (<emu-xref href="#sec-weak-ref-constructor"></emu-xref>)
</td>
</tr>
<tr>
<td>
%WeakSet%
</td>
<td>
`WeakSet`
</td>
<td>
The WeakSet constructor (<emu-xref href="#sec-weakset-constructor"></emu-xref>)
</td>
</tr>
</table>
</emu-table>
<emu-note>
<p>Additional entries in <emu-xref href="#table-additional-well-known-intrinsic-objects"></emu-xref>.</p>
</emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-ecmascript-language-expressions" number="13">
<h1>ECMAScript Language: Expressions</h1>
<emu-clause id="sec-left-hand-side-expressions" number="3">
<h1>Left-Hand-Side Expressions</h1>
<h2>Syntax</h2>
<emu-grammar type="definition">
ImportCall[Yield, Await] :
`import` `(` AssignmentExpression[+In, ?Yield, ?Await] `)`
`import` `.` `source` `(` AssignmentExpression[+In, ?Yield, ?Await] `)`
</emu-grammar>
<emu-clause id="sec-import-calls" number="10">
<h1>Import Calls</h1>
<emu-clause id="sec-import-call-runtime-semantics-evaluation" type="sdo">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ImportCall : `import` `(` AssignmentExpression[+In, ?Yield, ?Await] `)`</emu-grammar>
<emu-alg>
1. Return ? EvaluateImportCall(|AssignmentExpression|, ~evaluation~).
</emu-alg>
<emu-grammar>ImportCall : `import` `.` `source` `(` AssignmentExpression[+In, ?Yield, ?Await] `)`</emu-grammar>
<emu-alg>
1. Return ? EvaluateImportCall(|AssignmentExpression|, ~source~).
</emu-alg>
</emu-clause>
<emu-clause id="sec-evaluate-import-call" type="abstract operation">
<h1>
EvaluateImportCall (
_specifierExpression_: a Parse Node,
_phase_: ~source~ or ~evaluation~
): either a normal completion containing a Promise or a throw completion
</h1>
<dl class="header"></dl>
<emu-alg>
1. Let _referrer_ be GetActiveScriptOrModule().
1. If _referrer_ is *null*, set _referrer_ to the current Realm Record.
1. Let _specifierRef_ be ? Evaluation of evaluating _specifierExpression_.
1. Let _specifier_ be ? GetValue(_specifierRef_).
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
1. <ins>If _specifier_ is an Object, then</ins>
1. <ins>Let _module_ be GetModuleSourceModuleRecord(_specifier_).</ins>
1. <ins>If _module_ is ~not-a-source~, then</ins>
1. <ins>Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).</ins>
1. <ins>Return _promiseCapability_.[[Promise]].</ins>
1. <ins>If _module_.[[Realm]] is not equal to the current Realm Record, then</ins>
1. <ins>Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).</ins>
1. <ins>Return _promiseCapability_.[[Promise]].</ins>
1. <ins>Perform ContinueDynamicImport(_promiseCapability_, _phase_, Completion(_module_)).</ins>
1. <ins>Else,</ins>
1. Let _specifierString_ be Completion(ToString(_specifier_)).
1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_).
1. Let _moduleRequest_ be a new ModuleRequest Record { [[Specifier]]: _specifierString_, [[Phase]]: _phase_ }.
1. Perform HostLoadImportedModule(_referrer_, _moduleRequest_, ~empty~, _promiseCapability_).
1. Return _promiseCapability_.[[Promise]].
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-ContinueDynamicImport" type="abstract operation">
<h1>
ContinueDynamicImport (
_promiseCapability_: a PromiseCapability Record,
<ins>_phase_: ~source~ or ~evaluation~,</ins>
_moduleCompletion_: either a normal completion containing a Module Record or a throw completion,
): ~unused~
</h1>
<dl class="header">
<dt>description</dt>
<dd>It completes the process of a dynamic import originally started by an <emu-xref href="#sec-import-calls">`import()`</emu-xref> call, resolving or rejecting the promise returned by that call as appropriate.</dd>
</dl>
<emu-alg>
1. If _moduleCompletion_ is an abrupt completion, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _moduleCompletion_.[[Value]] »).
1. Return ~unused~.
1. Let _module_ be _moduleCompletion_.[[Value]].
1. If _phase_ is ~source~, then
1. Let _moduleSourceCompletion_ be Completion(_module_.GetModuleSource()).
1. If _moduleSourceCompletion_ is an abrupt completion, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _moduleSourceCompletion_.[[Value]] »).
1. Else,
1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _moduleSourceCompletion_.[[Value]] »).
1. Return ~unused~.
1. Let _loadPromise_ be _module_.LoadRequestedModules().
1. Let _rejectedClosure_ be a new Abstract Closure with parameters (_reason_) that captures _promiseCapability_ and performs the following steps when called:
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _reason_ »).
1. Return ~unused~.
1. Let _onRejected_ be CreateBuiltinFunction(_rejectedClosure_, 1, *""*, « »).
1. Let _linkAndEvaluateClosure_ be a new Abstract Closure with no parameters that captures _module_, _promiseCapability_, and _onRejected_ and performs the following steps when called:
1. Let _link_ be Completion(_module_.Link()).
1. If _link_ is an abrupt completion, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _link_.[[Value]] »).
1. Return ~unused~.
1. Let _evaluatePromise_ be _module_.Evaluate().
1. Let _fulfilledClosure_ be a new Abstract Closure with no parameters that captures _module_ and _promiseCapability_ and performs the following steps when called:
1. Let _namespace_ be GetModuleNamespace(_module_).
1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _namespace_ »).
1. Return ~unused~.
1. Let _onFulfilled_ be CreateBuiltinFunction(_fulfilledClosure_, *""*, 0, « »).
1. Perform PerformPromiseThen(_evaluatePromise_, _onFulfilled_, _onRejected_).
1. Let _linkAndEvaluate_ be CreateBuiltinFunction(_linkAndEvaluateClosure_, *""*, 0, « »).
1. Perform PerformPromiseThen(_loadPromise_, _linkAndEvaluate_, _onRejected_).
1. Return ~unused~.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-ecmascript-language-scripts-and-modules" number="16">
<h1>ECMAScript Language: Scripts and Modules</h1>
<emu-clause id="sec-modules">
<h1>Modules</h1>
<emu-clause id="sec-module-semantics">
<h1>Module Semantics</h1>
<emu-clause id="sec-abstract-module-records">
<h1>Abstract Module Records</h1>
<p>A <dfn variants="Module Records">Module Record</dfn> encapsulates structural information about the imports and exports of a single module. This information is used to link the imports and exports of sets of connected modules. A Module Record includes four fields that are only used when evaluating a module.</p>
<p>For specification purposes Module Record values are values of the Record specification type and can be thought of as existing in a simple object-oriented hierarchy where Module Record is an abstract class with both abstract and concrete subclasses. This specification defines the abstract subclass named Cyclic Module Record and its concrete subclass named Source Text Module Record. Other specifications and implementations may define additional Module Record subclasses corresponding to alternative module definition facilities that they defined.</p>
<p>Module Record defines the fields listed in <emu-xref href="#table-module-record-fields"></emu-xref>. All Module Definition subclasses include at least those fields. Module Record also defines the abstract method list in <emu-xref href="#table-abstract-methods-of-module-records"></emu-xref>. All Module definition subclasses must provide concrete implementations of these abstract methods.</p>
<emu-table id="table-module-record-fields" caption="Module Record Fields" oldids="table-36">
<table>
<thead>
<tr>
<th>
Field Name
</th>
<th>
Value Type
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tr>
<td>
[[Realm]]
</td>
<td>
a Realm Record
</td>
<td>
The Realm within which this module was created.
</td>
</tr>
<tr>
<td>
[[Environment]]
</td>
<td>
a Module Environment Record or ~empty~
</td>
<td>
The Environment Record containing the top level bindings for this module. This field is set when the module is linked.
</td>
</tr>
<tr>
<td>
[[Namespace]]
</td>
<td>
an Object or ~empty~
</td>
<td>
The Module Namespace Object (<emu-xref href="#sec-module-namespace-objects"></emu-xref>) if one has been created for this module.
</td>
</tr>
<tr>
<td>
[[HostDefined]]
</td>
<td>
anything (default value is *undefined*)
</td>
<td>
Field reserved for use by host environments that need to associate additional information with a module.
</td>
</tr>
</table>
</emu-table>
<emu-table id="table-abstract-methods-of-module-records" caption="Abstract Methods of Module Records" oldids="table-37">
<table>
<tr>
<th>
Method