Module.h 921 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  3. * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibJS/Forward.h>
  9. #include <LibJS/Heap/GCPtr.h>
  10. #include <LibJS/Heap/Handle.h>
  11. #include <LibWasm/Types.h>
  12. #include <LibWeb/Bindings/ExceptionOrUtils.h>
  13. #include <LibWeb/Bindings/PlatformObject.h>
  14. namespace Web::WebAssembly {
  15. class Module : public Bindings::PlatformObject {
  16. WEB_PLATFORM_OBJECT(Module, Bindings::PlatformObject);
  17. JS_DECLARE_ALLOCATOR(Module);
  18. public:
  19. static WebIDL::ExceptionOr<JS::NonnullGCPtr<Module>> construct_impl(JS::Realm&, JS::Handle<WebIDL::BufferSource>& bytes);
  20. size_t index() const { return m_index; }
  21. Wasm::Module const& module() const;
  22. private:
  23. Module(JS::Realm&, size_t index);
  24. virtual void initialize(JS::Realm&) override;
  25. size_t m_index { 0 };
  26. };
  27. }