Skip to content

Commit 3254e3b

Browse files
committed
update spec
1 parent 74b2e89 commit 3254e3b

File tree

1 file changed

+49
-52
lines changed

1 file changed

+49
-52
lines changed

spec.html

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -131,112 +131,109 @@ <h1>CreateSyntheticModule ( _exportNames_, _evaluationSteps_, _realm_, _hostDefi
131131
<emu-note type="editor">It seems we could set up the environment either here or in Instantiate(). I've chosen to do so in Instantiate() for symmetry with Source Text Module Records, but I don't think there's any actual requirement in that regard.</emu-note>
132132
</emu-clause>
133133

134-
<emu-clause id="sec-setsyntheticmoduleexport" aoid="SetSyntheticModuleExport">
135-
<h1>SetSyntheticModuleExport ( _module_, _exportName_, _exportValue_ )</h1>
136-
137-
<p>The abstract operation SetSyntheticModuleExport can be used to set or change the exported value for a pre-established export of a Synthetic Module Record. It performs the following steps:</p>
138-
139-
<emu-alg>
140-
1. Let _envRec_ be _module_.[[Environment]]'s EnvironmentRecord.
141-
1. Perform _envRec_.SetMutableBinding(_exportName_, _exportValue_, *true*).
142-
</emu-alg>
143-
</emu-clause>
144-
145-
<emu-clause id="sec-smr-concrete-methods">
134+
<emu-clause id="sec-synthetic-module-record-concrete-methods">
146135
<h1>Concrete Methods</h1>
147136

148137
<p>The following are the concrete methods for Synthetic Module Record that implement the corresponding Module Record abstract methods.</p>
149138

150139
<emu-note type="editor">I find having this wrapping sub-clause cleaner and suggest we do the same for Source Text Module Records in the main spec.</emu-note>
151140

152-
<emu-clause id="sec-smr-getexportednames">
153-
<h1>GetExportedNames( _exportStarSet_ )</h1>
141+
<emu-clause id="sec-synthetic-module-record-getexportednames">
142+
<h1>GetExportedNames( [ _exportStarSet_ ] )</h1>
154143

155-
<p>The GetExportedNames concrete method of a Synthetic Module Record implements the corresponding Module Record abstract method.</p>
156-
<p>It performs the following steps:</p>
144+
<p>The GetExportedNames concrete method of a Synthetic Module Record _module_ takes optional argument _exportStarSet_.</p>
145+
<p>It performs the following steps when called:</p>
157146

158147
<emu-alg>
159-
1. Let _module_ be this Synthetic Module Record.
160148
1. Return _module_.[[ExportNames]].
161149
</emu-alg>
162150
</emu-clause>
163151

164-
<emu-clause id="sec-smr-resolveexport">
165-
<h1>ResolveExport( _exportName_, _resolveSet_ )</h1>
152+
<emu-clause id="sec-synthetic-module-record-resolveexport">
153+
<h1>ResolveExport( _exportName_ [ , _resolveSet_ ] )</h1>
166154

167-
<p>The ResolveExport concrete method of a Synthetic Module Record implements the corresponding Module Record abstract method.</p>
168-
<p>It performs the following steps:</p>
155+
<p>The ResolveExport concrete method of a Synthetic Module Record _module_ takes argument _exportName_ (a String) and optional argument _resolveSet_.</p>
156+
<p>It performs the following steps when called:</p>
169157

170158
<emu-alg>
171-
1. Let _module_ be this Synthetic Module Record.
172159
1. If _module_.[[ExportNames]] does not contain _exportName_, return null.
173160
1. Return ResolvedBinding Record { [[Module]]: _module_, [[BindingName]]: _exportName_ }.
174161
</emu-alg>
175162
</emu-clause>
176163

177-
<emu-clause id="sec-smr-instantiate">
178-
<h1>Instantiate ( )</h1>
164+
<emu-clause id="sec-synthetic-module-record-link">
165+
<h1>Link ( )</h1>
179166

180-
<p>The Instantiate concrete method of a Synthetic Module Record implements the corresponding Module Record abstract method.</p>
181-
<p>It performs the following steps:</p>
167+
<p>The Link concrete method of a Synthetic Module Record _module_ takes no arguments.</p>
168+
<p>It performs the following steps when called:</p>
182169

183170
<emu-alg>
184-
1. Let _module_ be this Synthetic Module Record.
185171
1. Let _realm_ be _module_.[[Realm]].
186172
1. Assert: _realm_ is not *undefined*.
187173
1. Let _env_ be NewModuleEnvironment(_realm_.[[GlobalEnv]]).
188174
1. Set _module_.[[Environment]] to _env_.
189-
1. Let _envRec_ be _env_'s EnvironmentRecord.
190175
1. For each _exportName_ in _module_.[[ExportNames]],
191-
1. Perform ! _envRec_.CreateMutableBinding(_exportName_, *false*).
192-
1. Perform ! _envRec_.InitializeBinding(_exportName_, *undefined*).
176+
1. Perform ! _env_.CreateMutableBinding(_exportName_, *false*).
177+
1. Perform ! _env_.InitializeBinding(_exportName_, *undefined*).
193178
1. Return *undefined*.
194179
</emu-alg>
195180
</emu-clause>
196181

197-
<emu-clause id="sec-smr-Evaluate">
182+
<emu-clause id="sec-synthetic-module-record-evaluate">
198183
<h1>Evaluate ( )</h1>
199184

200-
<p>The Evaluate concrete method of a Synthetic Module Record implements the corresponding Module Record abstract method.</p>
201-
<p>It performs the following steps:</p>
185+
<p>The Evalate concrete method of a Synthetic Module Record _module_ takes no arguments.</p>
186+
<p>It performs the following steps when called:</p>
202187

203188
<emu-alg>
204-
1. Let _module_ be this Synthetic Module Record.
205-
1. Let _moduleCxt_ be a new ECMAScript code execution context.
206-
1. Set the Function of _moduleCxt_ to *null*.
207-
1. Assert: _module_.[[Realm]] is not *undefined*.
208-
1. Set the Realm of _moduleCxt_ to _module_.[[Realm]].
209-
1. Set the ScriptOrModule of _moduleCxt_ to _module_.
210-
1. Set the VariableEnvironment of _moduleCxt_ to _module_.[[Environment]].
211-
1. Set the LexicalEnvironment of _moduleCxt_ to _module_.[[Environment]].
212189
1. Suspend the currently running execution context.
213-
1. Push _moduleCxt_ on to the execution context stack; _moduleCxt_ is now the running execution context.
190+
1. Let _moduleContext_ be a new ECMAScript code execution context.
191+
1. Set the Function of _moduleContext_ to *null*.
192+
1. Set the Realm of _moduleContext_ to _module_.[[Realm]].
193+
1. Set the ScriptOrModule of _moduleContext_ to _module_.
194+
1. Set the VariableEnvironment of _moduleContext_ to _module_.[[Environment]].
195+
1. Set the LexicalEnvironment of _moduleContext_ to _module_.[[Environment]].
196+
1. Push _moduleContext_ on to the execution context stack; _moduleContext_ is now the running execution context.
214197
1. Let _result_ be the result of performing ? _module_.[[EvaluationSteps]](_module_).
215-
1. Suspend _moduleCxt_ and remove it from the execution context stack.
198+
1. Suspend _moduleContext_ and remove it from the execution context stack.
216199
1. Resume the context that is now on the top of the execution context stack as the running execution context.
217200
1. Return Completion(_result_).
218201
</emu-alg>
219202
</emu-clause>
203+
204+
<emu-clause id="sec-synthetic-module-record-set-synthetic-export">
205+
<h1>SetSyntheticExport ( _name_, _value_ )</h1>
206+
207+
<p>The SetSyntheticExport concrete method of a Synthetic Module Record _module_ takes argument _name_ (a String) and _value_.</p>
208+
<p>It performs the following steps when called:</p>
209+
210+
<emu-alg>
211+
1. Return ? _module_.[[Environment]].SetMutableBinding(_name_, _value_, *true*).
212+
</emu-alg>
213+
</emu-clause>
220214
</emu-clause>
221215
</emu-clause>
222216

223217
<emu-clause id="sec-create-default-export-synthetic-module" aoid="CreateDefaultExportSyntheticModule">
224-
<h1>CreateDefaultExportSyntheticModule ( _defaultExport_ )</h1>
225-
<p>The CreateDefaultExportSyntheticModule abstract operation creates a Synthetic Module Record whose default export is _defaultExport_. It performs the following steps:</p>
218+
<h1>CreateDefaultExportSyntheticModule ( _defaultExport_ , _realm_ , _hostDefined_ )</h1>
219+
<p>The CreateDefaultExportSyntheticModule abstract operation takes arguments _defaultExport_, _realm_ (a Realm), and _hostDefined_.</p>
220+
<p>It performs the following steps when called:</p>
226221
<emu-alg>
227-
1. Return CreateSyntheticModule(&laquo; *"default"* &raquo;, the following steps, the current Realm, _defaultExport_) with the following steps given _module_ as an argument:</p>
228-
1. SetSyntheticModuleExport(_module_, *"default"*, _module_.[[HostDefined]]).</li>
222+
1. Let _closure_ be the a Abstract Closure with parameters (_module_) that captures _defaultExport_ and performs the following steps when called:
223+
1. _module_.SetSyntheticExport(*"default"*, _defaultExport_).</li>
224+
1. Return CreateSyntheticModule(&laquo; *"default"* &raquo;, _closure_, _realm_)</p>
229225
</emu-alg>
230-
<!-- TODO: Could we apply the new spec closure concept here rather than painstakingly passing _defaultExport_ through [[HostDefined]]? -->
231226
</emu-clause>
232227

233228
<emu-clause id="sec-parse-json-module" aoid="ParseJSONModule">
234-
<h1>ParseJSONModule ( _source_ )</h1>
235-
<p>The abstract operation ParseJSONModule takes a single argument _source_ which is a String representing the contents of a module.</p>
229+
<h1>ParseJSONModule ( _sourceText_ , _realm_ , _hostDefined_ )</h1>
230+
<p>The abstract operation ParseJSONModule takes argument _source_ (a String).</p>
231+
<p>It performs the following steps when called:</p>
236232

237233
<emu-alg>
238-
1. Let _json_ be ? Call(%JSON.parse%, *undefined*, « _source_ »). <!-- TODO: Refactor JSONParse into an abstract algorithm -->
239-
1. Return CreateDefaultExportSyntheticModule(_json_).
234+
1. Let _jsonParse_ be _realm_'s intrinsic object named *"%JSON.parse%"*.
235+
1. Let _json_ be ? Call(_jsonParse_, *undefined*, « _sourceText_ »). <!-- TODO: Refactor JSONParse into an abstract algorithm -->
236+
1. Return CreateDefaultExportSyntheticModule(_json_, _realm_, _hostDefined_).
240237
</emu-alg>
241238
</emu-clause>
242239
</emu-clause>

0 commit comments

Comments
 (0)