mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
LibJS+LibWeb: Replace GlobalObject with Realm in object constructors
No functional changes - we can still very easily get to the global object via `Realm::global_object()`. This is in preparation of moving the intrinsics to the realm and no longer having to pass a global object when allocating any object. In a few (now, and many more in subsequent commits) places we get a realm using `GlobalObject::associated_realm()`, this is intended to be temporary. For example, create() functions will later receive the same treatment and are passed a realm instead of a global object.
This commit is contained in:
parent
4c300cc5e8
commit
ecd163bdf1
315 changed files with 592 additions and 554 deletions
|
@ -15,6 +15,8 @@ namespace JS {
|
|||
|
||||
ThrowCompletionOr<GeneratorObject*> GeneratorObject::create(GlobalObject& global_object, Value initial_value, ECMAScriptFunctionObject* generating_function, ExecutionContext execution_context, Bytecode::RegisterWindow frame)
|
||||
{
|
||||
auto& realm = *global_object.associated_realm();
|
||||
|
||||
// This is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
|
||||
Value generating_function_prototype;
|
||||
if (generating_function->kind() == FunctionKind::Async) {
|
||||
|
@ -26,14 +28,14 @@ ThrowCompletionOr<GeneratorObject*> GeneratorObject::create(GlobalObject& global
|
|||
generating_function_prototype = TRY(generating_function->get(global_object.vm().names.prototype));
|
||||
}
|
||||
auto* generating_function_prototype_object = TRY(generating_function_prototype.to_object(global_object));
|
||||
auto object = global_object.heap().allocate<GeneratorObject>(global_object, global_object, *generating_function_prototype_object, move(execution_context));
|
||||
auto object = global_object.heap().allocate<GeneratorObject>(global_object, realm, *generating_function_prototype_object, move(execution_context));
|
||||
object->m_generating_function = generating_function;
|
||||
object->m_frame = move(frame);
|
||||
object->m_previous_value = initial_value;
|
||||
return object;
|
||||
}
|
||||
|
||||
GeneratorObject::GeneratorObject(GlobalObject&, Object& prototype, ExecutionContext context)
|
||||
GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext context)
|
||||
: Object(prototype)
|
||||
, m_execution_context(move(context))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue