/* * Copyright (c) 2021, Ali Mohammad Pur * Copyright (c) 2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace Web::WebAssembly { struct MemoryDescriptor { u32 initial { 0 }; Optional maximum; }; class Memory : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(Memory, Bindings::PlatformObject); public: static WebIDL::ExceptionOr> construct_impl(JS::Realm&, MemoryDescriptor& descriptor); WebIDL::ExceptionOr grow(u32 delta); WebIDL::ExceptionOr> buffer() const; Wasm::MemoryAddress address() const { return m_address; } private: Memory(JS::Realm&, Wasm::MemoryAddress); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; Wasm::MemoryAddress m_address; }; }