diff options
Diffstat (limited to 'src/op/br_table.c')
| -rw-r--r-- | src/op/br_table.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/op/br_table.c b/src/op/br_table.c new file mode 100644 index 0000000..09ae8e4 --- /dev/null +++ b/src/op/br_table.c @@ -0,0 +1,46 @@ +#include <interp.h> +#include <interp_private.h> +#include <wasm_types.h> +#include <stddef.h> +#include <stdio.h> + +static int op(FILE *const f, struct interp *const i) +{ + varuint32 target_count, default_target; + + if (varuint32_read(f, &target_count)) + { + fprintf(stderr, "%s: varuint32_read target_count failed\n", __func__); + return -1; + } + + for (varuint32 i = 0; i < target_count; i++) + { + varuint32 target_table; + + if (varuint32_read(f, &target_table)) + { + fprintf(stderr, "%s: varuint32_read target_table failed\n", + __func__); + return -1; + } + } + + if (varuint32_read(f, &default_target)) + { + fprintf(stderr, "%s: varuint32_read default_target failed\n", __func__); + return -1; + } + + return 0; +} + +int op_br_table(struct interp *const i) +{ + return op(i->cfg.f, i); +} + +int check_br_table(FILE *const f) +{ + return op(f, NULL); +} |
