Skip to content

Commit a746bbf

Browse files
devsnekdandclark
andauthored
refactor spec (#109)
* refactor spec * Update spec.html Co-authored-by: Dan Clark <[email protected]> Co-authored-by: Dan Clark <[email protected]>
1 parent ae28137 commit a746bbf

File tree

1 file changed

+42
-35
lines changed

1 file changed

+42
-35
lines changed

spec.html

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,47 +65,54 @@ <h1>Import Calls</h1>
6565
<emu-clause id="sec-import-call-runtime-semantics-evaluation">
6666
<h1>Runtime Semantics: Evaluation</h1>
6767

68+
<emu-clause id="sec-evaluate-import-call">
69+
<h1>EvaluateImportCall ( _specifierExpression_ [ , _optionsExpression_ ] )</h1>
70+
<emu-alg>
71+
1. Let _referencingScriptOrModule_ be ! GetActiveScriptOrModule().
72+
1. Let _specifierRef_ be the result of evaluating _specifierExpression_.
73+
1. Let _specifier_ be ? GetValue(_specifierRef_).
74+
1. If _optionsExpression_ is present, then
75+
1. Let _optionsRef_ be the result of evaluating _optionsExpression_.
76+
1. Let _options_ be ? GetValue(_optionsRef_).
77+
1. Else,
78+
1. Let _options_ be *undefined*.
79+
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
80+
1. Let _specifierString_ be ToString(_specifier_).
81+
1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_).
82+
1. Let _assertions_ be a new empty List.
83+
1. If _options_ is not *undefined*, then
84+
1. Let _assertionsObj_ be Get(_options_, *"assert"*).
85+
1. IfAbruptRejectPromise(_assertionsObj_, _promiseCapability_).
86+
1. If _assertionsObj_ is not *undefined*,
87+
1. If Type(_assertionsObj_) is not Object,
88+
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).
89+
1. Return _promiseCapability_.[[Promise]].
90+
1. Let _keys_ be EnumerableOwnPropertyNames(_assertionsObj_, ~key~).
91+
1. IfAbruptRejectPromise(_keys_, _promiseCapability_).
92+
1. Let _supportedAssertions_ be ! HostGetSupportedImportAssertions().
93+
1. For each String _key_ of _keys_,
94+
1. Let _value_ be Get(_assertionsObj_, _key_).
95+
1. IfAbruptRejectPromise(_value_, _promiseCapability_).
96+
1. If Type(_value_) is not String, then
97+
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).
98+
1. Return _promiseCapability_.[[Promise]].
99+
1. If _supportedAssertions_ contains _key_, then
100+
1. Append { [[Key]]: _key_, [[Value]]: _value_ } to _assertions_.
101+
1. Sort _assertions_ by the code point order of the [[Key]] of each element. NOTE: This sorting is observable only in that hosts are prohibited from distinguishing among assertions by the order they occur in.
102+
1. Let _moduleRequest_ be a new ModuleRequest Record { [[Specifier]]: _specifierString_, [[Assertions]]: _assertions_ }.
103+
1. Perform ! HostImportModuleDynamically(_referencingScriptOrModule_, _moduleRequest_, _promiseCapability_).
104+
1. Return _promiseCapability_.[[Promise]].
105+
</emu-alg>
106+
</emu-clause>
107+
68108
<emu-grammar>ImportCall : `import` `(` AssignmentExpression `,`? `)`</emu-grammar>
69109
<emu-alg>
70-
1. Let _referencingScriptOrModule_ be ! GetActiveScriptOrModule().
71-
1. Let _argRef_ be the result of evaluating |AssignmentExpression|.
72-
1. Let _specifier_ be ? GetValue(_argRef_).
73-
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
74-
1. Let _specifierString_ be ToString(_specifier_).
75-
1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_).
76-
1. <ins>Let _moduleRequest_ be a new ModuleRequest Record { [[Specifier]]: _specifierString_, [[Assertions]]: an empty List }.</ins>
77-
1. Perform ! HostImportModuleDynamically(_referencingScriptOrModule_, <del>_specifierString_,</del> <ins>_moduleRequest_,</ins> _promiseCapability_).
78-
1. Return _promiseCapability_.[[Promise]].
110+
1. Return ? EvaluateImportCall(|AssignmentExpression|).
79111
</emu-alg>
80112

81113
<ins><emu-grammar>ImportCall : `import` `(` AssignmentExpression `,` AssignmentExpression `,`? `)`</emu-grammar></ins>
82114
<emu-alg>
83-
1. Let _referencingScriptOrModule_ be ! GetActiveScriptOrModule().
84-
1. Let _argRef_ be the result of evaluating <ins>the first</ins> |AssignmentExpression|.
85-
1. Let _specifier_ be ? GetValue(_argRef_).
86-
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
87-
1. Let _specifierString_ be ToString(_specifier_).
88-
1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_).
89-
1. <ins>Let _argRef_ be the result of evaluating the second |AssignmentExpression|.</ins>
90-
1. <ins>Let _arg_ be ? GetValue(_argRef_).</ins>
91-
1. <ins>If _arg_ is *undefined*, let _assertions_ be an empty List.</ins>
92-
1. <ins>Otherwise,</ins>
93-
1. <ins>Let _supportedAssertions_ ! HostGetSupportedImportAssertions().</ins>
94-
1. <ins>Let _assertionsObj_ be ? Get(_arg_, *"assert"*).</ins>
95-
1. <ins>Let _assertions_ be a new empty List.</ins>
96-
1. <ins>Let _keys_ be EnumerableOwnPropertyNames(_assertionsObj_, ~key~).</ins>
97-
1. <ins>IfAbruptRejectPromise(_keys_, _promiseCapability_).</ins>
98-
1. <ins>For each String _key_ of _keys_,</ins>
99-
1. <ins>Let _value_ be Get(_assertionsObj_, _key_).</ins>
100-
1. <ins>IfAbruptRejectPromise(_value_, _promiseCapability_).</ins>
101-
1. <ins>If Type(_value_) is not String, then</ins>
102-
1. <ins>Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).</ins>
103-
1. <ins>Return _promiseCapability_.[[Promise]].</ins>
104-
1. <ins>If _supportedAssertions_ contains _key_, append { [[Key]]: _key_, [[Value]]: _value_ } to _assertions_.</ins>
105-
1. <ins>Sort _assertions_ by the code point order of the [[Key]] of each element. NOTE: This sorting is observable only in that hosts are prohibited from distinguishing among assertions by the order they occur in.</ens>
106-
1. <ins>Let _moduleRequest_ be a new ModuleRequest Record { [[Specifier]]: _specifierString_, [[Assertions]]: _assertions_ }.</ins>
107-
1. Perform ! HostImportModuleDynamically(_referencingScriptOrModule_, <del>_specifierString_,</del> <ins>_moduleRequest_,</ins> _promiseCapability_).
108-
1. Return _promiseCapability_.[[Promise]].
115+
1. Return ? EvaluateImportCall(the first |AssignmentExpression|, the second |AssignmentExpression|).
109116
</emu-alg>
110117
</emu-clause>
111118
</emu-clause>

0 commit comments

Comments
 (0)