/* * 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 #include static enum nw_state push(struct nw_interp *const i) { struct nw_i_sm_i64_const *const c = &i->sm.i64_const; const enum nw_state n = nwp_stack_push(i, &c->io); if (n) return n; i->push_type = NW_TYPE_I64; nwp_interp_resume(i); return NW_AGAIN; } static enum nw_state get_value(struct nw_interp *const i) { const struct nw_io_cfg *const cfg = &i->cfg.io; struct nw_i_sm_i64_const *const c = &i->sm.i64_const; struct nw_sm_leb128 *const l = &c->leb128; const enum nw_state n = nwp_varuint64(cfg, l, &c->value, cfg->user); if (n) return n; else { struct nw_sm_io io = {0}; io.buf = &c->value; io.n = sizeof c->value; c->io = io; i->next = push; } return NW_AGAIN; } void nwp_op_i64_const(struct nw_interp *const i) { const struct nw_i_sm_i64_const c = {{0}}; i->next = get_value; i->sm.i64_const = c; }