mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibWeb: Add WebAssembly.Global and exports support for global instances
This commit is contained in:
parent
910ff8b694
commit
44e3817219
Notes:
github-actions[bot]
2024-12-24 14:21:40 +00:00
Author: https://github.com/ADKaster
Commit: 44e3817219
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3028
10 changed files with 268 additions and 4 deletions
43
Libraries/LibWeb/WebAssembly/Global.h
Normal file
43
Libraries/LibWeb/WebAssembly/Global.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWasm/AbstractMachine/AbstractMachine.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/GlobalPrototype.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::WebAssembly {
|
||||
|
||||
struct GlobalDescriptor {
|
||||
Bindings::ValueType value;
|
||||
bool mutable_ { false };
|
||||
};
|
||||
|
||||
class Global : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(Global, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(Global);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<GC::Ref<Global>> construct_impl(JS::Realm&, GlobalDescriptor& descriptor, JS::Value v);
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> value_of() const;
|
||||
|
||||
WebIDL::ExceptionOr<void> set_value(JS::Value);
|
||||
WebIDL::ExceptionOr<JS::Value> value() const;
|
||||
|
||||
Wasm::GlobalAddress address() const { return m_address; }
|
||||
|
||||
private:
|
||||
Global(JS::Realm&, Wasm::GlobalAddress);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Wasm::GlobalAddress m_address;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue