From c3b02ae65a7a4df2d83a8646a4683ccf847db8c5 Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 29 Oct 2023 02:52:59 +0100 Subject: [PATCH] LibJS: Add GraphLoadingState Record This patch adds the GraphLoadingState Record with a struct HostDefined for use in the HostDefined field. --- Userland/Libraries/LibJS/CyclicModule.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/CyclicModule.h b/Userland/Libraries/LibJS/CyclicModule.h index 22c3881758..88ec77047b 100644 --- a/Userland/Libraries/LibJS/CyclicModule.h +++ b/Userland/Libraries/LibJS/CyclicModule.h @@ -22,7 +22,24 @@ enum class ModuleStatus { Evaluated }; -// 16.2.1.5 Cyclic Module Records, https://tc39.es/ecma262/#sec-cyclic-module-records +class CyclicModule; + +// https://tc39.es/ecma262/#graphloadingstate-record +struct GraphLoadingState { + struct HostDefined { + virtual ~HostDefined() = default; + + virtual void visit_edges(Cell::Visitor&) { } + }; + + GCPtr promise_capability; // [[PromiseCapability]] + bool is_loading { false }; // [[IsLoading]] + size_t pending_module_count { 0 }; // [[PendingModulesCount]] + HashTable visited; // [[Visited]] + Optional host_defined; // [[HostDefined]] +}; + +// 16.2.1.5 Cyclic Module Records, https://tc39.es/ecma262/#cyclic-module-record class CyclicModule : public Module { JS_CELL(CyclicModule, Module);