/* * Copyright (c) 2021, Ali Mohammad Pur * Copyright (c) 2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace Web::Bindings { enum class ImportExportKind : u8; } namespace Web::WebAssembly { // FIXME: This should really be generated by the IDL generator. struct ModuleImportDescriptor { String module; String name; Bindings::ImportExportKind kind; }; struct ModuleExportDescriptor { String name; Bindings::ImportExportKind kind; }; class Module : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(Module, Bindings::PlatformObject); GC_DECLARE_ALLOCATOR(Module); public: static WebIDL::ExceptionOr> construct_impl(JS::Realm&, GC::Root& bytes); static WebIDL::ExceptionOr> imports(JS::VM&, GC::Ref); static WebIDL::ExceptionOr> exports(JS::VM&, GC::Ref); static WebIDL::ExceptionOr>> custom_sections(JS::VM&, GC::Ref, String section_name); NonnullRefPtr compiled_module() const { return m_compiled_module; } private: Module(JS::Realm&, NonnullRefPtr); virtual void initialize(JS::Realm&) override; NonnullRefPtr m_compiled_module; }; }