Instance.h 1006 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 <AK/Optional.h>
  9. #include <LibJS/Forward.h>
  10. #include <LibJS/Heap/GCPtr.h>
  11. #include <LibJS/Heap/Handle.h>
  12. #include <LibWeb/Bindings/ExceptionOrUtils.h>
  13. #include <LibWeb/Bindings/PlatformObject.h>
  14. namespace Web::WebAssembly {
  15. class Instance : public Bindings::PlatformObject {
  16. WEB_PLATFORM_OBJECT(Instance, Bindings::PlatformObject);
  17. public:
  18. static WebIDL::ExceptionOr<JS::NonnullGCPtr<Instance>> construct_impl(JS::Realm&, Module& module, Optional<JS::Handle<JS::Object>>& import_object);
  19. Object const* exports() const { return m_exports.ptr(); }
  20. private:
  21. Instance(JS::Realm&, size_t index);
  22. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  23. virtual void visit_edges(Visitor&) override;
  24. JS::NonnullGCPtr<Object> m_exports;
  25. size_t m_index { 0 };
  26. };
  27. }