Просмотр исходного кода

add enum improvement
and type name kinds

svn path=/trunk/mcs/; revision=26098

John Luke 22 лет назад
Родитель
Сommit
4bcccdc4b2
2 измененных файлов с 37 добавлено и 2 удалено
  1. 8 0
      mcs/tools/monop/ChangeLog
  2. 29 2
      mcs/tools/monop/outline.cs

+ 8 - 0
mcs/tools/monop/ChangeLog

@@ -1,3 +1,11 @@
+2004-04-27  John Luke <[email protected]>
+
+	* outline.cs: add GetTypeKind so we print
+	enums and interfaces, instead of always class or
+	struct	
+	add a special case for enums so we just print the fields
+	and quit
+
 2004-04-03  Duncan Mak  <[email protected]>
 
 	* monop.cs (PrintTypes): show the number of types in the assembly

+ 29 - 2
mcs/tools/monop/outline.cs

@@ -24,12 +24,12 @@ public class Outline {
 		this.t = t;
 		this.o = new IndentedTextWriter (output, "    ");
 	}
-	
+
 	public void OutlineType ()
         {
 		o.Write (GetTypeVisibility (t));
 		o.Write (" ");
-		o.Write (t.IsValueType ? "struct" : "class");
+		o.Write (GetTypeKind (t));
 		o.Write (" ");
 		o.Write (t.Name);
 		
@@ -55,6 +55,20 @@ public class Outline {
 		
 		o.WriteLine (" {");
 		o.Indent++;
+
+		if (t.IsEnum)
+		{
+			foreach (FieldInfo fi in t.GetFields ()) {
+				if (fi.Name != "value__")
+				{
+					o.Write (fi.Name);
+					o.Write (";");
+					o.WriteLine ();
+				}
+			}
+			o.Indent--; o.WriteLine ("}");
+			return;
+		}
 		
 		foreach (ConstructorInfo ci in t.GetConstructors ()) {
 			OutlineConstructor (ci);
@@ -196,6 +210,19 @@ public class Outline {
 		
 		return null;
 	}
+
+	static string GetTypeKind (Type t)
+	{
+		if (t.IsEnum)
+			return "enum";
+		if (t.IsClass)
+			return "class";
+		if (t.IsInterface)
+			return "interface";
+		if (t.IsValueType)
+			return "struct";
+		return "class";
+	}
 	
 	static string GetTypeVisibility (Type t)
 	{