/* * nanowasm, a tiny WebAssembly/Wasm interpreter * Copyright (C) 2023-2025 Xavier Del Campo Romero * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include #include #include #include #include static enum nw_state push(struct nw_interp *const i) { struct nw_i_sm_i32_arithm *const a = &i->sm.i32_arithm; const enum nw_state n = nwp_stack_push(i, &a->io); if (n) return n; i->push_type = NW_TYPE_I32; nwp_interp_resume(i); return NW_AGAIN; } void nwp_op_i32_arithm(struct nw_interp *const i, const long result) { const struct nw_i_sm_i32_arithm a = {0}; struct nw_i_sm_i32_arithm *const s = &i->sm.i32_arithm; *s = a; s->result = result; s->io.buf = &s->result; s->io.n = sizeof s->result; i->next = push; }