forked from tc39/proposal-shadowrealm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
269 lines (215 loc) · 59.1 KB
/
index.html
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
<!doctype html>
<head><meta charset="utf-8">
<link href="ecmarkup.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="ecmarkup.js"></script>
<title>ECMAScript Realms Spec Proposal</title><script type="application/json" id="menu-search-biblio">[{"type":"table","id":"table-1","number":1,"caption":"Table 1: Well-known Intrinsic Objects","referencingIds":[],"namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","key":"Table 1: Well-known Intrinsic Objects"},{"type":"table","id":"table-21","number":2,"caption":"Table 2: Realm Record Fields","referencingIds":[],"namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","key":"Table 2: Realm Record Fields"},{"type":"op","aoid":"InvokeIsDirectEvalTrap","refId":"sec-invokeisdirectevaltrap","location":"","referencingIds":[],"key":"InvokeIsDirectEvalTrap"},{"type":"clause","id":"sec-invokeisdirectevaltrap","aoid":"InvokeIsDirectEvalTrap","title":"InvokeIsDirectEvalTrap( trap, func )","titleHTML":"InvokeIsDirectEvalTrap( <var>trap</var>, <var>func</var> )","number":"1.1","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_28"],"key":"InvokeIsDirectEvalTrap( trap, func )"},{"type":"op","aoid":"InvokeTransformTrap","refId":"sec-invoketransformtrap","location":"","referencingIds":[],"key":"InvokeTransformTrap"},{"type":"clause","id":"sec-invoketransformtrap","aoid":"InvokeTransformTrap","title":"InvokeTransformTrap ( trap, sourceText )","titleHTML":"InvokeTransformTrap ( <var>trap</var>, <var>sourceText</var> )","number":"1.2","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_13"],"key":"InvokeTransformTrap ( trap, sourceText )"},{"type":"clause","id":"sec-code-realms","aoid":null,"title":"Realms","titleHTML":"Realms","number":"1","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Realms"},{"type":"production","id":"prod-CallExpression","name":"CallExpression","referencingIds":[],"namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","key":"CallExpression"},{"type":"clause","id":"sec-import-early-errors","aoid":null,"title":"Additional Early Error Rules for Eval in Realms","titleHTML":"Additional Early Error Rules for Eval in Realms","number":"2.1","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_0","_ref_1"],"key":"Additional Early Error Rules for Eval in Realms"},{"type":"op","aoid":"PerformEval","refId":"sec-performeval","location":"","referencingIds":[],"key":"PerformEval"},{"type":"clause","id":"sec-performeval","aoid":"PerformEval","title":"Runtime Semantics: PerformEval ( x, evalRealm, strictCaller, direct )","titleHTML":"Runtime Semantics: PerformEval ( <var>x</var>, <var>evalRealm</var>, <var>strictCaller</var>, <var>direct</var> )","number":"2","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_22","_ref_32"],"key":"Runtime Semantics: PerformEval ( x, evalRealm, strictCaller, direct )"},{"type":"clause","id":"sec-function-calls-runtime-semantics-evaluation","aoid":null,"title":"Runtime Semantics: Evaluation","titleHTML":"Runtime Semantics: Evaluation","number":"3","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_4","_ref_15"],"key":"Runtime Semantics: Evaluation"},{"type":"op","aoid":"ParseScript","refId":"sec-parse-script","location":"","referencingIds":[],"key":"ParseScript"},{"type":"clause","id":"sec-parse-script","aoid":"ParseScript","title":"ParseScript ( sourceText, realm, hostDefined )","titleHTML":"ParseScript ( <var>sourceText</var>, <var>realm</var>, <var>hostDefined</var> )","number":"4","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_37"],"key":"ParseScript ( sourceText, realm, hostDefined )"},{"type":"op","aoid":"CreateRealmRec","refId":"sec-create-realm-rec","location":"","referencingIds":[],"key":"CreateRealmRec"},{"type":"clause","id":"sec-create-realm-rec","aoid":"CreateRealmRec","title":"CreateRealmRec ( intrinsics )","titleHTML":"CreateRealmRec ( <var>intrinsics</var> )","number":"5.1.1","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_56"],"key":"CreateRealmRec ( intrinsics )"},{"type":"op","aoid":"PerformRealmEvaluation","refId":"sec-performRealmEvaluation","location":"","referencingIds":[],"key":"PerformRealmEvaluation"},{"type":"clause","id":"sec-performRealmEvaluation","aoid":"PerformRealmEvaluation","title":"PerformRealmEvaluation ( x, evalRealm )","titleHTML":"PerformRealmEvaluation ( <var>x</var>, <var>evalRealm</var> )","number":"5.1.2","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_23","_ref_65"],"key":"PerformRealmEvaluation ( x, evalRealm )"},{"type":"clause","id":"sec-realm-abstract-operations","aoid":null,"title":"Realm Abstract Operations","titleHTML":"Realm Abstract Operations","number":"5.1","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Realm Abstract Operations"},{"type":"op","aoid":"Realm","refId":"sec-realm","location":"","referencingIds":[],"key":"Realm"},{"type":"clause","id":"sec-realm","aoid":"Realm","title":"Realm ([ options ])","titleHTML":"Realm ([ <var>options</var> ])","number":"5.2.1","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":["_ref_3","_ref_18","_ref_24","_ref_41","_ref_42","_ref_43","_ref_44","_ref_45","_ref_46","_ref_76","_ref_77","_ref_78","_ref_79","_ref_80"],"key":"Realm ([ options ])"},{"type":"clause","id":"sec-the-realm-constructor","aoid":null,"title":"The Realm Constructor","titleHTML":"The Realm Constructor","number":"5.2","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"The Realm Constructor"},{"type":"clause","id":"sec-properties-of-the-realm-constructor","aoid":null,"title":"Properties of the Realm Constructor","titleHTML":"Properties of the Realm Constructor","number":"5.3","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Properties of the Realm Constructor"},{"type":"clause","id":"sec-realm.prototype.init","aoid":null,"title":"Realm.prototype.init ()","titleHTML":"Realm.prototype.init ()","number":"5.4.1","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Realm.prototype.init ()"},{"type":"clause","id":"sec-realm.prototype.eval","aoid":null,"title":"Realm.prototype.evaluate ( sourceText )","titleHTML":"Realm.prototype.evaluate ( <var>sourceText</var> )","number":"5.4.2","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Realm.prototype.evaluate ( sourceText )"},{"type":"clause","id":"sec-realm.prototype.global","aoid":null,"title":"get Realm.prototype.global","titleHTML":"get Realm.prototype.global","number":"5.4.3","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"get Realm.prototype.global"},{"type":"clause","id":"sec-realm.prototype.thisValue","aoid":null,"title":"get Realm.prototype.thisValue","titleHTML":"get Realm.prototype.thisValue","number":"5.4.4","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"get Realm.prototype.thisValue"},{"type":"clause","id":"sec-realm.prototype.stdlib","aoid":null,"title":"get Realm.prototype.stdlib","titleHTML":"get Realm.prototype.stdlib","number":"5.4.5","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"get Realm.prototype.stdlib"},{"type":"clause","id":"sec-realm.prototype.intrinsics","aoid":null,"title":"get Realm.prototype.intrinsics","titleHTML":"get Realm.prototype.intrinsics","number":"5.4.6","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"get Realm.prototype.intrinsics"},{"type":"clause","id":"sec-realm.prototype-@@tostringtag","aoid":null,"title":"Realm.prototype [ @@toStringTag ]","titleHTML":"Realm.prototype [ @@toStringTag ]","number":"5.4.7","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Realm.prototype [ @@toStringTag ]"},{"type":"clause","id":"sec-properties-of-the-realm-prototype-object","aoid":null,"title":"Properties of the Realm Prototype Object","titleHTML":"Properties of the Realm Prototype Object","number":"5.4","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Properties of the Realm Prototype Object"},{"type":"table","id":"table-3","number":3,"caption":"Table 3: Internal Slots of Realm Instances","referencingIds":["_ref_2"],"namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","key":"Table 3: Internal Slots of Realm Instances"},{"type":"clause","id":"sec-properties-of-realm-instances","aoid":null,"title":"Properties of Realm Instances","titleHTML":"Properties of Realm Instances","number":"5.5","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Properties of Realm Instances"},{"type":"clause","id":"sec-realm-objects","aoid":null,"title":"Realm Objects","titleHTML":"Realm Objects","number":"5","namespace":"https://rawgit.com/tc39/proposal-realms/master/index.html","location":"","referencingIds":[],"key":"Realm Objects"}]</script></head><body><div id="menu-toggle">☰</div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-code-realms" title="Realms"><span class="secnum">1</span> Realms</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-invokeisdirectevaltrap" title="InvokeIsDirectEvalTrap( trap, func )"><span class="secnum">1.1</span> InvokeIsDirectEvalTrap( <var>trap</var>, <var>func</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-invoketransformtrap" title="InvokeTransformTrap ( trap, sourceText )"><span class="secnum">1.2</span> InvokeTransformTrap ( <var>trap</var>, <var>sourceText</var> )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#sec-performeval" title="Runtime Semantics: PerformEval ( x, evalRealm, strictCaller, direct )"><span class="secnum">2</span> RS: PerformEval ( <var>x</var>, <var>evalRealm</var>, <var>strictCaller</var>, <var>direct</var> )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-import-early-errors" title="Additional Early Error Rules for Eval in Realms"><span class="secnum">2.1</span> Additional Early Error Rules for Eval in Realms</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-function-calls-runtime-semantics-evaluation" title="Runtime Semantics: Evaluation"><span class="secnum">3</span> RS: Evaluation</a></li><li><span class="item-toggle-none"></span><a href="#sec-parse-script" title="ParseScript ( sourceText, realm, hostDefined )"><span class="secnum">4</span> ParseScript ( <var>sourceText</var>, <var>realm</var>, <var>hostDefined</var> )</a></li><li><span class="item-toggle">◢</span><a href="#sec-realm-objects" title="Realm Objects"><span class="secnum">5</span> Realm Objects</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-realm-abstract-operations" title="Realm Abstract Operations"><span class="secnum">5.1</span> Realm Abstract Operations</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-create-realm-rec" title="CreateRealmRec ( intrinsics )"><span class="secnum">5.1.1</span> CreateRealmRec ( <var>intrinsics</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-performRealmEvaluation" title="PerformRealmEvaluation ( x, evalRealm )"><span class="secnum">5.1.2</span> PerformRealmEvaluation ( <var>x</var>, <var>evalRealm</var> )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#sec-the-realm-constructor" title="The Realm Constructor"><span class="secnum">5.2</span> The Realm Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-realm" title="Realm ([ options ])"><span class="secnum">5.2.1</span> Realm ([ <var>options</var> ])</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-the-realm-constructor" title="Properties of the Realm Constructor"><span class="secnum">5.3</span> Properties of the Realm Constructor</a></li><li><span class="item-toggle">◢</span><a href="#sec-properties-of-the-realm-prototype-object" title="Properties of the Realm Prototype Object"><span class="secnum">5.4</span> Properties of the Realm Prototype Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-realm.prototype.init" title="Realm.prototype.init ()"><span class="secnum">5.4.1</span> Realm.prototype.init ()</a></li><li><span class="item-toggle-none"></span><a href="#sec-realm.prototype.eval" title="Realm.prototype.evaluate ( sourceText )"><span class="secnum">5.4.2</span> Realm.prototype.evaluate ( <var>sourceText</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-realm.prototype.global" title="get Realm.prototype.global"><span class="secnum">5.4.3</span> get Realm.prototype.global</a></li><li><span class="item-toggle-none"></span><a href="#sec-realm.prototype.thisValue" title="get Realm.prototype.thisValue"><span class="secnum">5.4.4</span> get Realm.prototype.thisValue</a></li><li><span class="item-toggle-none"></span><a href="#sec-realm.prototype.stdlib" title="get Realm.prototype.stdlib"><span class="secnum">5.4.5</span> get Realm.prototype.stdlib</a></li><li><span class="item-toggle-none"></span><a href="#sec-realm.prototype.intrinsics" title="get Realm.prototype.intrinsics"><span class="secnum">5.4.6</span> get Realm.prototype.intrinsics</a></li><li><span class="item-toggle-none"></span><a href="#sec-realm.prototype-@@tostringtag" title="Realm.prototype [ @@toStringTag ]"><span class="secnum">5.4.7</span> Realm.prototype [ @@toStringTag ]</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-realm-instances" title="Properties of Realm Instances"><span class="secnum">5.5</span> Properties of Realm Instances</a></li></ol></li></ol></div></div><div id="spec-container"><h1 class="title first">ECMAScript Realms Spec Proposal</h1>
<emu-table id="table-1" caption="Well-known Intrinsic Objects"><figure><figcaption>Table 1: Well-known Intrinsic Objects</figcaption>
<table>
<tbody>
<tr>
<th>Intrinsic Name</th>
<th>Global Name</th>
<th>ECMAScript Language Association</th>
</tr>
<tr>
<td>%<emu-xref aoid="Realm" id="_ref_3"><a href="#sec-realm">Realm</a></emu-xref>%</td>
<td><code>Realm</code></td>
<td>…</td>
</tr>
<tr>
<td>%RealmPrototype%</td>
<td><code>Realm.prototype</code></td>
<td>…</td>
</tr>
</tbody>
</table>
</figure></emu-table>
<!-- es6num="8.2" -->
<emu-clause id="sec-code-realms">
<h1><span class="secnum">1</span>Realms</h1>
<emu-table id="table-21" caption="Realm Record Fields"><figure><figcaption>Table 2: <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref> Fields</figcaption>
<table>
<tbody>
<tr>
<th>Field Name</th>
<th>Value</th>
<th>Meaning</th>
</tr>
<tr>
<td>[[HostDefined]]</td>
<td>...</td>
<td>...</td>
</tr>
<tr>
<td>[[TransformTrap]]</td>
<td>A function object or <emu-val>undefined</emu-val></td>
<td>The function that is used as the transform trap. If [[TransformTrap]] is undefined, the trap invoker will carry on the default behavior.</td>
</tr>
<tr>
<td>[[IsDirectEvalTrap]]</td>
<td>A function object or <emu-val>undefined</emu-val></td>
<td>The function that is used as the <emu-xref href="#sec-function-calls-runtime-semantics-evaluation" id="_ref_4"><a href="#sec-function-calls-runtime-semantics-evaluation">direct eval</a></emu-xref> check trap. If [[IsDirectEvalTrap]] is undefined, the trap invoker will carry on the default behavior.</td>
</tr>
<tr>
<td>[[PreventImportExpression]]</td>
<td>A boolean value</td>
<td>Whether or not import declarations or expressions are allowed. Default to <emu-val>false</emu-val>.</td>
</tr>
</tbody>
</table>
</figure></emu-table>
<emu-clause id="sec-invokeisdirectevaltrap" aoid="InvokeIsDirectEvalTrap">
<h1><span class="secnum">1.1</span>InvokeIsDirectEvalTrap( <var>trap</var>, <var>func</var> )</h1>
<p>The abstract operation InvokeIsDirectEvalTrap with arguments <var>trap</var> and <var>func</var> performs the following steps:</p>
<emu-alg><ol><li>Assert: <emu-xref aoid="IsCallable" id="_ref_5"><a href="https://tc39.github.io/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>trap</var>) is <emu-val>true</emu-val>.</li><li>Let <var>result</var> be <emu-xref aoid="ToBoolean" id="_ref_6"><a href="https://tc39.github.io/ecma262/#sec-toboolean">ToBoolean</a></emu-xref>( ? <emu-xref aoid="Call" id="_ref_7"><a href="https://tc39.github.io/ecma262/#sec-call">Call</a></emu-xref>(<var>trap</var>, <emu-val>undefined</emu-val>, « <var>func</var> »)).</li><li>Return <var>result</var>.
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-invoketransformtrap" aoid="InvokeTransformTrap">
<h1><span class="secnum">1.2</span>InvokeTransformTrap ( <var>trap</var>, <var>sourceText</var> )</h1>
<p>The abstract operation InvokeTransformTrap with arguments <var>trap</var> and <var>sourceText</var> performs the following steps:</p>
<emu-alg><ol><li>Assert: <emu-xref aoid="IsCallable" id="_ref_8"><a href="https://tc39.github.io/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>trap</var>) is <emu-val>true</emu-val>.</li><li>Let <var>newSourceText</var> be ? <emu-xref aoid="Call" id="_ref_9"><a href="https://tc39.github.io/ecma262/#sec-call">Call</a></emu-xref>(<var>trap</var>, <emu-val>undefined</emu-val>, « <var>sourceText</var> »).</li><li>Return ? <emu-xref aoid="ToString" id="_ref_10"><a href="https://tc39.github.io/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>newSourceText</var>).
</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<!-- es6num="18.2.1.1" -->
<emu-clause id="sec-performeval" aoid="PerformEval">
<h1><span class="secnum">2</span>Runtime Semantics: PerformEval ( <var>x</var>, <var>evalRealm</var>, <var>strictCaller</var>, <var>direct</var> )</h1>
<p>The abstract operation PerformEval with arguments <var>x</var>, <var>evalRealm</var>, <var>strictCaller</var>, and <var>direct</var> performs the following steps:</p>
<emu-alg><ol><li>Assert: If <var>direct</var> is <emu-val>false</emu-val>, then <var>strictCaller</var> is also <emu-val>false</emu-val>.</li><li>If <emu-xref aoid="Type" id="_ref_11"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>x</var>) is not String, return <var>x</var>.</li><li><ins>Let <var>fn</var> be <var>evalRealm</var>.[[TransformTrap]]</ins>.</li><li><ins>If <emu-xref aoid="IsCallable" id="_ref_12"><a href="https://tc39.github.io/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>fn</var>) is <emu-val>true</emu-val>, then</ins><ol><li><ins>Let <var>x</var> be ? <emu-xref aoid="InvokeTransformTrap" id="_ref_13"><a href="#sec-invoketransformtrap">InvokeTransformTrap</a></emu-xref>(<var>fn</var>, <var>x</var>).</ins>.</li></ol></li><li>Let <var>thisEnvRec</var> be ! <emu-xref aoid="GetThisEnvironment" id="_ref_14"><a href="https://tc39.github.io/ecma262/#sec-getthisenvironment">GetThisEnvironment</a></emu-xref>().</li><li>If <var>thisEnvRec</var> is a <emu-xref href="#sec-function-environment-records"><a href="https://tc39.github.io/ecma262/#sec-function-environment-records">function Environment Record</a></emu-xref>, then<ol><li>Let <var>F</var> be <var>thisEnvRec</var>.[[FunctionObject]].</li><li>Let <var>inFunction</var> be <emu-val>true</emu-val>.</li><li>Let <var>inMethod</var> be <var>thisEnvRec</var>.HasSuperBinding().</li><li>If <var>F</var>.[[ConstructorKind]] is <code>"derived"</code>, let <var>inDerivedConstructor</var> be <emu-val>true</emu-val>; otherwise, let <var>inDerivedConstructor</var> be <emu-val>false</emu-val>.</li></ol></li><li>Else,<ol><li>Let <var>inFunction</var> be <emu-val>false</emu-val>.</li><li>Let <var>inMethod</var> be <emu-val>false</emu-val>.</li><li>Let <var>inDerivedConstructor</var> be <emu-val>false</emu-val>.</li></ol></li><li><ins>Let <var>preventImport</var> is <var>evalRealm</var>.[[PreventImportExpression]]</ins>.</li><li>Let <var>script</var> be the ECMAScript code that is the result of parsing <var>x</var>, interpreted as UTF-16 encoded Unicode text as described in <emu-xref href="#sec-ecmascript-language-types-string-type"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>, for the <emu-xref href="#sec-context-free-grammars"><a href="https://tc39.github.io/ecma262/#sec-context-free-grammars">goal symbol</a></emu-xref> <emu-nt><a href="https://tc39.github.io/ecma262/#prod-Script">Script</a></emu-nt>. <ins>If <var>preventImport</var> is <emu-val>true</emu-val>, additional <emu-xref href="#early-error"><a href="https://tc39.github.io/ecma262/#early-error">early error</a></emu-xref> rules from <emu-xref href="#sec-import-early-errors" id="_ref_0"><a href="#sec-import-early-errors">2.1</a></emu-xref> are applied. </ins>If <var>inFunction</var> is <emu-val>false</emu-val>, additional <emu-xref href="#early-error"><a href="https://tc39.github.io/ecma262/#early-error">early error</a></emu-xref> rules from <emu-xref href="#sec-performeval-rules-outside-functions"><a href="https://tc39.github.io/ecma262/#sec-performeval-rules-outside-functions">18.2.1.1.1</a></emu-xref> are applied. If <var>inMethod</var> is <emu-val>false</emu-val>, additional <emu-xref href="#early-error"><a href="https://tc39.github.io/ecma262/#early-error">early error</a></emu-xref> rules from <emu-xref href="#sec-performeval-rules-outside-methods"><a href="https://tc39.github.io/ecma262/#sec-performeval-rules-outside-methods">18.2.1.1.2</a></emu-xref> are applied. If <var>inDerivedConstructor</var> is <emu-val>false</emu-val>, additional <emu-xref href="#early-error"><a href="https://tc39.github.io/ecma262/#early-error">early error</a></emu-xref> rules from <emu-xref href="#sec-performeval-rules-outside-constructors"><a href="https://tc39.github.io/ecma262/#sec-performeval-rules-outside-constructors">18.2.1.1.3</a></emu-xref> are applied. If the parse fails, throw a <emu-val>SyntaxError</emu-val> exception. If any early errors are detected, throw a <emu-val>SyntaxError</emu-val> or a <emu-val>ReferenceError</emu-val> exception, depending on the type of the error (but see also clause <emu-xref href="#sec-error-handling-and-language-extensions"><a href="https://tc39.github.io/ecma262/#sec-error-handling-and-language-extensions">16</a></emu-xref>). Parsing and <emu-xref href="#early-error"><a href="https://tc39.github.io/ecma262/#early-error">early error</a></emu-xref> detection may be interweaved in an implementation-dependent manner.</li><li>If <var>script</var> Contains <emu-nt><a href="https://tc39.github.io/ecma262/#prod-ScriptBody">ScriptBody</a></emu-nt> is <emu-val>false</emu-val>, return <emu-val>undefined</emu-val>.</li><li>Let <var>body</var> be the <emu-nt><a href="https://tc39.github.io/ecma262/#prod-ScriptBody">ScriptBody</a></emu-nt> of <var>script</var>.</li><li>If <var>strictCaller</var> is <emu-val>true</emu-val>, let <var>strictEval</var> be <emu-val>true</emu-val>.</li><li>Else, let <var>strictEval</var> be IsStrict of <var>script</var>.</li><li>Let <var>ctx</var> be the <emu-xref href="#running-execution-context"><a href="https://tc39.github.io/ecma262/#running-execution-context">running execution context</a></emu-xref>.</li><li>NOTE: If <var>direct</var> is <emu-val>true</emu-val>, <var>ctx</var> will be the <emu-xref href="#sec-execution-contexts"><a href="https://tc39.github.io/ecma262/#sec-execution-contexts">execution context</a></emu-xref> that performed the <emu-xref href="#sec-function-calls-runtime-semantics-evaluation" id="_ref_15"><a href="#sec-function-calls-runtime-semantics-evaluation">direct eval</a></emu-xref>. If <var>direct</var> is <emu-val>false</emu-val>, <var>ctx</var> will be the <emu-xref href="#sec-execution-contexts"><a href="https://tc39.github.io/ecma262/#sec-execution-contexts">execution context</a></emu-xref> for the invocation of the <code>eval</code> function.</li><li>If <var>direct</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>lexEnv</var> be <emu-xref aoid="NewDeclarativeEnvironment" id="_ref_16"><a href="https://tc39.github.io/ecma262/#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a></emu-xref>(<var>ctx</var>'s LexicalEnvironment).</li><li>Let <var>varEnv</var> be <var>ctx</var>'s VariableEnvironment.</li></ol></li><li>Else,<ol><li>Let <var>lexEnv</var> be <emu-xref aoid="NewDeclarativeEnvironment" id="_ref_17"><a href="https://tc39.github.io/ecma262/#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a></emu-xref>(<var>evalRealm</var>.[[GlobalEnv]]).</li><li>Let <var>varEnv</var> be <var>evalRealm</var>.[[GlobalEnv]].</li></ol></li><li>If <var>strictEval</var> is <emu-val>true</emu-val>, set <var>varEnv</var> to <var>lexEnv</var>.</li><li>If <var>ctx</var> is not already suspended, suspend <var>ctx</var>.</li><li>Let <var>evalCxt</var> be a new ECMAScript code <emu-xref href="#sec-execution-contexts"><a href="https://tc39.github.io/ecma262/#sec-execution-contexts">execution context</a></emu-xref>.</li><li>Set the <var>evalCxt</var>'s Function to <emu-val>null</emu-val>.</li><li>Set the <var>evalCxt</var>'s <emu-xref aoid="Realm" id="_ref_18"><a href="#sec-realm">Realm</a></emu-xref> to <var>evalRealm</var>.</li><li>Set the <var>evalCxt</var>'s ScriptOrModule to <var>ctx</var>'s ScriptOrModule.</li><li>Set the <var>evalCxt</var>'s VariableEnvironment to <var>varEnv</var>.</li><li>Set the <var>evalCxt</var>'s LexicalEnvironment to <var>lexEnv</var>.</li><li>Push <var>evalCxt</var> on to the <emu-xref href="#execution-context-stack"><a href="https://tc39.github.io/ecma262/#execution-context-stack">execution context stack</a></emu-xref>; <var>evalCxt</var> is now the <emu-xref href="#running-execution-context"><a href="https://tc39.github.io/ecma262/#running-execution-context">running execution context</a></emu-xref>.</li><li>Let <var>result</var> be <emu-xref aoid="EvalDeclarationInstantiation" id="_ref_19"><a href="https://tc39.github.io/ecma262/#sec-evaldeclarationinstantiation">EvalDeclarationInstantiation</a></emu-xref>(<var>body</var>, <var>varEnv</var>, <var>lexEnv</var>, <var>strictEval</var>).</li><li>If <var>result</var>.[[Type]] is <emu-const>normal</emu-const>, then<ol><li>Set <var>result</var> to the result of evaluating <var>body</var>.</li></ol></li><li>If <var>result</var>.[[Type]] is <emu-const>normal</emu-const> and <var>result</var>.[[Value]] is <emu-const>empty</emu-const>, then<ol><li>Set <var>result</var> to <emu-xref aoid="NormalCompletion" id="_ref_20"><a href="https://tc39.github.io/ecma262/#sec-normalcompletion">NormalCompletion</a></emu-xref>(<emu-val>undefined</emu-val>).</li></ol></li><li>Suspend <var>evalCxt</var> and remove it from the <emu-xref href="#execution-context-stack"><a href="https://tc39.github.io/ecma262/#execution-context-stack">execution context stack</a></emu-xref>.</li><li>Resume the context that is now on the top of the <emu-xref href="#execution-context-stack"><a href="https://tc39.github.io/ecma262/#execution-context-stack">execution context stack</a></emu-xref> as the <emu-xref href="#running-execution-context"><a href="https://tc39.github.io/ecma262/#running-execution-context">running execution context</a></emu-xref>.</li><li>Return <emu-xref aoid="Completion" id="_ref_21"><a href="https://tc39.github.io/ecma262/#sec-completion-record-specification-type">Completion</a></emu-xref>(<var>result</var>).
</li></ol></emu-alg>
<!-- es6num="18.2.1.1.3" -->
<emu-clause id="sec-import-early-errors">
<h1><span class="secnum">2.1</span>Additional Early Error Rules for Eval in Realms</h1>
<p>These static semantics are applied by <emu-xref aoid="PerformEval" id="_ref_22"><a href="#sec-performeval">PerformEval</a></emu-xref> and <emu-xref aoid="PerformRealmEvaluation" id="_ref_23"><a href="#sec-performRealmEvaluation">PerformRealmEvaluation</a></emu-xref> when evaluating code in a <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref> associated to a <emu-xref aoid="Realm" id="_ref_24"><a href="#sec-realm">Realm</a></emu-xref> Object.</p>
<emu-grammar><emu-production name="CallExpression" collapsed="" id="prod-CallExpression">
<emu-nt><a href="#prod-CallExpression">CallExpression</a></emu-nt><emu-geq>:</emu-geq><emu-rhs a="9185f623"><emu-nt>ImportCall</emu-nt></emu-rhs>
</emu-production></emu-grammar>
<ul>
<li>It is a <emu-xref href="#sec-reference-specification-type"><a href="https://tc39.github.io/ecma262/#sec-reference-specification-type">Reference</a></emu-xref> Error if the <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref> Field Name [[PreventImportExpression]] has the value of <emu-val>true</emu-val>.</li>
</ul>
</emu-clause>
</emu-clause>
<!-- es6num="12.3.4.1" -->
<emu-clause id="sec-function-calls-runtime-semantics-evaluation">
<h1><span class="secnum">3</span>Runtime Semantics: Evaluation</h1>
<emu-grammar><emu-production name="CallExpression" collapsed="">
<emu-nt><a href="#prod-CallExpression">CallExpression</a></emu-nt><emu-geq>:</emu-geq><emu-rhs a="ec98fef7"><emu-nt><a href="https://tc39.github.io/ecma262/#prod-CoverCallExpressionAndAsyncArrowHead">CoverCallExpressionAndAsyncArrowHead</a></emu-nt></emu-rhs>
</emu-production></emu-grammar>
<emu-alg><ol><li>Let <var>expr</var> be CoveredCallExpression of CoverCallExpressionAndAsyncArrowHead.</li><li>Let <var>memberExpr</var> be the MemberExpression of <var>expr</var>.</li><li>Let <var>arguments</var> be the Arguments of <var>expr</var>.</li><li>Let <var>ref</var> be the result of evaluating <var>memberExpr</var>.</li><li>Let <var>func</var> be ? <emu-xref aoid="GetValue" id="_ref_25"><a href="https://tc39.github.io/ecma262/#sec-getvalue">GetValue</a></emu-xref>(<var>ref</var>).</li><li>If <emu-xref aoid="Type" id="_ref_26"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>ref</var>) is <emu-xref href="#sec-reference-specification-type"><a href="https://tc39.github.io/ecma262/#sec-reference-specification-type">Reference</a></emu-xref> and <emu-xref href="#ao-ispropertyreference"><a href="https://tc39.github.io/ecma262/#ao-ispropertyreference">IsPropertyReference</a></emu-xref>(<var>ref</var>) is <emu-val>false</emu-val> and <emu-xref href="#ao-getreferencedname"><a href="https://tc39.github.io/ecma262/#ao-getreferencedname">GetReferencedName</a></emu-xref>(<var>ref</var>) is <code>"eval"</code>, then<ol><li><ins>Let <var>evalRealm</var> be <emu-xref href="#current-realm"><a href="https://tc39.github.io/ecma262/#current-realm">the current Realm Record</a></emu-xref>.</ins>.</li><li><ins>Let <var>trapFn</var> be <var>evalRealm</var>.[[IsDirectEvalTrap]]</ins>.</li><li><ins>If <emu-xref aoid="IsCallable" id="_ref_27"><a href="https://tc39.github.io/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>trapFn</var>) is <emu-val>true</emu-val>, then</ins><ol><li><ins>Let <var>isDirectEval</var> be ? <emu-xref aoid="InvokeIsDirectEvalTrap" id="_ref_28"><a href="#sec-invokeisdirectevaltrap">InvokeIsDirectEvalTrap</a></emu-xref>(<var>trapFn</var>, <var>func</var>).</ins>.</li></ol></li><li> <ins>Else</ins>,<ol><li><ins>Let <var>isDirectEval</var> be <emu-xref aoid="SameValue" id="_ref_29"><a href="https://tc39.github.io/ecma262/#sec-samevalue">SameValue</a></emu-xref>(<var>func</var>, <emu-xref href="#sec-eval-x"><a href="https://tc39.github.io/ecma262/#sec-eval-x">%eval%</a></emu-xref>)</ins>.</li></ol></li><li>If <ins><var>isDirectEval</var></ins><del><emu-xref aoid="SameValue" id="_ref_30"><a href="https://tc39.github.io/ecma262/#sec-samevalue">SameValue</a></emu-xref>(<var>func</var>, <emu-xref href="#sec-eval-x"><a href="https://tc39.github.io/ecma262/#sec-eval-x">%eval%</a></emu-xref>)</del> is <emu-val>true</emu-val>, then<ol><li>Let <var>argList</var> be ? ArgumentListEvaluation(<var>arguments</var>).</li><li>If <var>argList</var> has no elements, return undefined.</li><li>Let <var>evalText</var> be the first element of <var>argList</var>.</li><li>If the source code matching this CallExpression is <emu-xref href="#sec-strict-mode-code"><a href="https://tc39.github.io/ecma262/#sec-strict-mode-code">strict mode code</a></emu-xref>, let <var>strictCaller</var> be <emu-val>true</emu-val>. Otherwise let strictCaller be <emu-val>false</emu-val>.</li><li><del>Let evalRealm be <emu-xref href="#current-realm"><a href="https://tc39.github.io/ecma262/#current-realm">the current Realm Record</a></emu-xref></del>.</li><li>Perform ? <emu-xref aoid="HostEnsureCanCompileStrings" id="_ref_31"><a href="https://tc39.github.io/ecma262/#sec-hostensurecancompilestrings">HostEnsureCanCompileStrings</a></emu-xref>(<var>evalRealm</var>, <var>evalRealm</var>).</li><li>Return ? <emu-xref aoid="PerformEval" id="_ref_32"><a href="#sec-performeval">PerformEval</a></emu-xref>(<var>evalText</var>, <var>evalRealm</var>, <var>strictCaller</var>, <emu-val>true</emu-val>).</li></ol></li></ol></li><li>Let <var>thisCall</var> be this CallExpression.</li><li>Let <var>tailCall</var> be <emu-xref aoid="IsInTailPosition" id="_ref_33"><a href="https://tc39.github.io/ecma262/#sec-isintailposition">IsInTailPosition</a></emu-xref>(<var>thisCall</var>).</li><li>Return ? <emu-xref aoid="EvaluateCall" id="_ref_34"><a href="https://tc39.github.io/ecma262/#sec-evaluatecall">EvaluateCall</a></emu-xref>(<var>func</var>, <var>ref</var>, <var>arguments</var>, <var>tailCall</var>).
</li></ol></emu-alg>
</emu-clause>
<!-- es6num="15.1.9" -->
<emu-clause id="sec-parse-script" aoid="ParseScript">
<h1><span class="secnum">4</span>ParseScript ( <var>sourceText</var>, <var>realm</var>, <var>hostDefined</var> )</h1>
<p>The abstract operation ParseScript with arguments <var>sourceText</var>, <var>realm</var>, and <var>hostDefined</var> creates a <emu-xref href="#script-record"><a href="https://tc39.github.io/ecma262/#script-record">Script Record</a></emu-xref> based upon the result of parsing <var>sourceText</var> as a <emu-nt><a href="https://tc39.github.io/ecma262/#prod-Script">Script</a></emu-nt>. ParseScript performs the following steps:</p>
<emu-alg><ol><li>Assert: <var>sourceText</var> is an ECMAScript source text (see clause <emu-xref href="#sec-ecmascript-language-source-code"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-source-code">10</a></emu-xref>).</li><li><ins>Let <var>preventImport</var> is <var>realm</var>.[[PreventImportExpression]]</ins>.</li><li>Parse <var>sourceText</var> using <emu-nt><a href="https://tc39.github.io/ecma262/#prod-Script">Script</a></emu-nt> as the <emu-xref href="#sec-context-free-grammars"><a href="https://tc39.github.io/ecma262/#sec-context-free-grammars">goal symbol</a></emu-xref> and analyse the parse result for any Early Error conditions. <ins>If <var>preventImport</var> is <emu-val>true</emu-val>, additional <emu-xref href="#early-error"><a href="https://tc39.github.io/ecma262/#early-error">early error</a></emu-xref> rules from <emu-xref href="#sec-import-early-errors" id="_ref_1"><a href="#sec-import-early-errors">2.1</a></emu-xref> are applied. </ins>If the parse was successful and no early errors were found, let <var>body</var> be the resulting parse tree. Otherwise, let <var>body</var> be a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of one or more <emu-val>SyntaxError</emu-val> or <emu-val>ReferenceError</emu-val> objects representing the parsing errors and/or early errors. Parsing and <emu-xref href="#early-error"><a href="https://tc39.github.io/ecma262/#early-error">early error</a></emu-xref> detection may be interweaved in an implementation-dependent manner. If more than one parsing error or <emu-xref href="#early-error"><a href="https://tc39.github.io/ecma262/#early-error">early error</a></emu-xref> is present, the number and ordering of error objects in the list is implementation-dependent, but at least one must be present.</li><li>If <var>body</var> is a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of errors, return <var>body</var>.</li><li>Return <emu-xref href="#script-record"><a href="https://tc39.github.io/ecma262/#script-record">Script Record</a></emu-xref> {[[Realm]]: <var>realm</var>, [[Environment]]: <emu-val>undefined</emu-val>, [[ECMAScriptCode]]: <var>body</var>, [[HostDefined]]: <var>hostDefined</var>}.
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-realm-objects">
<h1><span class="secnum">5</span>Realm Objects</h1>
<emu-clause id="sec-realm-abstract-operations">
<h1><span class="secnum">5.1</span>Realm Abstract Operations</h1>
<emu-clause id="sec-create-realm-rec" aoid="CreateRealmRec">
<h1><span class="secnum">5.1.1</span>CreateRealmRec ( <var>intrinsics</var> )</h1>
<emu-alg><ol><li>Let <var>realmRec</var> be a new <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref>.</li><li>If <var>intrinsics</var> is <emu-val>undefined</emu-val>, then<ol><li>Perform <emu-xref aoid="CreateIntrinsics" id="_ref_35"><a href="https://tc39.github.io/ecma262/#sec-createintrinsics">CreateIntrinsics</a></emu-xref>(<var>realmRec</var>).</li></ol></li><li>Else<ol><li>Assert: In this case, <var>intrinsics</var> must be a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> with field names listed in column one of Table 7.</li><li>Set <var>realmRec</var>.[[Intrinsics]] to <var>intrinsics</var>.</li></ol></li><li>Set <var>realmRec</var>.[[GlobalObject]] to <emu-val>undefined</emu-val>.</li><li>Set <var>realmRec</var>.[[GlobalEnv]] to <emu-val>undefined</emu-val>.</li><li>Set <var>realmRec</var>.[[TemplateMap]] to a new empty <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Return <var>realmRec</var>.
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-performRealmEvaluation" aoid="PerformRealmEvaluation">
<h1><span class="secnum">5.1.2</span>PerformRealmEvaluation ( <var>x</var>, <var>evalRealm</var> )</h1>
<emu-alg><ol><li>Assert: <emu-xref aoid="Type" id="_ref_36"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>x</var>) is String.</li><li>Assert: <var>evalRealm</var> is a <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref>.</li><li>Let <var>hostDefined</var> be <var>evalRealm</var>.[[HostDefined]].</li><li>Let <var>s</var> be <emu-xref aoid="ParseScript" id="_ref_37"><a href="#sec-parse-script">ParseScript</a></emu-xref>(<var>x</var>, <var>evalRealm</var>, <var>hostDefined</var>).</li><li>If <var>s</var> is a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of errors, then<ol><li>Perform <emu-xref aoid="HostReportErrors" id="_ref_38"><a href="https://tc39.github.io/ecma262/#sec-host-report-errors">HostReportErrors</a></emu-xref>(<var>s</var>).</li><li>Return <emu-xref aoid="NormalCompletion" id="_ref_39"><a href="https://tc39.github.io/ecma262/#sec-normalcompletion">NormalCompletion</a></emu-xref>(<emu-val>undefined</emu-val>).</li></ol></li><li>Return ? <emu-xref aoid="ScriptEvaluation" id="_ref_40"><a href="https://tc39.github.io/ecma262/#sec-runtime-semantics-scriptevaluation">ScriptEvaluation</a></emu-xref>(<var>s</var>).
</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-the-realm-constructor">
<h1><span class="secnum">5.2</span>The Realm Constructor</h1>
<p>
The Ream constructor is the %<emu-xref aoid="Realm" id="_ref_41"><a href="#sec-realm">Realm</a></emu-xref>% intrinsic object and the initial value of the <emu-val>Realm</emu-val> property of the <emu-xref href="#global-object"><a href="https://tc39.github.io/ecma262/#global-object">global object</a></emu-xref>. When called as a constructor it creates and initializes a new <emu-xref aoid="Realm" id="_ref_42"><a href="#sec-realm">Realm</a></emu-xref> object. <emu-xref aoid="Realm" id="_ref_43"><a href="#sec-realm">Realm</a></emu-xref> is not intended to be called as a function and will throw an exception when called in that manner.
</p>
<p>
The <emu-xref aoid="Realm" id="_ref_44"><a href="#sec-realm">Realm</a></emu-xref> constructor is designed to be subclassable. It may be used as the value in an extends clause of a class definition. Subclass constructors that intend to inherit the specified <emu-xref aoid="Realm" id="_ref_45"><a href="#sec-realm">Realm</a></emu-xref> behaviour must include a super call to the <emu-xref aoid="Realm" id="_ref_46"><a href="#sec-realm">Realm</a></emu-xref> constructor to create and initialize the subclass instance with the internal state necessary to support the Realm.prototype built-in methods.
</p>
<emu-clause id="sec-realm" aoid="Realm">
<h1><span class="secnum">5.2.1</span>Realm ([ <var>options</var> ])</h1>
When Realm is called with argument <var>option</var> performs the following steps:
<emu-alg><ol><li>If NewTarget is <emu-val>undefined</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>O</var> be ? <emu-xref aoid="OrdinaryCreateFromConstructor" id="_ref_47"><a href="https://tc39.github.io/ecma262/#sec-ordinarycreatefromconstructor">OrdinaryCreateFromConstructor</a></emu-xref>(NewTarget, "%RealmPrototype%", « [[Realm]] »).</li><li>If <var>options</var> is not <emu-val>undefined</emu-val>, then<ol><li>Let <var>parentRealm</var> be <emu-xref href="#current-realm"><a href="https://tc39.github.io/ecma262/#current-realm">the current Realm Record</a></emu-xref>.</li><li>Let <var>opts</var> be ? <emu-xref aoid="ToObject" id="_ref_48"><a href="https://tc39.github.io/ecma262/#sec-toobject">ToObject</a></emu-xref>(<var>options</var>).</li><li>Let <var>transformTrap</var> be ? <emu-xref aoid="Get" id="_ref_49"><a href="https://tc39.github.io/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>opts</var>, "transform").</li><li>If <var>transformTrap</var> is equal <code>"inherit"</code>, then<ol><li>Set <var>transformTrap</var> to <var>parentRealm</var>.[[TransformTrap]].</li></ol></li><li>Else if <var>transformTrap</var> is not <emu-val>undefined</emu-val> and <emu-xref aoid="IsCallable" id="_ref_50"><a href="https://tc39.github.io/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>transformTrap</var>) is <emu-val>false</emu-val>, throw a TypeError exception.</li><li>Let <var>isDirectEvalTrap</var> be ? <emu-xref aoid="Get" id="_ref_51"><a href="https://tc39.github.io/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>opts</var>, "isDirectEval").</li><li>If <var>isDirectEvalTrap</var> is equal <code>"inherit"</code>, then<ol><li>Set <var>isDirectEvalTrap</var> to <var>parentRealm</var>.[[IsDirectEvalTrap]].</li></ol></li><li>Else if <var>isDirectEvalTrap</var> is not <emu-val>undefined</emu-val> and <emu-xref aoid="IsCallable" id="_ref_52"><a href="https://tc39.github.io/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>isDirectEvalTrap</var>) is <emu-val>false</emu-val>, throw a TypeError exception.</li><li>Let <var>intrinsics</var> be ? <emu-xref aoid="Get" id="_ref_53"><a href="https://tc39.github.io/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>opts</var>, "intrinsics").</li><li>If <var>intrinsics</var> is equal <code>"inherit"</code>, then<ol><li>Set <var>intrinsics</var> to <var>parentRealm</var>.[[Intrinsics]].</li></ol></li><li>Else if <var>intrinsics</var> is not <emu-val>undefined</emu-val>, throw a TypeError exception.</li><li>Let <var>thisValue</var> be ? <emu-xref aoid="Get" id="_ref_54"><a href="https://tc39.github.io/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>opts</var>, "thisValue").</li><li>If <var>thisValue</var> is not <emu-val>undefined</emu-val> and <emu-xref aoid="Type" id="_ref_55"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>thisValue</var>) is not Object, throw a TypeError exception.</li></ol></li><li>Let <var>realmRec</var> be <emu-xref aoid="CreateRealmRec" id="_ref_56"><a href="#sec-create-realm-rec">CreateRealmRec</a></emu-xref>(<var>intrinsics</var>).</li><li>Set <var>O</var>.[[Realm]] to <var>realmRec</var>.</li><li>Perform ? <emu-xref aoid="SetRealmGlobalObject" id="_ref_57"><a href="https://tc39.github.io/ecma262/#sec-setrealmglobalobject">SetRealmGlobalObject</a></emu-xref>(<var>realmRec</var>, <emu-val>undefined</emu-val>, <var>thisValue</var>).</li><li>Set <var>realmRec</var>.[[PreventImportExpression]] to <emu-val>true</emu-val>.</li><li>If <var>transformTrap</var> is not <emu-val>undefined</emu-val>, then<ol><li>Set <var>realmRec</var>.[[TransformTrap]] to <var>transformTrap</var>.</li></ol></li><li>If <var>isDirectEvalTrap</var> is not <emu-val>undefined</emu-val>, then<ol><li>Set <var>realmRec</var>.[[IsDirectEvalTrap]] to <var>isDirectEvalTrap</var>.</li></ol></li><li>Let <var>init</var> be ? <emu-xref aoid="GetMethod" id="_ref_58"><a href="https://tc39.github.io/ecma262/#sec-getmethod">GetMethod</a></emu-xref>(<var>O</var>, <emu-val>"init"</emu-val>).</li><li>If <emu-xref aoid="IsCallable" id="_ref_59"><a href="https://tc39.github.io/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>init</var>) is not <emu-val>true</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Perform ? <emu-xref aoid="Call" id="_ref_60"><a href="https://tc39.github.io/ecma262/#sec-call">Call</a></emu-xref>(<var>init</var>, <var>O</var>).</li><li>Return <var>O</var>.
</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-realm-constructor">
<h1><span class="secnum">5.3</span>Properties of the Realm Constructor</h1>
The value of the [[Prototype]] internal slot of the <emu-val>Realm</emu-val> constructor is the intrinsic object <emu-xref href="#sec-properties-of-the-function-prototype-object"><a href="https://tc39.github.io/ecma262/#sec-properties-of-the-function-prototype-object">%FunctionPrototype%</a></emu-xref>.
</emu-clause>
<emu-clause id="sec-properties-of-the-realm-prototype-object">
<h1><span class="secnum">5.4</span>Properties of the Realm Prototype Object</h1>
<emu-clause id="sec-realm.prototype.init">
<h1><span class="secnum">5.4.1</span>Realm.prototype.init ()</h1>
<emu-alg><ol><li>Let <var>O</var> be <emu-val>this</emu-val> value.</li><li>If <emu-xref aoid="Type" id="_ref_61"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>O</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>O</var> does not have an [[Realm]] internal slot, throw a <emu-val>TypeError</emu-val> exception.</li><li>Perform ? <emu-xref aoid="SetDefaultGlobalBindings" id="_ref_62"><a href="https://tc39.github.io/ecma262/#sec-setdefaultglobalbindings">SetDefaultGlobalBindings</a></emu-xref>(<var>O</var>.[[Realm]]).
</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
Extensible web: This is the dynamic way to define globals in a new realm.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-realm.prototype.eval">
<h1><span class="secnum">5.4.2</span>Realm.prototype.evaluate ( <var>sourceText</var> )</h1>
Synchronously execute a top-level script. The <var>x</var> is interpreted as a Script and evaluated with this bound to the realm's <emu-xref href="#global-object"><a href="https://tc39.github.io/ecma262/#global-object">global object</a></emu-xref>.
<emu-alg><ol><li>Let <var>O</var> be <emu-val>this</emu-val> value.</li><li>If <emu-xref aoid="Type" id="_ref_63"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>O</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>O</var> does not have an [[Realm]] internal slot, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <emu-xref aoid="Type" id="_ref_64"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>sourceText</var>) is not String, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>realm</var> be <var>O</var>.[[Realm]].</li><li>Return ? <emu-xref aoid="PerformRealmEvaluation" id="_ref_65"><a href="#sec-performRealmEvaluation">PerformRealmEvaluation</a></emu-xref>(<var>sourceText</var>, <var>realm</var>).
</li></ol></emu-alg>
<emu-note><span class="note">Note 1</span><div class="note-contents">
Extensible web: This is the dynamic equivalent of a <script> in HTML.
</div></emu-note>
<emu-note><span class="note">Note 2</span><div class="note-contents">
Invocation of this method does not transform <var>x</var> via the [[TransformTrap]].
</div></emu-note>
</emu-clause>
<emu-clause id="sec-realm.prototype.global">
<h1><span class="secnum">5.4.3</span>get Realm.prototype.global</h1>
Realm.prototype.global is an accessor property whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps:
<emu-alg><ol><li>Let <var>O</var> be <emu-val>this</emu-val> value.</li><li>If <emu-xref aoid="Type" id="_ref_66"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>O</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>O</var> does not have an [[Realm]] internal slot, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return <var>O</var>.[[Realm]].[[GlobalObject]].
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-realm.prototype.thisValue">
<h1><span class="secnum">5.4.4</span>get Realm.prototype.thisValue</h1>
Realm.prototype.thisValue is an accessor property whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps:
<emu-alg><ol><li>Let <var>O</var> be <emu-val>this</emu-val> value.</li><li>If <emu-xref aoid="Type" id="_ref_67"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>O</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>O</var> does not have an [[Realm]] internal slot, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>envRec</var> be <var>O</var>.[[Realm]].[[GlobalEnv]].</li><li>Return <var>envRec</var>.[[GlobalThisValue]].
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-realm.prototype.stdlib">
<h1><span class="secnum">5.4.5</span>get Realm.prototype.stdlib</h1>
Realm.prototype.stdlib is an accessor property whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps:
<emu-alg><ol><li>Let <var>O</var> be <emu-val>this</emu-val> value.</li><li>If <emu-xref aoid="Type" id="_ref_68"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>O</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>O</var> does not have an [[Realm]] internal slot, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>realmRec</var> be <var>O</var>.[[Realm]].</li><li>Let global be realmRec.[[GlobalObject]].</li><li>Let <var>stdlib</var> be <emu-xref aoid="ObjectCreate" id="_ref_69"><a href="https://tc39.github.io/ecma262/#sec-objectcreate">ObjectCreate</a></emu-xref>(<emu-xref href="#sec-properties-of-the-object-prototype-object"><a href="https://tc39.github.io/ecma262/#sec-properties-of-the-object-prototype-object">%ObjectPrototype%</a></emu-xref>).</li><li>For each property of the Global Object specified in clause <emu-xref href="#sec-global-object"><a href="https://tc39.github.io/ecma262/#sec-global-object">18</a></emu-xref> that correspond to an intrinsic object, do:<ol><li>Let <var>name</var> be the String value of the property name.</li><li>Let <var>value</var> be the corresponding value of the intrinsic object from record <var>realmRec</var>.[[Intrinsics]].</li><li>Let <var>descObj</var> be <emu-xref aoid="ObjectCreate" id="_ref_70"><a href="https://tc39.github.io/ecma262/#sec-objectcreate">ObjectCreate</a></emu-xref>(<emu-xref href="#sec-properties-of-the-object-prototype-object"><a href="https://tc39.github.io/ecma262/#sec-properties-of-the-object-prototype-object">%ObjectPrototype%</a></emu-xref>).</li><li>Perform ? <emu-xref aoid="DefinePropertyOrThrow" id="_ref_71"><a href="https://tc39.github.io/ecma262/#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref>(<var>descObj</var>, <emu-val>"value"</emu-val>, PropertyDescriptor{[[Value]]: <var>value</var>, [[Writable]]: <emu-val>true</emu-val>, [[Enumerable]]: <emu-val>true</emu-val>, [[Configurable]]: <emu-val>true</emu-val>}).</li><li>Perform ? <emu-xref aoid="DefinePropertyOrThrow" id="_ref_72"><a href="https://tc39.github.io/ecma262/#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref>(<var>stdlib</var>, <var>name</var>, PropertyDescriptor{[[Value]]: <var>descObj</var>, [[Writable]]: <emu-val>true</emu-val>, [[Enumerable]]: <emu-val>true</emu-val>, [[Configurable]]: <emu-val>true</emu-val>}).</li></ol></li><li>Return <var>stdlib</var>.
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-realm.prototype.intrinsics">
<h1><span class="secnum">5.4.6</span>get Realm.prototype.intrinsics</h1>
Realm.prototype.intrinsics is an accessor property whose set accessor function is <emu-val>undefined</emu-val>. Its get accessor function performs the following steps:
<emu-alg><ol><li>Let <var>O</var> be <emu-val>this</emu-val> value.</li><li>If <emu-xref aoid="Type" id="_ref_73"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>O</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>O</var> does not have an [[Realm]] internal slot, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>realmRec</var> be <var>O</var>.[[Realm]].</li><li>Let <var>intrinsics</var> be <emu-xref aoid="ObjectCreate" id="_ref_74"><a href="https://tc39.github.io/ecma262/#sec-objectcreate">ObjectCreate</a></emu-xref>(<emu-xref href="#sec-properties-of-the-object-prototype-object"><a href="https://tc39.github.io/ecma262/#sec-properties-of-the-object-prototype-object">%ObjectPrototype%</a></emu-xref>).</li><li>For each intrinsic name listed in <emu-xref href="#table-7"><a href="https://tc39.github.io/ecma262/#table-7">Table 7</a></emu-xref>, do:<ol><li>Let <var>intrinsicName</var> be the String value in column one of the table.</li><li>Let <var>name</var> be the String value of <var>intrinsicName</var> without the <emu-val>%</emu-val> symbols.</li><li>Let <var>value</var> be the value of the field name <var>intrisicName</var> from record <var>realmRec</var>.[[Intrinsics]].</li><li>Perform ? <emu-xref aoid="DefinePropertyOrThrow" id="_ref_75"><a href="https://tc39.github.io/ecma262/#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref>(<var>intrinsics</var>, <var>name</var>, PropertyDescriptor{[[Value]]: <var>value</var>, [[Writable]]: <emu-val>true</emu-val>, [[Enumerable]]: <emu-val>true</emu-val>, [[Configurable]]: <emu-val>true</emu-val>}).</li></ol></li><li>Return <var>intrinsics</var>.
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-realm.prototype-@@tostringtag">
<h1><span class="secnum">5.4.7</span>Realm.prototype [ @@toStringTag ]</h1>
The initial value of the @@toStringTag property is the String value "<emu-xref aoid="Realm" id="_ref_76"><a href="#sec-realm">Realm</a></emu-xref>". This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-realm-instances">
<h1><span class="secnum">5.5</span>Properties of Realm Instances</h1>
<emu-xref aoid="Realm" id="_ref_77"><a href="#sec-realm">Realm</a></emu-xref> instances are ordinary objects that inherit properties from the <emu-xref aoid="Realm" id="_ref_78"><a href="#sec-realm">Realm</a></emu-xref> prototype object (the intrinsic, %RealmPrototype%). <emu-xref aoid="Realm" id="_ref_79"><a href="#sec-realm">Realm</a></emu-xref> instances are initially created with the internal slots described in <emu-xref href="#table-3" id="_ref_2"><a href="#table-3">Table 3</a></emu-xref>.
<emu-table id="table-3" caption="Internal Slots of Realm Instances"><figure><figcaption>Table 3: Internal Slots of <emu-xref aoid="Realm" id="_ref_80"><a href="#sec-realm">Realm</a></emu-xref> Instances</figcaption>
<table>
<tbody>
<tr>
<th>Internal Slot</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>[[Realm]]</td>
<td><emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref></td>
<td>The <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref> for the initial <emu-xref href="#sec-execution-contexts"><a href="https://tc39.github.io/ecma262/#sec-execution-contexts">execution context</a></emu-xref>.</td>
</tr>
</tbody>
</table>
</figure></emu-table>
</emu-clause>
</emu-clause>
</div></body>