Skip to content

Commit

Permalink
LibJS: Support creation of global object in Realm::set_global_object()
Browse files Browse the repository at this point in the history
  • Loading branch information
linusg authored and awesomekling committed Aug 6, 2022
1 parent c8f1651 commit 885004a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Userland/Libraries/LibJS/Runtime/Realm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ void Realm::set_global_object(GlobalObject* global_object, GlobalObject* this_va
{
// 1. If globalObj is undefined, then
if (global_object == nullptr) {
// NOTE: Step 1 is not supported, the global object must be allocated elsewhere.
VERIFY_NOT_REACHED();
// a. Let intrinsics be realmRec.[[Intrinsics]].
// b. Set globalObj to OrdinaryObjectCreate(intrinsics.[[%Object.prototype%]]).
// NOTE: We allocate a proper GlobalObject directly as this plain object is
// turned into one via SetDefaultGlobalBindings in the spec.
global_object = heap().allocate_without_global_object<GlobalObject>(*this);
}

// 2. Assert: Type(globalObj) is Object.
Expand Down

0 comments on commit 885004a

Please sign in to comment.