Skip to content

Commit 66743be

Browse files
committed
Add the TypeKind name to the IR graphviz output
1 parent cb10597 commit 66743be

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
@@ -443,6 +443,8 @@ impl DotAttributes for TypeKind {
443443
where
444444
W: io::Write,
445445
{
446+
writeln!(out, "<tr><td>type kind</td><td>{}</td></tr>", self.kind_name())?;
447+
446448
if let TypeKind::Comp(ref comp) = *self {
447449
comp.dot_attributes(ctx, out)?;
448450
}
@@ -451,6 +453,35 @@ impl DotAttributes for TypeKind {
451453
}
452454
}
453455

456+
impl TypeKind {
457+
fn kind_name(&self) -> &'static str {
458+
match *self {
459+
TypeKind::Void => "Void",
460+
TypeKind::NullPtr => "NullPtr",
461+
TypeKind::Comp(..) => "Comp",
462+
TypeKind::Opaque => "Opaque",
463+
TypeKind::Int(..) => "Int",
464+
TypeKind::Float(..) => "Float",
465+
TypeKind::Complex(..) => "Complex",
466+
TypeKind::Alias(..) => "Alias",
467+
TypeKind::TemplateAlias(..) => "TemplateAlias",
468+
TypeKind::Array(..) => "Array",
469+
TypeKind::Function(..) => "Function",
470+
TypeKind::Enum(..) => "Enum",
471+
TypeKind::Pointer(..) => "Pointer",
472+
TypeKind::BlockPointer => "BlockPointer",
473+
TypeKind::Reference(..) => "Reference",
474+
TypeKind::TemplateInstantiation(..) => "TemplateInstantiation",
475+
TypeKind::UnresolvedTypeRef(..) => "UnresolvedTypeRef",
476+
TypeKind::ResolvedTypeRef(..) => "ResolvedTypeRef",
477+
TypeKind::TypeParam => "TypeParam",
478+
TypeKind::ObjCInterface(..) => "ObjCInterface",
479+
TypeKind::ObjCId => "ObjCId",
480+
TypeKind::ObjCSel => "ObjCSel",
481+
}
482+
}
483+
}
484+
454485
#[test]
455486
fn is_invalid_type_param_valid() {
456487
let ty = Type::new(Some("foo".into()), None, TypeKind::TypeParam, false);

0 commit comments

Comments
 (0)