1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

wasm: Don't try to print the function results if it traps

This commit is contained in:
Ali Mohammad Pur 2021-07-13 00:36:50 +04:30
parent 23b48f8fe1
commit bacf5a7220

View file

@ -512,14 +512,16 @@ int main(int argc, char* argv[])
if (debug) if (debug)
launch_repl(); launch_repl();
if (result.is_trap()) if (result.is_trap()) {
warnln("Execution trapped!"); warnln("Execution trapped: {}", result.trap().reason);
if (!result.values().is_empty()) } else {
warnln("Returned:"); if (!result.values().is_empty())
for (auto& value : result.values()) { warnln("Returned:");
Wasm::Printer printer { stream }; for (auto& value : result.values()) {
g_stdout.write(" -> "sv.bytes()); Wasm::Printer printer { stream };
g_printer.print(value); g_stdout.write(" -> "sv.bytes());
g_printer.print(value);
}
} }
} }
} }