8.2.3 SetRealmGlobalObject ( realmRec, globalObj, thisValue )
具有参数 realmRec、globalObj 和 thisValue 的抽象操作SetRealmGlobalObject执行以下步骤:
- 如果 globalObj 为undefined,那么
a. 使 intrinsics 变为 realmRec.[[Intrinsics]]。 b. 使 globalObj 变为 ObjectCreate(intrinsics.[[%ObjectPrototype%]])。
2.断言: Type(globalObj) 为 Object 类型。
3.如果 thisValue 为 undefined,则使 thisValue 变为 globalObj。
4.设置 realmRec.[[GlobalObject]] 为 globalObj。
5.使 newGlobalEnv 变为 NewGlobalEnvironment(globalObj, thisValue)。
6.设置 realmRec.[[GlobalEnv]] 为 newGlobalEnv。
7.返回 realmRec。