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(init:0, |sum: usize, param: &(Type, Param)| sum + std::cmp::max(v1:4, v2: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: &Type, _)| ty.dependencies(dependencies)); |
22 | } |
23 | |
24 | pub fn types(&self) -> impl Iterator<Item = &Type> + '_ { |
25 | stdimpl Iterator ::iter::once(&self.return_type.0) |
26 | .chain(self.params.iter().map(|(ty: &Type, _)| ty)) |
27 | .map(|ty: &Type| ty.decay()) |
28 | } |
29 | } |
30 | |