Skip to content

Commit 187920d

Browse files
committed
Add the TypeKind name to the IR graphviz output
1 parent e841f6f commit 187920d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/ir/ty.rs

+31
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ impl DotAttributes for TypeKind {
435435
where
436436
W: io::Write,
437437
{
438+
writeln!(out, "<tr><td>type kind</td><td>{}</td></tr>", self.kind_name())?;
439+
438440
if let TypeKind::Comp(ref comp) = *self {
439441
comp.dot_attributes(ctx, out)?;
440442
}
@@ -443,6 +445,35 @@ impl DotAttributes for TypeKind {
443445
}
444446
}
445447

448+
impl TypeKind {
449+
fn kind_name(&self) -> &'static str {
450+
match *self {
451+
TypeKind::Void => "Void",
452+
TypeKind::NullPtr => "NullPtr",
453+
TypeKind::Comp(..) => "Comp",
454+
TypeKind::Opaque => "Opaque",
455+
TypeKind::Int(..) => "Int",
456+
TypeKind::Float(..) => "Float",
457+
TypeKind::Complex(..) => "Complex",
458+
TypeKind::Alias(..) => "Alias",
459+
TypeKind::TemplateAlias(..) => "TemplateAlias",
460+
TypeKind::Array(..) => "Array",
461+
TypeKind::Function(..) => "Function",
462+
TypeKind::Enum(..) => "Enum",
463+
TypeKind::Pointer(..) => "Pointer",
464+
TypeKind::BlockPointer => "BlockPointer",
465+
TypeKind::Reference(..) => "Reference",
466+
TypeKind::TemplateInstantiation(..) => "TemplateInstantiation",
467+
TypeKind::UnresolvedTypeRef(..) => "UnresolvedTypeRef",
468+
TypeKind::ResolvedTypeRef(..) => "ResolvedTypeRef",
469+
TypeKind::TypeParam => "TypeParam",
470+
TypeKind::ObjCInterface(..) => "ObjCInterface",
471+
TypeKind::ObjCId => "ObjCId",
472+
TypeKind::ObjCSel => "ObjCSel",
473+
}
474+
}
475+
}
476+
446477
#[test]
447478
fn is_invalid_type_param_valid() {
448479
let ty = Type::new(Some("foo".into()), None, TypeKind::TypeParam, false);

0 commit comments

Comments
 (0)