mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +00:00
LibWasm: Load and instantiate tables
This commit is a fairly large refactor, mainly because it unified the two different ways that existed to represent references. Now Reference values are also a kind of value. It also implements a printer for values/references instead of copying the implementation everywhere.
This commit is contained in:
parent
c392a0cf7f
commit
be62e4d1d7
10 changed files with 350 additions and 192 deletions
|
@ -204,17 +204,8 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi
|
|||
if (!result.values().is_empty())
|
||||
warnln("Returned:");
|
||||
for (auto& value : result.values()) {
|
||||
auto str = value.value().visit(
|
||||
[&]<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);
|
||||
});
|
||||
g_stdout.write(str.bytes());
|
||||
g_printer.print(value.type());
|
||||
g_stdout.write(" -> "sv.bytes());
|
||||
g_printer.print(value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -541,17 +532,9 @@ int main(int argc, char* argv[])
|
|||
if (!result.values().is_empty())
|
||||
warnln("Returned:");
|
||||
for (auto& value : result.values()) {
|
||||
value.value().visit(
|
||||
[&]<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);
|
||||
});
|
||||
Wasm::Printer printer { stream };
|
||||
printer.print(value.type());
|
||||
g_stdout.write(" -> "sv.bytes());
|
||||
g_printer.print(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue