diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-10 23:47:10 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-10 23:47:10 +0100 |
| commit | ba623c7a3a5b450b9b492de50efceea93df96039 (patch) | |
| tree | 92b0d70db2fb304bac604338215401e25e8c4aac /src/routines | |
| parent | 806824b23c28d2d81ffd588c555be82fa5a14004 (diff) | |
| download | nanowasm-ba623c7a3a5b450b9b492de50efceea93df96039.tar.gz | |
Add if and else operators
Diffstat (limited to 'src/routines')
| -rw-r--r-- | src/routines/start_block.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/routines/start_block.c b/src/routines/start_block.c index 83be44c..fb0b420 100644 --- a/src/routines/start_block.c +++ b/src/routines/start_block.c @@ -17,7 +17,7 @@ static enum nw_state get_block_type(struct nw_interp *const i) { nw_varint7 type; - struct nw_i_sm_sb *const sb = &i->sm.start_block; + struct nw_i_sm_sb *const sb = i->state; const struct nw_io_cfg *const cfg = &i->cfg.io; const enum nw_state n = nwp_varint7(cfg, &sb->leb128, &type, cfg->user); enum nw_type block_type; @@ -26,24 +26,27 @@ static enum nw_state get_block_type(struct nw_interp *const i) return n; else if (type != 0x40 && nwp_get_type(type, &block_type)) { - static const char *const exc = "invalid block_type"; + static const char *const exc = "invalid block type"; i->exception = exc; -#ifdef NW_LOG - nwp_log("%s: %#hhx\n", exc, (unsigned char)type); +#ifdef ENABLE_LOG + nwp_log("%s: %#x\n", exc, (unsigned)type); #endif return NW_FATAL; } i->fr.block_i++; - nwp_interp_resume(i); + i->next = sb->next; return NW_AGAIN; } -void nwp_start_block(struct nw_interp *const i) +void nwp_start_block(struct nw_interp *const i, struct nw_i_sm_sb *const psb, + enum nw_state (*const next)(struct nw_interp *)) { const struct nw_i_sm_sb sb = {0}; - i->sm.start_block = sb; + *psb = sb; + psb->next = next; + i->state = psb; i->next = get_block_type; } |
