diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-11-20 06:51:24 +0330 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-11-26 02:23:15 +0330 |
commit | af511a64cd9d9306f091f441fd0ba0f2c2a5365d (patch) | |
tree | e472774535aed78f142d1bff12dacf61db1f710b /Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp | |
parent | 0d1471e72f9b5869a76520921e6e7787dc4b7b3e (diff) | |
download | serenity-af511a64cd9d9306f091f441fd0ba0f2c2a5365d.zip |
LibWeb: Add support for accessing exported wasm table instances
Diffstat (limited to 'Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp index 7d937fe963..8fa738a005 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp @@ -14,6 +14,7 @@ #include <LibWeb/WebAssembly/WebAssemblyInstanceObject.h> #include <LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h> #include <LibWeb/WebAssembly/WebAssemblyObject.h> +#include <LibWeb/WebAssembly/WebAssemblyTableObject.h> namespace Web::Bindings { @@ -51,6 +52,14 @@ void WebAssemblyInstanceObject::initialize(JS::Realm& realm) } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); }, + [&](Wasm::TableAddress const& address) { + Optional<WebAssemblyTableObject*> object = cache.table_instances.get(address); + if (!object.has_value()) { + object = heap().allocate<Web::Bindings::WebAssemblyTableObject>(realm, realm, address); + cache.table_instances.set(address, *object); + } + m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); + }, [&](auto const&) { // FIXME: Implement other exports! }); |