WebAssemblyInstanceObject.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Runtime/GlobalObject.h>
  8. #include <LibJS/Runtime/Object.h>
  9. #include <LibJS/Runtime/VM.h>
  10. #include <LibWasm/AbstractMachine/AbstractMachine.h>
  11. #include <LibWeb/Forward.h>
  12. #include <LibWeb/WebAssembly/WebAssemblyObject.h>
  13. namespace Web::Bindings {
  14. class WebAssemblyInstanceObject final : public JS::Object {
  15. JS_OBJECT(WebAssemblyInstanceObject, Object);
  16. public:
  17. explicit WebAssemblyInstanceObject(JS::GlobalObject&, size_t index);
  18. virtual void initialize(JS::GlobalObject&) override;
  19. virtual ~WebAssemblyInstanceObject() override = default;
  20. size_t index() const { return m_index; }
  21. Wasm::ModuleInstance& instance() const { return WebAssemblyObject::s_instantiated_modules.at(m_index); }
  22. auto& cache() { return WebAssemblyObject::s_module_caches.at(m_index); }
  23. void visit_edges(Visitor&) override;
  24. friend class WebAssemblyInstancePrototype;
  25. private:
  26. size_t m_index { 0 };
  27. Object* m_exports_object { nullptr };
  28. };
  29. }