LibWeb/WebAssembly: Change behavior of explicit undefined in tables

This commit is contained in:
Diego Frias 2024-08-17 17:02:59 -07:00 committed by Ali Mohammad Pur
commit 80434fa516
Notes: github-actions[bot] 2024-08-18 21:36:03 +00:00
3 changed files with 26 additions and 10 deletions

View file

@ -455,6 +455,22 @@ JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::VM& vm, JS::Value va
VERIFY_NOT_REACHED();
}
Wasm::Value default_webassembly_value(JS::VM& vm, Wasm::ValueType type)
{
switch (type.kind()) {
case Wasm::ValueType::I32:
case Wasm::ValueType::I64:
case Wasm::ValueType::F32:
case Wasm::ValueType::F64:
case Wasm::ValueType::V128:
case Wasm::ValueType::FunctionReference:
return Wasm::Value(type);
case Wasm::ValueType::ExternReference:
return MUST(to_webassembly_value(vm, JS::js_undefined(), type));
}
VERIFY_NOT_REACHED();
}
// https://webassembly.github.io/spec/js-api/#tojsvalue
JS::Value to_js_value(JS::VM& vm, Wasm::Value& wasm_value, Wasm::ValueType type)
{