LibJS: Implement SetDefaultGlobalBindings as a standalone function

Instead of hardcoding all the property definitions in GlobalObject's
initialize() function, make it the standalone AO it is supposed to be
that can then be used by other global objects that don't inherit from
JS::GlobalObject.
This commit is contained in:
Linus Groh 2022-08-28 17:33:01 +01:00
commit 040e3abb1d
Notes: sideshowbarker 2024-07-17 07:39:22 +09:00
3 changed files with 103 additions and 81 deletions

View file

@ -71,11 +71,11 @@ ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> Realm::initialize_host_define
// 9. Perform SetRealmGlobalObject(realm, global, thisValue).
realm->set_global_object(global, this_value);
// NOTE: Steps 10 & 11 are somewhat ad-hoc, since we store intrinsics on the global object.
// 10. Let globalObj be ? SetDefaultGlobalBindings(realm).
auto& global_object = set_default_global_bindings(*realm);
// 11. Create any host-defined global object properties on globalObj.
realm->global_object().initialize(*realm);
global_object.initialize(*realm);
// 12. Return unused.
return new_context;