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

Method write_ref

crates/test-util/src/component_fuzz.rs:1354–1388  ·  view source on GitHub ↗
(&mut self, ty: &'a Type, dst: &mut String)

Source from the content-addressed store, hash-verified

1352
1353impl<'a> TypesBuilder<'a> {
1354 fn write_ref(&mut self, ty: &'a Type, dst: &mut String) {
1355 match ty {
1356 // Primitive types can be referenced directly
1357 Type::Bool => dst.push_str("bool"),
1358 Type::S8 => dst.push_str("s8"),
1359 Type::U8 => dst.push_str("u8"),
1360 Type::S16 => dst.push_str("s16"),
1361 Type::U16 => dst.push_str("u16"),
1362 Type::S32 => dst.push_str("s32"),
1363 Type::U32 => dst.push_str("u32"),
1364 Type::S64 => dst.push_str("s64"),
1365 Type::U64 => dst.push_str("u64"),
1366 Type::Float32 => dst.push_str("float32"),
1367 Type::Float64 => dst.push_str("float64"),
1368 Type::Char => dst.push_str("char"),
1369 Type::String => dst.push_str("string"),
1370
1371 // Otherwise emit a reference to the type and remember to generate
1372 // the corresponding type alias later.
1373 Type::List(_)
1374 | Type::Map(_, _)
1375 | Type::Record(_)
1376 | Type::Tuple(_)
1377 | Type::Variant(_)
1378 | Type::Enum(_)
1379 | Type::Option(_)
1380 | Type::Result { .. }
1381 | Type::Flags(_) => {
1382 let idx = self.next;
1383 self.next += 1;
1384 uwrite!(dst, "$t{idx}");
1385 self.worklist.push((idx, ty));
1386 }
1387 }
1388 }
1389
1390 fn write_decl(&mut self, idx: u32, ty: &'a Type) -> String {
1391 let mut decl = format!("(type $t{idx}' ");

Callers 2

write_declMethod · 0.80
declarationsMethod · 0.80

Calls 2

push_strMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected