LibWeb/WebAssembly: Implement Module::imports(module)

This commit is contained in:
Ali Mohammad Pur 2025-04-22 10:57:59 +02:00 committed by Andrew Kaster
commit f984c1cc51
Notes: github-actions[bot] 2025-04-22 14:45:11 +00:00
3 changed files with 52 additions and 6 deletions

View file

@ -10,19 +10,32 @@
#include <LibGC/Ptr.h>
#include <LibGC/Root.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Array.h>
#include <LibWasm/Types.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/WebAssembly/WebAssembly.h>
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;
};
class Module : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(Module, Bindings::PlatformObject);
GC_DECLARE_ALLOCATOR(Module);
public:
static WebIDL::ExceptionOr<GC::Ref<Module>> construct_impl(JS::Realm&, GC::Root<WebIDL::BufferSource>& bytes);
static WebIDL::ExceptionOr<Vector<ModuleImportDescriptor>> imports(JS::VM&, GC::Ref<Module>);
NonnullRefPtr<Detail::CompiledWebAssemblyModule> compiled_module() const { return m_compiled_module; }