mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
LibWasm: Implement reference instructions (ref.{null,func,is_null})
This commit is contained in:
parent
7fb458b7c9
commit
56bf80251c
8 changed files with 73 additions and 9 deletions
|
@ -190,6 +190,12 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
|
|||
case Wasm::ValueType::Kind::ExternReference:
|
||||
arguments.append(Wasm::Value(Wasm::ExternAddress { static_cast<u64>(value) }));
|
||||
break;
|
||||
case Wasm::ValueType::Kind::NullFunctionReference:
|
||||
arguments.append(Wasm::Value(Wasm::Value::Null { Wasm::ValueType(Wasm::ValueType::Kind::FunctionReference) }));
|
||||
break;
|
||||
case Wasm::ValueType::Kind::NullExternReference:
|
||||
arguments.append(Wasm::Value(Wasm::Value::Null { Wasm::ValueType(Wasm::ValueType::Kind::ExternReference) }));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,6 +212,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
|
|||
result.values().first().value().visit(
|
||||
[&](const auto& value) { return_value = JS::Value(static_cast<double>(value)); },
|
||||
[&](const Wasm::FunctionAddress& index) { return_value = JS::Value(static_cast<double>(index.value())); },
|
||||
[&](const Wasm::ExternAddress& index) { return_value = JS::Value(static_cast<double>(index.value())); });
|
||||
[&](const Wasm::ExternAddress& index) { return_value = JS::Value(static_cast<double>(index.value())); },
|
||||
[&](const Wasm::Value::Null&) { return_value = JS::js_null(); });
|
||||
return return_value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue