2008-08-07 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System / Microsoft.CSharp / CSharpCodeGenerator.cs
index 899e7865a01a4124e25e3d6148f89373abd19f13..b91480a1fa30872ad9b7ad12933ea67de8c13527 100644 (file)
@@ -48,7 +48,7 @@ namespace Mono.CSharp
                : CodeGenerator
        {
 #if NET_2_0
-               Dictionary <string, string> providerOptions;
+               IDictionary <string, string> providerOptions;
 #endif
                
                // It is used for beautiful "for" syntax
@@ -63,12 +63,12 @@ namespace Mono.CSharp
                }
 
 #if NET_2_0
-               public CSharpCodeGenerator (Dictionary <string, string> providerOptions)
+               public CSharpCodeGenerator (IDictionary <string, string> providerOptions)
                {
                        this.providerOptions = providerOptions;
                }
 
-               protected Dictionary <string, string> ProviderOptions {
+               protected IDictionary <string, string> ProviderOptions {
                        get { return providerOptions; }
                }
 #endif
@@ -561,6 +561,9 @@ namespace Mono.CSharp
                {
                        Output.WriteLine ();
                        Output.WriteLine ("#line default");
+#if NET_2_0
+                       Output.WriteLine ("#line hidden");
+#endif
                }
 
                protected override void GenerateEvent (CodeMemberEvent eventRef, CodeTypeDeclaration declaration)
@@ -694,7 +697,7 @@ namespace Mono.CSharp
                        GenerateGenericsConstraints (method.TypeParameters);
 #endif
 
-                       if ((attributes & MemberAttributes.ScopeMask) == MemberAttributes.Abstract || declaration.IsInterface)
+                       if (IsAbstract (attributes) || declaration.IsInterface)
                                output.WriteLine (';');
                        else {
                                OutputStartBrace ();
@@ -707,7 +710,7 @@ namespace Mono.CSharp
 
                static bool IsAbstract (MemberAttributes attributes)
                {
-                       return (attributes & MemberAttributes.Abstract) == MemberAttributes.Abstract;
+                       return (attributes & MemberAttributes.ScopeMask) == MemberAttributes.Abstract;
                }
 
                protected override void GenerateProperty (CodeMemberProperty property,
@@ -954,7 +957,18 @@ namespace Mono.CSharp
 
                private void OutputAttributes (CodeAttributeDeclarationCollection attributes, string prefix, bool inline)
                {
+#if NET_2_0
+                       bool params_set = false;
+#endif
+
                        foreach (CodeAttributeDeclaration att in attributes) {
+#if NET_2_0
+                               if (att.Name == "System.ParamArrayAttribute") {
+                                       params_set = true;
+                                       continue;
+                               }
+#endif
+
                                GenerateAttributeDeclarationsStart (attributes);
                                if (prefix != null) {
                                        Output.Write (prefix);
@@ -967,6 +981,18 @@ namespace Mono.CSharp
                                        Output.WriteLine ();
                                }
                        }
+
+#if NET_2_0
+                       if (params_set) {
+                               if (prefix != null)
+                                       Output.Write (prefix);
+                               Output.Write ("params");
+                               if (inline)
+                                       Output.Write (" ");
+                               else
+                                       Output.WriteLine ();
+                       }
+#endif
                }
 
                private void OutputAttributeDeclaration (CodeAttributeDeclaration attribute)
@@ -1367,11 +1393,14 @@ namespace Mono.CSharp
                                                                // skip ` character
                                                                i++;
                                                                // determine number of type arguments to output
-                                                               int typeArgCount = baseType[i] - '0';
+                                                               int end = i;
+                                                               while (end < baseType.Length && Char.IsDigit (baseType [end]))
+                                                                       end++;
+                                                               int typeArgCount = Int32.Parse (baseType.Substring (i, end - i));
                                                                // output type arguments
                                                                OutputTypeArguments (type.TypeArguments, sb, typeArgCount);
                                                                // skip type argument indicator
-                                                               i++;
+                                                               i = end;
                                                                // if next character is . or +, then append .
                                                                if ((i < baseType.Length) && ((baseType[i] == '+') || (baseType[i] == '.'))) {
                                                                        sb.Append ('.');