MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / validate_block

Method validate_block

cranelift/isle/isle/src/codegen.rs:620–642  ·  view source on GitHub ↗
(ret_kind: ReturnKind, block: &Block)

Source from the content-addressed store, hash-verified

618 }
619
620 fn validate_block(ret_kind: ReturnKind, block: &Block) -> Nested<'_> {
621 if !matches!(ret_kind, ReturnKind::Iterator) {
622 // Loops are only allowed if we're returning an iterator.
623 assert!(
624 !block
625 .steps
626 .iter()
627 .any(|c| matches!(c.check, ControlFlow::Loop { .. }))
628 );
629
630 // Unless we're returning an iterator, a case which returns a result must be the last
631 // case in a block.
632 if let Some(result_pos) = block
633 .steps
634 .iter()
635 .position(|c| matches!(c.check, ControlFlow::Return { .. }))
636 {
637 assert_eq!(block.steps.len() - 1, result_pos);
638 }
639 }
640
641 Nested::Cases(block.steps.iter())
642 }
643
644 fn block_weight(block: &Block) -> usize {
645 fn cf_weight(cf: &ControlFlow) -> usize {

Callers

nothing calls this directly

Calls 2

positionMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected