aboutsummaryrefslogtreecommitdiff
path: root/src/interp/ops.c
blob: ea7c2b92308ab9e69f63c597d7be5da5024d2368 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * nanowasm, a tiny WebAssembly/Wasm interpreter
 * Copyright (C) 2023-2024  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/opcodes.h>
#include <nw/ops.h>
#include <nw/interp.h>

static void (*const ops[])(struct nw_interp *) =
{
    [OP_UNREACHABLE] = nwp_op_unreachable,
    [OP_NOP] = nwp_op_nop,
    [OP_I32_LOAD] = nwp_op_i32_load,
    [OP_I32_CONST] = nwp_op_i32_const,
    [OP_END] = nwp_op_end,
#if 0
    [OP_BLOCK] = nwp_op_block,
    [OP_LOOP] = nwp_op_loop,
    [OP_IF] = nwp_op_if,
    [OP_ELSE] = nwp_op_else,

    [OP_BR] = nwp_op_br,
    [OP_BR_IF] = nwp_op_br_if,
    [OP_BR_TABLE] = nwp_op_br_table,
    [OP_RETURN] = nwp_op_return,
    [OP_CALL] = nwp_op_call,
    [OP_CALL_INDIRECT] = nwp_op_call_indirect,
    [OP_GET_LOCAL] = nwp_op_get_local,
    [OP_SET_LOCAL] = nwp_op_set_local,
    [OP_TEE_LOCAL] = nwp_op_tee_local,
    [OP_GET_GLOBAL] = nwp_op_get_global,
    [OP_SET_GLOBAL] = nwp_op_set_global,

    [OP_I32_STORE] = nwp_op_i32_store,

    [OP_I64_CONST] = nwp_op_i64_const,
    [OP_F32_CONST] = nwp_op_f32_const,
    [OP_F64_CONST] = nwp_op_f64_const,
    [OP_I32_SUB] = nwp_op_i32_sub
#endif
};

const struct nwp_ops nwp_ops =
{
    .ops = ops,
    .n = sizeof ops / sizeof *ops
};