Skip to content

Commit

Permalink
Editorial: Inline CreateRealm + SetRealmGlobalObject into InitializeH…
Browse files Browse the repository at this point in the history
…ostDefinedRealm (#3139(

... and put the result in the "Realms" section.
  • Loading branch information
jmdyck authored and ljharb committed May 23, 2024
1 parent a92f3e9 commit 977a6c4
Showing 1 changed file with 26 additions and 53 deletions.
79 changes: 26 additions & 53 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -11596,18 +11596,35 @@ <h1>Realms</h1>
</table>
</emu-table>

<emu-clause id="sec-createrealm" type="abstract operation">
<h1>CreateRealm ( ): a Realm Record</h1>
<emu-clause id="sec-initializehostdefinedrealm" type="abstract operation" oldids="sec-createrealm,sec-setrealmglobalobject">
<h1>InitializeHostDefinedRealm ( ): either a normal completion containing ~unused~ or a throw completion</h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _realmRec_ be a new Realm Record.
1. Perform CreateIntrinsics(_realmRec_).
1. Set _realmRec_.[[AgentSignifier]] to AgentSignifier().
1. Set _realmRec_.[[GlobalObject]] to *undefined*.
1. Set _realmRec_.[[GlobalEnv]] to *undefined*.
1. Set _realmRec_.[[TemplateMap]] to a new empty List.
1. Return _realmRec_.
1. Let _realm_ be a new Realm Record.
1. Perform CreateIntrinsics(_realm_).
1. Set _realm_.[[AgentSignifier]] to AgentSignifier().
1. Set _realm_.[[GlobalObject]] to *undefined*.
1. Set _realm_.[[GlobalEnv]] to *undefined*.
1. Set _realm_.[[TemplateMap]] to a new empty List.
1. Let _newContext_ be a new execution context.
1. Set the Function of _newContext_ to *null*.
1. Set the Realm of _newContext_ to _realm_.
1. Set the ScriptOrModule of _newContext_ to *null*.
1. Push _newContext_ onto the execution context stack; _newContext_ is now the running execution context.
1. If the host requires use of an exotic object to serve as _realm_'s global object, then
1. Let _global_ be such an object created in a host-defined manner.
1. Else,
1. Let _global_ be OrdinaryObjectCreate(_realm_.[[Intrinsics]].[[%Object.prototype%]]).
1. If the host requires that the `this` binding in _realm_'s global scope return an object other than the global object, then
1. Let _thisValue_ be such an object created in a host-defined manner.
1. Else,
1. Let _thisValue_ be _global_.
1. Set _realm_.[[GlobalObject]] to _global_.
1. Set _realm_.[[GlobalEnv]] to NewGlobalEnvironment(_global_, _thisValue_).
1. Let _globalObj_ be ? SetDefaultGlobalBindings(_realm_).
1. Create any host-defined global object properties on _globalObj_.
1. Return ~unused~.
</emu-alg>
</emu-clause>

Expand All @@ -11627,29 +11644,6 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-setrealmglobalobject" type="abstract operation">
<h1>
SetRealmGlobalObject (
_realmRec_: a Realm Record,
_globalObj_: an Object or *undefined*,
_thisValue_: an Object or *undefined*,
): ~unused~
</h1>
<dl class="header">
</dl>
<emu-alg>
1. If _globalObj_ is *undefined*, then
1. Let _intrinsics_ be _realmRec_.[[Intrinsics]].
1. Set _globalObj_ to OrdinaryObjectCreate(_intrinsics_.[[%Object.prototype%]]).
1. Assert: _globalObj_ is an Object.
1. If _thisValue_ is *undefined*, set _thisValue_ to _globalObj_.
1. Set _realmRec_.[[GlobalObject]] to _globalObj_.
1. Let _newGlobalEnv_ be NewGlobalEnvironment(_globalObj_, _thisValue_).
1. Set _realmRec_.[[GlobalEnv]] to _newGlobalEnv_.
1. Return ~unused~.
</emu-alg>
</emu-clause>

<emu-clause id="sec-setdefaultglobalbindings" type="abstract operation">
<h1>
SetDefaultGlobalBindings (
Expand Down Expand Up @@ -12065,27 +12059,6 @@ <h1>
</emu-clause>
</emu-clause>

<emu-clause id="sec-initializehostdefinedrealm" type="abstract operation">
<h1>InitializeHostDefinedRealm ( ): either a normal completion containing ~unused~ or a throw completion</h1>
<dl class="header">
</dl>

<emu-alg>
1. Let _realm_ be CreateRealm().
1. Let _newContext_ be a new execution context.
1. Set the Function of _newContext_ to *null*.
1. Set the Realm of _newContext_ to _realm_.
1. Set the ScriptOrModule of _newContext_ to *null*.
1. Push _newContext_ onto the execution context stack; _newContext_ is now the running execution context.
1. If the host requires use of an exotic object to serve as _realm_'s global object, let _global_ be such an object created in a host-defined manner. Otherwise, let _global_ be *undefined*, indicating that an ordinary object should be created as the global object.
1. If the host requires that the `this` binding in _realm_'s global scope return an object other than the global object, let _thisValue_ be such an object created in a host-defined manner. Otherwise, let _thisValue_ be *undefined*, indicating that _realm_'s global `this` binding should be the global object.
1. Perform SetRealmGlobalObject(_realm_, _global_, _thisValue_).
1. Let _globalObj_ be ? SetDefaultGlobalBindings(_realm_).
1. Create any host-defined global object properties on _globalObj_.
1. Return ~unused~.
</emu-alg>
</emu-clause>

<emu-clause id="sec-agents">
<h1>Agents</h1>

Expand Down

0 comments on commit 977a6c4

Please sign in to comment.