mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWasm/WASI: Don't convert enums and u8s into i64
Doing so results in incorrect values being created, ultimately leading to traps or errors. (cherry picked from commit f6c3b333334f7bb5314a844804cb259cf277005e)
This commit is contained in:
parent
7181c3f2ea
commit
a4eb46fcca
Notes:
sideshowbarker
2024-07-17 10:31:19 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/LadybirdBrowser/ladybird/commit/a4eb46fcca Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/322
1 changed files with 14 additions and 1 deletions
|
@ -909,7 +909,20 @@ ErrorOr<HostFunction> Implementation::function_by_name(StringView name)
|
|||
namespace ABI {
|
||||
|
||||
template<typename T>
|
||||
auto CompatibleValueType = IsOneOf<T, i8, i16, i32>
|
||||
struct HostTypeImpl {
|
||||
using Type = T;
|
||||
};
|
||||
|
||||
template<Enum T>
|
||||
struct HostTypeImpl<T> {
|
||||
using Type = UnderlyingType<T>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using HostType = typename HostTypeImpl<T>::Type;
|
||||
|
||||
template<typename T>
|
||||
auto CompatibleValueType = IsOneOf<HostType<T>, i8, i16, i32, u8, u16>
|
||||
? Wasm::ValueType(Wasm::ValueType::I32)
|
||||
: Wasm::ValueType(Wasm::ValueType::I64);
|
||||
|
||||
|
|
Loading…
Reference in a new issue