MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / patch_end_jumps

Method patch_end_jumps

crates/parser/src/visit.rs:730–749  ·  view source on GitHub ↗
(&mut self, ctx: LoweringCtx, end_ip: usize)

Source from the content-addressed store, hash-verified

728 }
729
730 fn patch_end_jumps(&mut self, ctx: LoweringCtx, end_ip: usize) {
731 match ctx.kind {
732 BlockKind::Block | BlockKind::Loop => {
733 let target = if matches!(ctx.kind, BlockKind::Loop) { ctx.start_ip } else { end_ip };
734 for jump_ip in ctx.branch_jumps {
735 self.patch_jump(jump_ip, target);
736 }
737 }
738 BlockKind::If => {
739 if let Some((&cond_jump_ip, branch_jumps)) = ctx.branch_jumps.split_first() {
740 if !ctx.has_else {
741 self.patch_jump_if_zero(cond_jump_ip, end_ip);
742 }
743 for &jump_ip in branch_jumps {
744 self.patch_jump(jump_ip, end_ip);
745 }
746 }
747 }
748 }
749 }
750}

Callers 1

visit_endMethod · 0.80

Calls 2

patch_jumpMethod · 0.80
patch_jump_if_zeroMethod · 0.80

Tested by

no test coverage detected