mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
LibWasm: Give traps a reason and display it when needed
This makes debugging wasm code a bit easier, as we now know what fails instead of just "too bad, something went wrong".
This commit is contained in:
parent
62ca81fdcc
commit
b538e15548
10 changed files with 54 additions and 50 deletions
|
@ -193,28 +193,29 @@ private:
|
|||
};
|
||||
|
||||
struct Trap {
|
||||
// Empty value type
|
||||
String reason;
|
||||
};
|
||||
|
||||
class Result {
|
||||
public:
|
||||
explicit Result(Vector<Value> values)
|
||||
: m_values(move(values))
|
||||
: m_result(move(values))
|
||||
{
|
||||
}
|
||||
|
||||
Result(Trap)
|
||||
: m_is_trap(true)
|
||||
Result(Trap trap)
|
||||
: m_result(move(trap))
|
||||
{
|
||||
}
|
||||
|
||||
auto& values() const { return m_values; }
|
||||
auto& values() { return m_values; }
|
||||
auto is_trap() const { return m_is_trap; }
|
||||
auto is_trap() const { return m_result.has<Trap>(); }
|
||||
auto& values() const { return m_result.get<Vector<Value>>(); }
|
||||
auto& values() { return m_result.get<Vector<Value>>(); }
|
||||
auto& trap() const { return m_result.get<Trap>(); }
|
||||
auto& trap() { return m_result.get<Trap>(); }
|
||||
|
||||
private:
|
||||
Vector<Value> m_values;
|
||||
bool m_is_trap { false };
|
||||
Variant<Vector<Value>, Trap> m_result;
|
||||
};
|
||||
|
||||
using ExternValue = Variant<FunctionAddress, TableAddress, MemoryAddress, GlobalAddress>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue