| 1 | use super::*; |
| 2 | |
| 3 | #[derive(Clone, Debug, PartialEq, Eq)] |
| 4 | pub struct Signature { |
| 5 | pub call_flags: MethodCallAttributes, |
| 6 | pub return_type: (Type, Option<Param>), |
| 7 | pub params: Vec<(Type, Param)>, |
| 8 | } |
| 9 | |
| 10 | impl Signature { |
| 11 | pub fn size(&self) -> usize { |
| 12 | self.params |
| 13 | .iter() |
| 14 | .fold(0, |sum, param| sum + std::cmp::max(4, param.0.size())) |
| 15 | } |
| 16 | |
| 17 | pub fn dependencies(&self, dependencies: &mut TypeMap) { |
| 18 | self.return_type.0.dependencies(dependencies); |
| 19 | self.params |
| 20 | .iter() |
| 21 | .for_each(|(ty, _)| ty.dependencies(dependencies)); |
| 22 | } |
| 23 | |
| 24 | pub fn types(&self) -> impl Iterator<Item = &Type> + '_ { |
| 25 | std::iter::once(&self.return_type.0) |
| 26 | .chain(self.params.iter().map(|(ty, _)| ty)) |
| 27 | .map(|ty| ty.decay()) |
| 28 | } |
| 29 | } |
| 30 | |