1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:44:58 +00:00

LibWasm: Implement reference instructions (ref.{null,func,is_null})

This commit is contained in:
Ali Mohammad Pur 2021-06-01 09:48:36 +04:30 committed by Ali Mohammad Pur
parent 7fb458b7c9
commit 56bf80251c
8 changed files with 73 additions and 9 deletions

View file

@ -202,9 +202,11 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi
warnln("Returned:");
for (auto& value : result.values()) {
auto str = value.value().visit(
[&](const auto& value) {
[&]<typename T>(const T& value) {
if constexpr (requires { value.value(); })
return String::formatted(" -> addr{} ", value.value());
else if constexpr (IsSame<Wasm::Value::Null, T>)
return String::formatted(" ->addr(null)");
else
return String::formatted(" -> {} ", value);
});
@ -460,9 +462,11 @@ int main(int argc, char* argv[])
warnln("Returned:");
for (auto& value : result.values()) {
value.value().visit(
[&](const auto& value) {
[&]<typename T>(const T& value) {
if constexpr (requires { value.value(); })
out(" -> addr{} ", value.value());
else if constexpr (IsSame<Wasm::Value::Null, T>)
out(" ->addr(null)");
else
out(" -> {} ", value);
});