summaryrefslogtreecommitdiff
path: root/src/ir/ty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/ty.rs')
-rw-r--r--src/ir/ty.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index b805dd62..9cc097d4 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -320,6 +320,7 @@ impl Type {
match self.kind {
TypeKind::TypeParam |
TypeKind::Array(..) |
+ TypeKind::Vector(..) |
TypeKind::Comp(..) |
TypeKind::Opaque |
TypeKind::Int(..) |
@@ -472,6 +473,7 @@ impl TypeKind {
TypeKind::Alias(..) => "Alias",
TypeKind::TemplateAlias(..) => "TemplateAlias",
TypeKind::Array(..) => "Array",
+ TypeKind::Vector(..) => "Vector",
TypeKind::Function(..) => "Function",
TypeKind::Enum(..) => "Enum",
TypeKind::Pointer(..) => "Pointer",
@@ -565,6 +567,7 @@ impl TemplateParameters for TypeKind {
TypeKind::Float(_) |
TypeKind::Complex(_) |
TypeKind::Array(..) |
+ TypeKind::Vector(..) |
TypeKind::Function(_) |
TypeKind::Enum(_) |
TypeKind::Pointer(_) |
@@ -627,6 +630,9 @@ pub enum TypeKind {
/// template parameters.
TemplateAlias(TypeId, Vec<TypeId>),
+ /// A packed vector type: element type, number of elements
+ Vector(TypeId, usize),
+
/// An array of a type and a length.
Array(TypeId, usize),
@@ -1148,12 +1154,15 @@ impl Type {
TypeKind::Comp(complex)
}
- // FIXME: We stub vectors as arrays since in 99% of the cases the
- // layout is going to be correct, and there's no way we can generate
- // vector types properly in Rust for now.
- //
- // That being said, that should be fixed eventually.
- CXType_Vector |
+ CXType_Vector => {
+ let inner = Item::from_ty(
+ ty.elem_type().as_ref().unwrap(),
+ location,
+ None,
+ ctx,
+ ).expect("Not able to resolve vector element?");
+ TypeKind::Vector(inner, ty.num_elements().unwrap())
+ }
CXType_ConstantArray => {
let inner = Item::from_ty(
ty.elem_type().as_ref().unwrap(),
@@ -1214,6 +1223,7 @@ impl Trace for Type {
TypeKind::Pointer(inner) |
TypeKind::Reference(inner) |
TypeKind::Array(inner, _) |
+ TypeKind::Vector(inner, _) |
TypeKind::Alias(inner) |
TypeKind::ResolvedTypeRef(inner) => {
tracer.visit_kind(inner.into(), EdgeKind::TypeReference);