blob: e833a113156a98fc58fa9d8445068819bbdb91b9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/*
* 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 <nanowasm/nw.h>
#include <nw/io.h>
#include <nw/interp.h>
#include <nw/stack.h>
#include <nw/routines.h>
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;
}
|