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

Method visit_else

crates/parser/src/visit.rs:298–312  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

296 }
297
298 fn visit_else(&mut self) -> Self::Output {
299 let last_if = self.ctx_stack.last().filter(|ctx| matches!(ctx.kind, BlockKind::If));
300 if let Some(cond_jump_ip) = last_if.map(|ctx| ctx.branch_jumps[0]) {
301 let jump_ip = self.instructions.len();
302 self.instructions.push(Instruction::Jump(0));
303 if let Some(ctx) = self.ctx_stack.last_mut() {
304 ctx.has_else = true;
305 ctx.branch_jumps.push(jump_ip);
306 self.patch_jump_if_zero(cond_jump_ip, self.instructions.len());
307 if !matches!(self.instructions.last(), Some(Instruction::Nop | Instruction::MergeBarrier)) {
308 self.instructions.push(Instruction::MergeBarrier); // prevent superinstructions from merging across block boundaries
309 }
310 };
311 };
312 }
313
314 fn visit_end(&mut self) -> Self::Output {
315 if let Some(ctx) = self.ctx_stack.pop() {

Callers

nothing calls this directly

Calls 5

mapMethod · 0.80
patch_jump_if_zeroMethod · 0.80
lastMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected