Module.h 900 B

123456789101112131415161718192021222324252627282930313233343536
  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. public:
  18. static WebIDL::ExceptionOr<JS::NonnullGCPtr<Module>> construct_impl(JS::Realm&, JS::Handle<JS::Object>& bytes);
  19. size_t index() const { return m_index; }
  20. Wasm::Module const& module() const;
  21. private:
  22. Module(JS::Realm&, size_t index);
  23. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  24. size_t m_index { 0 };
  25. };
  26. }