summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/WebAssembly/Instance.h
blob: c3f4380d0116baf3d7532a9b29a3fe10279f2643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
 * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Optional.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibJS/Heap/Handle.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/PlatformObject.h>

namespace Web::WebAssembly {

class Instance : public Bindings::PlatformObject {
    WEB_PLATFORM_OBJECT(Instance, Bindings::PlatformObject);

public:
    static WebIDL::ExceptionOr<JS::NonnullGCPtr<Instance>> construct_impl(JS::Realm&, Module& module, Optional<JS::Handle<JS::Object>>& import_object);

    Object const* exports() const { return m_exports.ptr(); }

private:
    Instance(JS::Realm&, size_t index);

    virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
    virtual void visit_edges(Visitor&) override;

    JS::NonnullGCPtr<Object> m_exports;
    size_t m_index { 0 };
};

}