| 14 | namespace wasmtime { |
| 15 | |
| 16 | inline Result<ExnRef> ExnRef::create(Store::Context cx, const Tag &tag, |
| 17 | const std::vector<Val> &fields) { |
| 18 | wasmtime_exnref_t exn; |
| 19 | auto *error = wasmtime_exnref_new( |
| 20 | cx.capi(), &tag.capi(), |
| 21 | reinterpret_cast<const wasmtime_val_t *>(fields.data()), fields.size(), |
| 22 | &exn); |
| 23 | if (error != nullptr) { |
| 24 | return Error(error); |
| 25 | } |
| 26 | return ExnRef(exn); |
| 27 | } |
| 28 | |
| 29 | /// Reads a field value by index. |
| 30 | inline Result<Val> ExnRef::field(Store::Context cx, size_t index) const { |