Author: benm
Date: 2005-07-03 18:37:40 -0400 (Sun, 03 Jul 2005)
New Revision: 46894

Added:
   trunk/mcs/tools/monop/monop2.exe.sources
Modified:
   trunk/mcs/tools/monop/
   trunk/mcs/tools/monop/ChangeLog
   trunk/mcs/tools/monop/Makefile
   trunk/mcs/tools/monop/outline.cs
Log:
        * *: begin support for 2.0




Property changes on: trunk/mcs/tools/monop
___________________________________________________________________
Name: svn:ignore
   - monop.exe
*.pdb
*.mdb
semantic.cache

   + *.exe
*.pdb
*.mdb
semantic.cache


Modified: trunk/mcs/tools/monop/ChangeLog
===================================================================
--- trunk/mcs/tools/monop/ChangeLog     2005-07-03 21:08:50 UTC (rev 46893)
+++ trunk/mcs/tools/monop/ChangeLog     2005-07-03 22:37:40 UTC (rev 46894)
@@ -1,5 +1,7 @@
 2005-07-03  Ben Maurer  <[EMAIL PROTECTED]>
 
+       * *: begin support for 2.0
+
        * outline.cs: Add support for readonly fields.
 
 2005-05-30  Ben Maurer  <[EMAIL PROTECTED]>

Modified: trunk/mcs/tools/monop/Makefile
===================================================================
--- trunk/mcs/tools/monop/Makefile      2005-07-03 21:08:50 UTC (rev 46893)
+++ trunk/mcs/tools/monop/Makefile      2005-07-03 22:37:40 UTC (rev 46894)
@@ -2,6 +2,10 @@
 SUBDIRS = 
 include ../../build/rules.make
 
+ifeq (net_2_0, $(PROFILE))
+PROGRAM = monop2.exe
+else
 PROGRAM = monop.exe
+endif
 
 include ../../build/executable.make

Added: trunk/mcs/tools/monop/monop2.exe.sources
===================================================================
--- trunk/mcs/tools/monop/monop2.exe.sources    2005-07-03 21:08:50 UTC (rev 
46893)
+++ trunk/mcs/tools/monop/monop2.exe.sources    2005-07-03 22:37:40 UTC (rev 
46894)
@@ -0,0 +1,4 @@
+monop.cs
+options.cs
+outline.cs
+TypeSorter.cs

Modified: trunk/mcs/tools/monop/outline.cs
===================================================================
--- trunk/mcs/tools/monop/outline.cs    2005-07-03 21:08:50 UTC (rev 46893)
+++ trunk/mcs/tools/monop/outline.cs    2005-07-03 22:37:40 UTC (rev 46894)
@@ -34,6 +34,7 @@
 using System.Collections;
 using System.CodeDom.Compiler;
 using System.IO;
+using System.Text;
        
 public class Outline {
        
@@ -76,7 +77,7 @@
 
                        o.Write (FormatType (method.ReturnType));
                        o.Write (" ");
-                       o.Write (t.Name);
+                       o.Write (GetTypeName (t));
                        o.Write (" (");
                        OutlineParams (method.GetParameters ());
                        o.WriteLine (");");
@@ -84,7 +85,7 @@
                        return;
                }
                
-               o.Write (t.Name);
+               o.Write (GetTypeName (t));
                if (((parent != null && parent != typeof (object) && parent != 
typeof (ValueType)) || interfaces.Length != 0) && ! t.IsEnum) {
                        first = true;
                        o.Write (" : ");
@@ -287,7 +288,7 @@
        void OutlineConstructor (ConstructorInfo ci)
        {
                o.Write (GetMethodVisibility (ci));
-               o.Write (t.Name);
+               o.Write (RemoveGenericArity (t.Name));
                o.Write (" (");
                OutlineParams (ci.GetParameters ());
                o.Write (");");
@@ -487,7 +488,7 @@
        
        string FormatType (Type t)
        {
-               string type = t.FullName;
+               string type = GetFullName (t);
                
                if (!type.StartsWith ("System.")) {
                        if (t.Namespace == this.t.Namespace)
@@ -533,6 +534,85 @@
                return type;
        }
 
+       public static string RemoveGenericArity (string name)
+       {
+               int start = 0;
+               StringBuilder sb = new StringBuilder ();
+               while (start < name.Length) {
+                       int pos = name.IndexOf ('`', start);
+                       if (pos < 0) {
+                               sb.Append (name.Substring (start));
+                               break;
+                       }
+                       sb.Append (name.Substring (start, pos-start));
+
+                       pos++;
+
+                       while ((pos < name.Length) && Char.IsNumber (name 
[pos]))
+                               pos++;
+
+                       start = pos;
+               }
+
+               return sb.ToString ();
+       }
+
+       string GetTypeName (Type t)
+       {
+               StringBuilder sb = new StringBuilder ();
+               GetTypeName (sb, t);
+               return sb.ToString ();
+       }
+
+       void GetTypeName (StringBuilder sb, Type t)
+       {
+               sb.Append (RemoveGenericArity (t.Name));
+#if NET_2_0
+               Type[] args = t.GetGenericArguments ();
+               if (args.Length > 0) {
+                       sb.Append ("<");
+                       for (int i = 0; i < args.Length; i++) {
+                               if (i > 0)
+                                       sb.Append (",");
+                               sb.Append (FormatType (args [i]));
+                       }
+                       sb.Append (">");
+               }
+#endif
+       }
+
+       string GetFullName (Type t)
+       {
+               StringBuilder sb = new StringBuilder ();
+               GetFullName_recursed (sb, t, false);
+               return sb.ToString ();
+       }
+
+       void GetFullName_recursed (StringBuilder sb, Type t, bool recursed)
+       {
+#if NET_2_0
+               if (t.IsGenericParameter) {
+                       sb.Append (t.Name);
+                       return;
+               }
+#endif
+
+               if (t.DeclaringType != null) {
+                       GetFullName_recursed (sb, t.DeclaringType, true);
+                       sb.Append (".");
+               }
+
+               if (!recursed) {
+                       string ns = t.Namespace;
+                       if ((ns != null) && (ns != "")) {
+                               sb.Append (ns);
+                               sb.Append (".");
+                       }
+               }
+
+               GetTypeName (sb, t);
+       }
+
        string OperatorFromName (string name)
        {
                switch (name) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to