| 32 | self.push_str(&self.ty(ty, mode)) |
| 33 | } |
| 34 | fn ty(&self, ty: &Type, mode: TypeMode) -> String { |
| 35 | match ty { |
| 36 | Type::Id(t) => self.tyid(*t, mode), |
| 37 | Type::Bool => "bool".to_string(), |
| 38 | Type::U8 => "u8".to_string(), |
| 39 | Type::U16 => "u16".to_string(), |
| 40 | Type::U32 => "u32".to_string(), |
| 41 | Type::U64 => "u64".to_string(), |
| 42 | Type::S8 => "i8".to_string(), |
| 43 | Type::S16 => "i16".to_string(), |
| 44 | Type::S32 => "i32".to_string(), |
| 45 | Type::S64 => "i64".to_string(), |
| 46 | Type::F32 => "f32".to_string(), |
| 47 | Type::F64 => "f64".to_string(), |
| 48 | Type::Char => "char".to_string(), |
| 49 | Type::String => match mode { |
| 50 | TypeMode::AllBorrowed(lt) => { |
| 51 | if lt != "'_" { |
| 52 | format!("&{lt} str") |
| 53 | } else { |
| 54 | format!("&str") |
| 55 | } |
| 56 | } |
| 57 | TypeMode::Owned => { |
| 58 | let wt = self.wasmtime_path(); |
| 59 | format!("{wt}::component::__internal::String") |
| 60 | } |
| 61 | }, |
| 62 | Type::ErrorContext => { |
| 63 | let wt = self.wasmtime_path(); |
| 64 | format!("{wt}::component::ErrorContext") |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | fn print_optional_ty(&mut self, ty: Option<&Type>, mode: TypeMode) { |
| 70 | self.push_str(&self.optional_ty(ty, mode)) |