diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-12 00:35:04 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-12 00:35:04 +0100 |
| commit | c3d6bac9d716433ca31f7d39332b2a6a96d8187d (patch) | |
| tree | aa9f769a98800e26203bcd8d65b8f8f5f1a95cfa | |
| parent | be7c97ce6ae43d677b28d455506fdaedf944a25b (diff) | |
call_import.c: Fix prev_ret
So far, this variable was only being assigned by unwind.c, which is
called only for WebAssembly functions. However, it is still mandatory
to report the last returned value from imported functions, too, as
prev_ret is relied upon by operators such as `drop`.
| -rw-r--r-- | src/routines/call_import.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/routines/call_import.c b/src/routines/call_import.c index 6a94ff0..38e0338 100644 --- a/src/routines/call_import.c +++ b/src/routines/call_import.c @@ -151,18 +151,20 @@ static enum nw_state call_done(struct nw_interp *const i) const nw_varuint32 pcnt = fn->param_count; const struct nw_interp_cfg *const icfg = &i->cfg; union nw_value *const ret = fn->ret.count ? icfg->args + pcnt : NULL; + struct nw_return r = {0}; if (ret) { size_t sz; + const enum nw_type type = fn->ret.type; - if (nwp_type_sz(fn->ret.type, &sz)) + if (nwp_type_sz(type, &sz)) { static const char *const exc = "invalid return type"; i->exception = exc; #ifdef NW_LOG - nwp_log("%s: %#x\n", exc, (unsigned)fn->ret.type); + nwp_log("%s: %#x\n", exc, (unsigned)type); #endif return NW_FATAL; } @@ -175,10 +177,14 @@ static enum nw_state call_done(struct nw_interp *const i) ci->io = io; i->next = push_return; } + + r.count = 1; + r.type = type; } else nwp_interp_resume(i); + i->fr.prev_ret = r; return NW_AGAIN; } |
