Instance.h 1019 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. JS_DECLARE_ALLOCATOR(Instance);
  18. public:
  19. static WebIDL::ExceptionOr<JS::NonnullGCPtr<Instance>> construct_impl(JS::Realm&, Module& module, Optional<JS::Handle<JS::Object>>& import_object);
  20. Object const* exports() const { return m_exports.ptr(); }
  21. private:
  22. Instance(JS::Realm&, size_t index);
  23. virtual void initialize(JS::Realm&) override;
  24. virtual void visit_edges(Visitor&) override;
  25. JS::NonnullGCPtr<Object> m_exports;
  26. size_t m_index { 0 };
  27. };
  28. }