|
1 |
| -use crate::asg::{self}; |
2 |
| -use std::collections::HashSet; |
| 1 | +use crate::asg::{Type, TypeKind}; |
| 2 | +use indexmap::IndexSet; |
3 | 3 |
|
4 |
| -pub fn collect_polymorphs(map: &mut HashSet<String>, ty: &asg::Type) { |
| 4 | +pub fn collect_polymorphs(map: &mut IndexSet<String>, ty: &Type) { |
5 | 5 | match &ty.kind {
|
6 |
| - asg::TypeKind::Unresolved => panic!(), |
7 |
| - asg::TypeKind::Boolean |
8 |
| - | asg::TypeKind::Integer(_, _) |
9 |
| - | asg::TypeKind::CInteger(_, _) |
10 |
| - | asg::TypeKind::IntegerLiteral(_) |
11 |
| - | asg::TypeKind::FloatLiteral(_) |
12 |
| - | asg::TypeKind::Floating(_) => (), |
13 |
| - asg::TypeKind::Ptr(inner) => collect_polymorphs(map, inner.as_ref()), |
14 |
| - asg::TypeKind::Void => (), |
15 |
| - asg::TypeKind::Never => (), |
16 |
| - asg::TypeKind::AnonymousStruct() => todo!(), |
17 |
| - asg::TypeKind::AnonymousUnion() => todo!(), |
18 |
| - asg::TypeKind::AnonymousEnum(_) => (), |
19 |
| - asg::TypeKind::FixedArray(fixed_array) => collect_polymorphs(map, &fixed_array.inner), |
20 |
| - asg::TypeKind::FuncPtr(_) => todo!(), |
21 |
| - asg::TypeKind::Enum(_, _) => (), |
22 |
| - asg::TypeKind::Structure(_, _, params) | asg::TypeKind::TypeAlias(_, _, params) => { |
| 6 | + TypeKind::Unresolved => panic!(), |
| 7 | + TypeKind::Boolean |
| 8 | + | TypeKind::Integer(_, _) |
| 9 | + | TypeKind::CInteger(_, _) |
| 10 | + | TypeKind::IntegerLiteral(_) |
| 11 | + | TypeKind::FloatLiteral(_) |
| 12 | + | TypeKind::Floating(_) => (), |
| 13 | + TypeKind::Ptr(inner) => collect_polymorphs(map, inner.as_ref()), |
| 14 | + TypeKind::Void => (), |
| 15 | + TypeKind::Never => (), |
| 16 | + TypeKind::AnonymousStruct() => todo!(), |
| 17 | + TypeKind::AnonymousUnion() => todo!(), |
| 18 | + TypeKind::AnonymousEnum(_) => (), |
| 19 | + TypeKind::FixedArray(fixed_array) => collect_polymorphs(map, &fixed_array.inner), |
| 20 | + TypeKind::FuncPtr(_) => todo!(), |
| 21 | + TypeKind::Enum(_, _) => (), |
| 22 | + TypeKind::Structure(_, _, params) | TypeKind::TypeAlias(_, _, params) => { |
23 | 23 | for parameter in params {
|
24 | 24 | collect_polymorphs(map, parameter);
|
25 | 25 | }
|
26 | 26 | }
|
27 |
| - asg::TypeKind::Polymorph(name) => { |
| 27 | + TypeKind::Polymorph(name) => { |
28 | 28 | if !map.contains(name) {
|
29 | 29 | map.insert(name.into());
|
30 | 30 | }
|
31 | 31 | }
|
32 |
| - asg::TypeKind::Trait(_, _, parameters) => { |
| 32 | + TypeKind::Trait(_, _, parameters) => { |
33 | 33 | for parameter in parameters {
|
34 | 34 | collect_polymorphs(map, parameter);
|
35 | 35 | }
|
|
0 commit comments