1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibWeb: Split the WebAssemblyInstance object logic into multiple files

Now that we're adding a constructor to it, let's split it up like the
rest of LibWeb does.
This commit is contained in:
Ali Mohammad Pur 2021-07-01 11:19:45 +04:30 committed by Ali Mohammad Pur
parent a4897ed7b2
commit bfb3d9e9d0
7 changed files with 116 additions and 77 deletions

View file

@ -9,11 +9,14 @@
#include <LibJS/Runtime/Object.h>
#include <LibWasm/AbstractMachine/AbstractMachine.h>
#include <LibWeb/Forward.h>
#include <LibWeb/WebAssembly/WebAssemblyObjectPrototype.h>
#include <LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h>
namespace Web::Bindings {
class WebAssemblyMemoryObject;
JS::NativeFunction* create_native_function(Wasm::FunctionAddress address, String name, JS::GlobalObject& global_object);
JS::Value to_js_value(Wasm::Value& wasm_value, JS::GlobalObject& global_object);
Optional<Wasm::Value> to_webassembly_value(JS::Value value, const Wasm::ValueType& type, JS::GlobalObject& global_object);
class WebAssemblyObject final : public JS::Object {
JS_OBJECT(WebAssemblyObject, JS::Object);
@ -73,27 +76,6 @@ private:
size_t m_index { 0 };
};
class WebAssemblyInstanceObject final : public JS::Object {
JS_OBJECT(WebAssemblyInstanceObject, JS::Object);
public:
explicit WebAssemblyInstanceObject(JS::GlobalObject&, size_t index);
virtual void initialize(JS::GlobalObject&) override;
virtual ~WebAssemblyInstanceObject() override = default;
size_t index() const { return m_index; }
Wasm::ModuleInstance& instance() const { return WebAssemblyObject::s_instantiated_modules.at(m_index); }
auto& cache() { return WebAssemblyObject::s_module_caches.at(m_index); }
void visit_edges(Cell::Visitor&) override;
friend class WebAssemblyInstancePrototype;
private:
size_t m_index { 0 };
JS::Object* m_exports_object { nullptr };
};
class WebAssemblyMemoryObject final : public JS::Object {
JS_OBJECT(WebAssemblyMemoryObject, JS::Object);