MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / write_variant_arms_to_memory

Method write_variant_arms_to_memory

crates/core/src/abi.rs:2099–2120  ·  view source on GitHub ↗
(
        &mut self,
        offset: ArchitectureSize,
        addr: B::Operand,
        tag: Int,
        cases: impl IntoIterator<Item = Option<&'b Type>> + Clone,
    )

Source from the content-addressed store, hash-verified

2097 }
2098
2099 fn write_variant_arms_to_memory<'b>(
2100 &mut self,
2101 offset: ArchitectureSize,
2102 addr: B::Operand,
2103 tag: Int,
2104 cases: impl IntoIterator<Item = Option<&'b Type>> + Clone,
2105 ) {
2106 let payload_offset = offset + (self.bindgen.sizes().payload_offset(tag, cases.clone()));
2107 for (i, ty) in cases.into_iter().enumerate() {
2108 self.push_block();
2109 self.emit(&Instruction::VariantPayloadName);
2110 let payload_name = self.stack.pop().unwrap();
2111 self.emit(&Instruction::I32Const { val: i as i32 });
2112 self.stack.push(addr.clone());
2113 self.store_intrepr(offset, tag);
2114 if let Some(ty) = ty {
2115 self.stack.push(payload_name.clone());
2116 self.write_to_memory(ty, addr.clone(), payload_offset);
2117 }
2118 self.finish_block(0);
2119 }
2120 }
2121
2122 fn write_list_to_memory(&mut self, ty: &Type, addr: B::Operand, offset: ArchitectureSize) {
2123 // After lowering the list there's two i32 values on the stack

Callers 1

write_to_memoryMethod · 0.80

Calls 7

store_intreprMethod · 0.80
write_to_memoryMethod · 0.80
sizesMethod · 0.45
push_blockMethod · 0.45
emitMethod · 0.45
pushMethod · 0.45
finish_blockMethod · 0.45

Tested by

no test coverage detected